ํฐ์คํ ๋ฆฌ ๋ทฐ
๐จ React + Vite์ Tailwind CSS ์ ์ฉํ๋ ๋ฐฉ๋ฒ
์๋
ํ์ธ์! ์ง๋ ๊ธ์์ Tailwind CSS๊ฐ ์ ์ข์์ง์ ๋ํด ์์๋ดค์ฃ ?
์ด๋ฒ ๊ธ์์๋ ์ค์ ๋ก React + Vite ํ๋ก์ ํธ์ Tailwind CSS๋ฅผ ์ค์นํ๊ณ ์ ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋จ๊ณ๋ณ๋ก ์ ๋ฆฌํด๋๋ฆด๊ฒ์.
โ 1๋จ๊ณ: ํ๋ก์ ํธ ์ค๋น
๋จผ์ Vite + React ํ๋ก์ ํธ๊ฐ ์ค๋น๋์ด ์์ด์ผ ํฉ๋๋ค.
์์ง ์์ฑํ์ง ์์ผ์
จ๋ค๋ฉด ์๋ ๋ช
๋ น์ด๋ก ๋จผ์ ํ๋ก์ ํธ๋ฅผ ๋ง๋ค๊ณ ์์ํ์ธ์.
npm create vite@latest my-app -- --template react
cd my-app
npm install
โ 2๋จ๊ณ: Tailwind CSS ์ค์น
Tailwind CSS ๊ด๋ จ ํจํค์ง๋ฅผ ์ค์นํฉ๋๋ค.
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
- ์ ๋ช
๋ น์ด๋
tailwind.config.js
์postcss.config.js
ํ์ผ์ ์์ฑํฉ๋๋ค.
โ 3๋จ๊ณ: Tailwind ์ค์ ์์
tailwind.config.js
ํ์ผ์ ์ด๊ณ content
ํญ๋ชฉ์ ์๋์ฒ๋ผ ์์ ํฉ๋๋ค.
// tailwind.config.js
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
์ด ์ค์ ์ Tailwind๊ฐ ์ฌ์ฉํ ํด๋์ค๋ค์ ์๋์ผ๋ก ๊ฐ์งํ ์ ์๊ฒ ํด์ค๋๋ค.
โ 4๋จ๊ณ: ์คํ์ผ ํ์ผ ์์ฑ ๋ฐ ์ฐ๊ฒฐ
src/index.css
ํ์ผ์ ๋ง๋ค๊ณ ์๋์ ๊ฐ์ด ์์ฑํฉ๋๋ค.
/* src/index.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
๊ทธ ๋ค์, src/main.jsx
(๋๋ main.tsx)์ ์ด CSS ํ์ผ์ import ํฉ๋๋ค.
// src/main.jsx
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>
)
โ 5๋จ๊ณ: ์ ๋๋ก ์ ์ฉ๋๋์ง ํ์ธ
App.jsx
์ Tailwind ํด๋์ค๋ฅผ ์ถ๊ฐํด๋ด
๋๋ค.
// src/App.jsx
function App() {
return (
<div className="min-h-screen flex items-center justify-center bg-gradient-to-r from-blue-500 to-purple-600 text-white text-3xl font-bold">
Hello Tailwind CSS!
</div>
)
}
export default App
โ 6๋จ๊ณ: ๊ฐ๋ฐ ์๋ฒ ์คํ
์ด์ ๊ฐ๋ฐ ์๋ฒ๋ฅผ ๋ค์ ์คํํด๋ด ๋๋ค.
npm run dev
๋ธ๋ผ์ฐ์ ์ Tailwind ์คํ์ผ์ด ์ ์ฉ๋ ํ๋ฉด์ด ๋ฌ๋ค๋ฉด ์ฑ๊ณต์ ๋๋ค!
๐ฏ ๋ง๋ฌด๋ฆฌ
์ด์ ์ฌ๋ฌ๋ถ์ React + Vite ํ๋ก์ ํธ์ Tailwind CSS๊ฐ ์ฑ๊ณต์ ์ผ๋ก ์ ์ฉ๋์์ต๋๋ค!
์์ผ๋ก๋ ๋ณต์กํ CSS ํ์ผ ์์ด, HTML ํด๋์ค๋ง์ผ๋ก๋ ๋ฉ์ง UI๋ฅผ ๋น ๋ฅด๊ฒ ๋ง๋ค ์ ์์ด์.
๐ ๋ค์ ๊ธ ์๊ณ
๋ค์ ํฌ์คํ
์์๋ Tailwind CSS๋ก ์์ฃผ ์ฌ์ฉํ๋ UI ๊ตฌ์ฑ ์์(๋ฒํผ, ์นด๋, ํผ ๋ฑ)๋ฅผ ๋น ๋ฅด๊ฒ ๋ง๋๋ ๋ฐฉ๋ฒ์ ์๊ฐํด๋๋ฆด๊ฒ์.
์ง๊ธ๊น์ง ๋ฐ๋ผ์ค์๋๋ผ ๊ณ ์ ๋ง์ผ์
จ๊ณ , ๊ถ๊ธํ ์ ์ ๋๊ธ๋ก ๋จ๊ฒจ์ฃผ์ธ์! ๐
- Total
- Today
- Yesterday
- ์ฟผ๋ํธ๋ฆฌ#BOJ#๋ถํ ์ ๋ณต#Python
- ๋์ ์๋ฅด๊ธฐ#์ด๋ถํ์#BOJ#Python
- Triangle#Sorting#Codility#Python
- ๋ฐฑ์ค ์๊ณ ๋ฆฌ์ฆ#BackTracking
- ๋ฐฐ์ดํฉ์น๊ธฐ#๋ถํ ์ ๋ณต#BOJ#Python
- Brackets#Stacks and Queues#Codility#Python
- ๋ฐ๋ณต์์ด#๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ#Python
- ๋ฏธ๋ก ํ์#๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ#Python
- django#slicing
- API#lazy#
- PassingCars#Codility#Python
- ๋ ์ง ๊ณ์ฐ#BOJ#์์ ํ์#Python
- ๊ณต์ ๊ธฐ ์ค์น#BOJ#์ด๋ถํ์#Python
- ์ข ์ด์๋ฅด๊ธฐ#๋ถํ ์ ๋ณต#BOJ#Python
- django
- ์ฌ์๊ฐ์#๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ#Python
- Swift#Tuples#Range
- ๋๋ฌด์๋ฅด๊ธฐ#BOJ#์ด๋ถํ์#Python
- NumberofDiscIntersections#Codility#Sort#Python
- filter#isalnum#lower
- ํฐํ๋น์น#๋ฆฌ์ฝ#xbox#controller
- Distinct#Codility#Python
- ์์ด์ฌ์ดํด#BOJ#Python
- ๋ณ๋ ๋์ดํธ#BOJ#ํ์๋ฒ#Python
- ํ ํ๋ก์ ํธ#๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ#Python
- ๋ฆฌ๋ชจ์ปจ#์์ ํ์#BOJ#Python
- ์ํธ์ฝ๋#dp#BOJ#Python
- ํ ๋งํ #๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ#Python
- ํ์ด์ฌ์๊ณ ๋ฆฌ์ฆ์ธํฐ๋ทฐ#4์ฅ
- N์ผ๋ก ํํ#DP#Programmers#Python
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |