β¨ λ€μ΄κ°λ©°
μΉ νλ‘ νΈμλλ₯Ό κ°λ°νλ©΄μ CSS λλ¬Έμ 골머리λ₯Ό μμλ³Έ μ μ΄ μμΌμ κ°μ?
ν΄λμ€ μ΄λ¦μ μ΄λ»κ² μ§μ΄μΌ νμ§?, λμμΈ μμ€ν
μ μ΄λ»κ² λ§λ€μ§? κ³ λ―Ό λ§μΌμ
¨λ€λ©΄, Tailwind CSSκ° μ¬λ¬λΆμ κ³ λ―Όμ ν μ€μ¬μ€ μ μμ΅λλ€.
Tailwind CSSλ μ νΈλ¦¬ν° νΌμ€νΈ CSS νλ μμν¬λ‘, 미리 μ μλ ν΄λμ€λ₯Ό μ‘°ν©ν΄μ λΉ λ₯΄κ² UIλ₯Ό λ§λ€ μ μλ κ°λ ₯ν λꡬμ λλ€.
π οΈ 1. Tailwind CSSλ?
π ν΅μ¬ νΉμ§
- μ νΈλ¦¬ν° ν΄λμ€ κΈ°λ°:
p-4
,bg-blue-500
,text-center
κ°μ ν΄λμ€λ₯Ό μ‘°ν©ν΄ μ€νμΌ μ μ© - μ»΄ν¬λνΈ μ€νμΌ μ¬μ¬μ©: λ³λ CSS νμΌ μμ΄λ λΉ λ₯΄κ² UI ꡬμ±
- λͺ¨λ°μΌ νΌμ€νΈ, λ°μν μμ¬μ:
sm:
,md:
,lg:
μ λμ΄λ‘ λ°μν μ½κ² ꡬν - λμμΈ μμ€ν μ΅μ ν: νμ₯μ±κ³Ό μ μ§λ³΄μμ κ°ν¨
π κΈ°μ‘΄ λ°©μκ³Ό λΉκ΅
μ ν΅ CSS | Tailwind CSS |
---|---|
ν΄λμ€λͺ μ§μ μ μ | ν΄λμ€ μ‘°ν©μΌλ‘ μ€νμΌ |
CSS νμΌ λ°λ‘ μμ± | HTML μμμ μ€νμΌ κ΅¬μ± |
μ¬μ¬μ© μ΄λ €μ | μ¬μ¬μ©μ±κ³Ό μ μ§λ³΄μ μ©μ΄ |
βοΈ 2. μ€μΉ λ°©λ² (Vite κΈ°μ€)
Tailwindλ λ€μν νκ²½μμ μΈ μ μμ§λ§, μμ¦ κ°μ₯ μΈκΈ° μλ Vite + Tailwind μ‘°ν©μΌλ‘ μ€λͺ λ릴κ²μ.
1) Vite νλ‘μ νΈ μμ±
npm create vite@latest my-tailwind-app -- --template vanilla
cd my-tailwind-app
npm install
2) Tailwind μ€μΉ
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
3) μ€μ νμΌ μμ
tailwind.config.js
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}"
],
theme: {
extend: {},
},
plugins: [],
}
src/index.css
@tailwind base;
@tailwind components;
@tailwind utilities;
main.js
import './index.css'
4) μ€ν
npm run dev
λΈλΌμ°μ μμ http://localhost:5173
νμΈ!
π§± 3. κΈ°λ³Έ μ νΈλ¦¬ν° ν΄λμ€
π λ μ΄μμ & λ°μ€ λͺ¨λΈ
ν΄λμ€ | μλ―Έ |
---|---|
p-4 | padding: 1rem |
m-2 | margin: 0.5rem |
w-full | width: 100% |
h-screen | height: 100vh |
max-w-md | max-width: medium |
π¨ λ°°κ²½ λ° ν λ리
ν΄λμ€ | μλ―Έ |
---|---|
bg-blue-500 | νλ λ°°κ²½ |
border | ν λ리 1px |
rounded-lg | λͺ¨μ리 λΌμ΄λ μ²λ¦¬ |
shadow-md | κ·Έλ¦Όμ μ€κ° μ λ |
π ν μ€νΈ κ΄λ ¨
ν΄λμ€ | μλ―Έ |
---|---|
text-lg | ν° κΈμ¨ |
font-bold | λ³Όλ체 |
text-center | κ°μ΄λ° μ λ ¬ |
text-gray-600 | νμ ν μ€νΈ |
π± λ°μν
ν΄λμ€ | μλ―Έ |
---|---|
sm:text-sm | μμ νλ©΄μμ μμ ν μ€νΈ |
md:w-1/2 | μ€κ° νλ©΄λΆν° λλΉ 50% |
lg:flex-row | ν° νλ©΄λΆν° row λ°©ν₯μΌλ‘ flex |
π‘ 4. μ€μ μμ : μΉ΄λ UI
<div class="max-w-sm mx-auto bg-white rounded-xl shadow-md overflow-hidden p-6">
<h2 class="text-xl font-semibold text-gray-800 mb-2">Tailwind μμνκΈ°</h2>
<p class="text-gray-600">μ΄λ κ² μΉ΄λ UIλ κ°λ¨νκ² λ§λ€ μ μμ΄μ!</p>
</div>
λ¨ ν μ€μ CSS μμ΄λ μμ±λ μλ UI κ°λ₯!
π 5. μμ£Ό μ°λ Tailwind ν¨ν΄
μ©λ | ν΄λμ€ μμ |
---|---|
λ²νΌ | bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded |
μ λ ₯μ°½ | border border-gray-300 p-2 rounded w-full |
λ μ΄μμ | flex items-center justify-between |
μΉμ | py-8 px-4 sm:px-6 lg:px-8 |
π§ 6. νκ³Ό νΈλ¬λΈμν
π§ κ°λ° ν
class
κ° κΈΈμ΄μ§λ©΄@apply
λ₯Ό νμ©ν΄ μ¬μ¬μ© κ°λ₯- Tailwind UI, daisyUI, Flowbite κ°μ μ»΄ν¬λνΈ λΌμ΄λΈλ¬λ¦¬ νμ© μΆμ²
- IntelliSense μ€μΉ (VSCode): μλμμ±μΌλ‘ μμ°μ± κ·Ήλν
π§ͺ μ€μκ° λμμΈ ν μ€νΈ
- Tailwind Play (μ¨λΌμΈ μλν°): https://play.tailwindcss.com/
π§© 7. Tailwind CSS ν νλ¦ΏμΌλ‘ λΉ λ₯΄κ² μμνκΈ°
Tailwind CSS μνκ³μλ μλ§μ μ€νμμ€ ν νλ¦Ώκ³Ό λμμΈ μ»΄ν¬λνΈλ€μ΄ μ‘΄μ¬ν©λλ€. μ΄λ₯Ό νμ©νλ©΄ λΉ λ₯΄κ² λ©μ§ UIλ₯Ό λ§λ€ μ μμ΄μ.
π λνμ μΈ λ¬΄λ£ ν νλ¦Ώ μ¬μ΄νΈ
νλ«νΌ | νΉμ§ |
---|---|
Tailwind UI | Tailwind 곡μ μ λ£ ν νλ¦Ώ (λμμΈ νλ¦¬ν° μ΅μ) |
daisyUI | λ²νΌ, μΉ΄λ, λͺ¨λ¬ λ± UI μ»΄ν¬λνΈ λͺ¨λ μ 곡 |
Flowbite | Tailwind κΈ°λ° μ€νμμ€ UI ν€νΈ + ν νλ¦Ώ |
TailGrids | λΉμ¦λμ€μ© ν νλ¦Ώ λͺ¨μ |
Cruip | μ€ννΈμ /SAASμ© λ¬΄λ£ & μ λ£ ν νλ¦Ώ |
HyperUI | λ€μν λ―Έλ €ν UI μ»΄ν¬λνΈ λͺ¨μ (무λ£) |
Treact | React κΈ°λ° λ¬΄λ£ ν νλ¦Ώ (Tailwind μ¬μ©) |
π¦ μμ: daisyUIλ‘ λ²νΌ λ§λ€μ΄λ³΄κΈ°
μ€μΉ
npm install daisyui
tailwind.config.js
μ μΆκ°
module.exports = {
plugins: [require("daisyui")],
}
μ¬μ© μ
<button class="btn btn-primary">λ‘κ·ΈμΈ</button>
<button class="btn btn-outline btn-accent">νμκ°μ
</button>
β λ€μν λ²νΌ μ€νμΌ, μ λ ₯μ°½, λͺ¨λ¬ λ±μ ν μ€λ‘ ꡬν κ°λ₯!
π§° μ€μ ν νλ¦Ώ νλ‘μ νΈ μμ
πΌ ν¬νΈν΄λ¦¬μ€ ν νλ¦Ώ
- Tailwind Awesomeμμ “Portfolio” κ²μ
- λ μ΄μμ, νλ‘μ νΈ μκ°, μ°λ½μ² μΉμ ν¬ν¨λ ꡬ쑰
π μΌνλͺ° ν νλ¦Ώ
- Flowbite E-Commerce νμ©
- μν λͺ©λ‘, μ₯λ°κ΅¬λ, κ²°μ UI μ 곡
π± Landing Page ν νλ¦Ώ
- Cruip λ¬΄λ£ ν νλ¦Ώ
- μ¬μ€(SaaS), μ€ννΈμ μ© λ°μν μκ° νμ΄μ§
β¨ ν νλ¦Ώ μ¬μ© ν
ν | μ€λͺ |
---|---|
βοΈ HTMLλ§ λΆμ¬λ£μΌλ©΄ λ¨ | Tailwindμ μ₯μ : CSS λ°λ‘ μ€μ λΆνμ |
π¨ μμ, κ°κ²©λ§ λ°κΏλ λΆμκΈ° ν λ¬λΌμ§ | bg- , text- , p- , m- λ± μ‘°μ |
π§© μ»΄ν¬λνΈν μΆμ² | Svelte, React λ±μμ ν νλ¦Ώμ μ»΄ν¬λνΈλ‘ μͺΌκ°μ κ΄λ¦¬νλ©΄ μ μ§λ³΄μ μ¬μ |
β οΈ Tailwind λ²μ μ£Όμ | ν νλ¦Ώμ΄ μ¬μ©νλ Tailwind λ²μ κ³Ό νλ‘μ νΈμ λ²μ μ΄ λ€λ₯΄λ©΄ μΌλΆ ν΄λμ€κ° μλνμ§ μμ μ μμ |
β λ§λ¬΄λ¦¬νλ©°
Tailwind CSSλ μ²μμ μ‘°κΈ λ―μ€ μ μμ§λ§, μ΅μν΄μ§λ©΄ μ λ§ λΉ λ₯΄κ³ ν¨μ¨μ μΈ μ€νμΌλ§ λꡬμ
λλ€.
νΉν νλ‘ νΈμλ κ°λ°μ, νλ‘ν νμ΄νμ΄ λΉ λ₯Έ ν, λμμΈ μΌκ΄μ±μ΄ νμν νλ‘μ νΈμ ν° νμ΄ λ©λλ€.
π μ°Έκ³ λ§ν¬
- 곡μ μ¬μ΄νΈ: https://tailwindcss.com
- VSCode νμ₯: Tailwind CSS IntelliSense
- UI μ»΄ν¬λνΈ λͺ¨μ: https://tailwindui.com, https://daisyui.com
ποΈ μκ³
λ€μ κΈμμλ λ€μκ³Ό κ°μ λ΄μ©μ λ€λ£° μμ μ λλ€:
β Tailwindλ‘ λ°μν 그리λ λ μ΄μμ λ§λ€κΈ°
β dark mode, theme μ μ©νκΈ°
β SvelteKitμ Tailwind ν΅ν©νκΈ°