Search

Tailwind - Table ํ…Œ์ด๋ธ”

Tailwind - Table ํ…Œ์ด๋ธ”

tailwind ๋กœ Table ์„ ๋งŒ๋“ค์–ด๋ด…๋‹ˆ๋‹ค.
import React from 'react' import MainLayout from '../../layouts/MainLayout' const Table = () => { return ( <MainLayout> <div className="sm:p-24 px-4 py-12 flex flex-col justify-center items-center"> <h3 className="pb-10 font-bold text-4xl"> Table </h3> <div className="inline-block min-w-full shadow-md rounded-lg overflow-hidden"> <table className="min-w-full leading-normal"> <thead> <tr> <th className="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider" > ๊ณ ๊ฐ๋ช… </th> <th className="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider hidden md:table-cell" > ์ „ํ™”๋ฒˆํ˜ธ / ์ด๋ฉ”์ผ </th> <th className="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider hidden md:table-cell" > ๊ฐ€์ž… ์ผ์ž </th> <th className="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider hidden sm:table-cell" > ์ƒํƒœ </th> <th className="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-right" ></th> </tr> </thead> <tbody> <tr> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm"> <div className="flex"> <div className="flex-shrink-0 w-10 h-10"> <img className="w-full h-full rounded-full border" src="https://i.imgur.com/CbuD3gl.png" alt="" /> </div> <div className="ml-3"> <p className="text-gray-900 whitespace-no-wrap"> ์•Œ๋กœํ•˜ </p> <p className="text-gray-600 whitespace-no-wrap hidden md:block">Lv.100</p> </div> </div> </td> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm hidden md:table-cell"> <p className="text-gray-900 whitespace-no-wrap">010-0000-0000</p> <p className="text-gray-600 whitespace-no-wrap">wwwaloha@kakao.com</p> </td> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm hidden md:table-cell"> <p className="text-gray-900 whitespace-no-wrap">2025/01/01</p> <p className="text-gray-600 whitespace-no-wrap">3 ์ผ์ „</p> </td> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm hidden sm:table-cell"> <span className="relative inline-block px-3 py-1 font-semibold text-green-900 leading-tight" > <span aria-hidden className="absolute inset-0 bg-green-200 opacity-50 rounded-full" ></span> <span className="relative">ํ™œ๋™์ค‘</span> </span> </td> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm text-right" > <button type="button" className="inline-block text-gray-500 hover:text-gray-700" > <svg className="inline-block h-6 w-6 fill-current" viewBox="0 0 24 24" > <path d="M12 6a2 2 0 110-4 2 2 0 010 4zm0 8a2 2 0 110-4 2 2 0 010 4zm-2 6a2 2 0 104 0 2 2 0 00-4 0z" /> </svg> </button> </td> </tr> <tr> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm"> <div className="flex"> <div className="flex-shrink-0 w-10 h-10"> <img className="w-full h-full rounded-full border" src="https://i.imgur.com/PqgZlA0.png" alt="" /> </div> <div className="ml-3"> <p className="text-gray-900 whitespace-no-wrap"> ๊น€์กฐ์€ </p> <p className="text-gray-600 whitespace-no-wrap hidden md:block">Lv.50</p> </div> </div> </td> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm hidden md:table-cell"> <p className="text-gray-900 whitespace-no-wrap">010-0000-0000</p> <p className="text-gray-600 whitespace-no-wrap">wwwaloha@kakao.com</p> </td> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm hidden md:table-cell"> <p className="text-gray-900 whitespace-no-wrap">2025/01/01</p> <p className="text-gray-600 whitespace-no-wrap">3 ์ผ์ „</p> </td> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm hidden sm:table-cell"> <span className="relative inline-block px-3 py-1 font-semibold text-green-900 leading-tight" > <span aria-hidden className="absolute inset-0 bg-green-200 opacity-50 rounded-full" ></span> <span className="relative">ํ™œ๋™์ค‘</span> </span> </td> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm text-right" > <button type="button" className="inline-block text-gray-500 hover:text-gray-700" > <svg className="inline-block h-6 w-6 fill-current" viewBox="0 0 24 24" > <path d="M12 6a2 2 0 110-4 2 2 0 010 4zm0 8a2 2 0 110-4 2 2 0 010 4zm-2 6a2 2 0 104 0 2 2 0 00-4 0z" /> </svg> </button> </td> </tr> <tr> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm"> <div className="flex"> <div className="flex-shrink-0 w-10 h-10"> <img className="w-full h-full rounded-full border" src="https://i.imgur.com/vmkZm6D.png" alt="" /> </div> <div className="ml-3"> <p className="text-gray-900 whitespace-no-wrap"> ์‹ ์ค€์ˆ˜ </p> <p className="text-gray-600 whitespace-no-wrap hidden md:block">Lv.1</p> </div> </div> </td> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm hidden md:table-cell"> <p className="text-gray-900 whitespace-no-wrap">010-0000-0000</p> <p className="text-gray-600 whitespace-no-wrap">wwwaloha@kakao.com</p> </td> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm hidden md:table-cell"> <p className="text-gray-900 whitespace-no-wrap">2025/01/01</p> <p className="text-gray-600 whitespace-no-wrap">3 ์ผ์ „</p> </td> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm hidden sm:table-cell"> <span className="relative inline-block px-3 py-1 font-semibold text-orange-900 leading-tight" > <span aria-hidden className="absolute inset-0 bg-orange-200 opacity-50 rounded-full" ></span> <span className="relative">๋Œ€๊ธฐ์ค‘</span> </span> </td> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm text-right" > <button type="button" className="inline-block text-gray-500 hover:text-gray-700" > <svg className="inline-block h-6 w-6 fill-current" viewBox="0 0 24 24" > <path d="M12 6a2 2 0 110-4 2 2 0 010 4zm0 8a2 2 0 110-4 2 2 0 010 4zm-2 6a2 2 0 104 0 2 2 0 00-4 0z" /> </svg> </button> </td> </tr> <tr> <td className="px-5 py-5 bg-white text-sm"> <div className="flex"> <div className="flex-shrink-0 w-10 h-10"> <img className="w-full h-full rounded-full border" src="https://i.imgur.com/OD1a0Mv.png" alt="" /> </div> <div className="ml-3"> <p className="text-gray-900 whitespace-no-wrap"> ๊ตฌ๊ต์ฐฌ </p> <p className="text-gray-600 whitespace-no-wrap hidden md:block">Lv.5</p> </div> </div> </td> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm hidden md:table-cell"> <p className="text-gray-900 whitespace-no-wrap">010-0000-0000</p> <p className="text-gray-600 whitespace-no-wrap">wwwaloha@kakao.com</p> </td> <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm hidden md:table-cell"> <p className="text-gray-900 whitespace-no-wrap">2025/01/01</p> <p className="text-gray-600 whitespace-no-wrap">3 ์ผ์ „</p> </td> <td className="px-5 py-5 bg-white text-sm hidden sm:table-cell"> <span className="relative inline-block px-3 py-1 font-semibold text-red-900 leading-tight" > <span aria-hidden className="absolute inset-0 bg-red-200 opacity-50 rounded-full" ></span> <span className="relative">๋น„ํ™œ์„ฑํ™”</span> </span> </td> <td className="px-5 py-5 bg-white text-sm text-right"> <button type="button" className="inline-block text-gray-500 hover:text-gray-700" > <svg className="inline-block h-6 w-6 fill-current" viewBox="0 0 24 24" > <path d="M12 6a2 2 0 110-4 2 2 0 010 4zm0 8a2 2 0 110-4 2 2 0 010 4zm-2 6a2 2 0 104 0 2 2 0 00-4 0z" /> </svg> </button> </td> </tr> </tbody> </table> </div> </div> </MainLayout> ) } export default Table
JavaScript
๋ณต์‚ฌ
<thead> <tr> <th className="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider" > ๊ณ ๊ฐ๋ช… </th> <th className="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider hidden md:table-cell" > ์ „ํ™”๋ฒˆํ˜ธ / ์ด๋ฉ”์ผ </th> <th className="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider hidden md:table-cell" > ๊ฐ€์ž… ์ผ์ž </th> <th className="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider ' hidden sm:table-cell" > ์ƒํƒœ </th> <th className="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-right" ></th> </tr> </thead>
JavaScript
๋ณต์‚ฌ
โ€ข
PC : ๊ณ ๊ฐ๋ช…, ์ „ํ™”๋ฒˆํ˜ธ/์ด๋ฉ”์ผ, ๊ฐ€์ž…์ผ์ž, ์ƒํƒœ, (๋”๋ณด๊ธฐ)
โ€ข
Tablet : ๊ณ ๊ฐ๋ช…, ์ƒํƒœ, (๋”๋ณด๊ธฐ)
โ€ข
mobile : ๊ณ ๊ฐ๋ช…, (๋”๋ณด๊ธฐ)
๋ฐ˜์‘ํ˜• ํ…Œ์ด๋ธ”๋กœ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•ด์„œ, ๊ฐ๊ฐ ๋””๋ฐ”์ด์Šค ๋ณ„๋กœ ์ถœ๋ ฅํ•  ์—ด์„ ์œ„์™€ ๊ฐ™์ด ์ •ํ•ฉ๋‹ˆ๋‹ค.
์ด ๋•Œ mobile~PC ๊นŒ์ง€ ์ถœ๋ ฅํ•˜๋Š” ์—ด์„ ๊ณ ๊ฐ๋ช…๊ณผ (๋”๋ณด๊ธฐ) ์ž…๋‹ˆ๋‹ค.
hidden ํด๋ž˜์Šค๋ฅผ ์ง€์ •ํ•˜๋ฉด ํ™”๋ฉด์— ์ถœ๋ ฅ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
sm:table-cell ํด๋ž˜์Šค๋ฅผ ์ง€์ •ํ•˜๋ฉด sm(์ตœ์†Œ 640px ์ด์ƒ) ์‚ฌ์ด์ฆˆ๋ถ€ํ„ฐ ์ถœ๋ ฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๋”ฐ๋ผ์„œ Tablet ์‚ฌ์ด์ฆˆ๋ถ€ํ„ฐ ๋ณด์—ฌ์ฃผ์–ด์•ผํ•  ์ƒํƒœ ์—ด์— ์•„๋ž˜์™€ ๊ฐ™์ด ์ง€์ •ํ•˜๋ฉด, ํƒœ๋ธ”๋ฆฟ ์ •๋„ ์‚ฌ์ด์ฆˆ๋ถ€ํ„ฐ ์ƒํƒœ ์—ด์„ ์ถœ๋ ฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
<th className="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider ' hidden sm:table-cell" > ์ƒํƒœ </th>
JavaScript
๋ณต์‚ฌ
์ „ํ™”๋ฒˆํ˜ธ/์ด๋ฉ”์ผ, ๊ฐ€์ž…์ผ์ž ๋Š” ํƒœ๋ธ”๋ฆฟ ์ •๋„ ์‚ฌ์ด์ฆˆ๋ณด๋‹ค ์กฐ๊ธˆ ๋” ํฐ ์‚ฌ์ด์ฆˆ๋ถ€ํ„ฐ ๋ณด์—ฌ์ฃผ์–ด์•ผํ•˜๋ฏ€๋กœ, md:table-cell ํด๋ž˜์Šค๋ฅผ ์ง€์ •ํ•˜์—ฌ, ํƒœ๋ธ”๋ฆฟ์ด์ƒ๋ถ€ํ„ฐ PC ์‚ฌ์ด์ฆˆ์—์„œ ์ถœ๋ ฅ๋˜๋„๋ก ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.