ํฐ์คํ ๋ฆฌ ๋ทฐ
์นดํ
๊ณ ๋ฆฌ ์์
๐งฉ ์์ด์ฝ๊ณผ ํ ์คํธ๊ฐ ํจ๊ป ๋ค์ด๊ฐ ์ปค์คํฐ๋ง์ด์ง ๊ฐ๋ฅํ ๋ฒํผ ๋ง๋ค๊ธฐ (Tailwind + React)
B_log 2025. 5. 18. 14:20๋ฐ์ํ
๐งฉ ์์ด์ฝ๊ณผ ํ ์คํธ๊ฐ ํจ๊ป ๋ค์ด๊ฐ ์ปค์คํฐ๋ง์ด์ง ๊ฐ๋ฅํ ๋ฒํผ ๋ง๋ค๊ธฐ (Tailwind + React)
์ด๋ฒ ๊ธ์์๋ Tailwind CSS๋ฅผ ๊ธฐ๋ฐ์ผ๋ก,
์์ด์ฝ๊ณผ ํ
์คํธ๊ฐ ํจ๊ป ํ์๋๊ณ , ์์/ํฐํธ/๋ชจ์๋ฆฌ ๋ฑ์ ์์ ๋กญ๊ฒ ์กฐ์ ํ ์ ์๋ ๋ฒํผ ์ปดํฌ๋ํธ๋ฅผ ๋ง๋ค์ด๋ณด๊ฒ ์ต๋๋ค.
๐ ๋ชฉํ ๋์์ธ
- ์์ด์ฝ + ํ ์คํธ ์ํ ์ ๋ ฌ
- ๋ฐฐ๊ฒฝ์, ํ ์คํธ์, border-radius ๋ฑ ์ปค์คํฐ๋ง์ด์ง ๊ฐ๋ฅ
- ํด๋ฆญ ์ด๋ฒคํธ ํธ๋ค๋ง ๊ฐ๋ฅ
- ๋ฐ๋ณต ์ฌ์ฉ์ด ์ฌ์ด ์ฌ์ฌ์ฉํ ๊ตฌ์กฐ
๐งฑ ButtonPresets.js (์คํ์ผ ํ๋ฆฌ์ )
// src/styles/buttonPresets.js
export const buttonPresets = {
default: {
background: 'bg-gray-100',
textColor: 'text-black',
font: 'text-sm font-semibold',
padding: 'px-4 py-2',
radius: 'rounded-xl',
iconSize: 'w-5 h-5',
gap: 'gap-2',
},
outline: {
background: 'bg-white border border-gray-300',
textColor: 'text-gray-700',
font: 'text-sm font-medium',
padding: 'px-3 py-2',
radius: 'rounded-md',
iconSize: 'w-4 h-4',
gap: 'gap-1.5',
},
}
๐งฉ IconButton.jsx (์ปดํฌ๋ํธ ๊ตฌํ)
import React from 'react'
import { buttonPresets } from '../styles/buttonPresets'
function IconButton({
icon,
label,
onClick,
variant = 'default',
customClass = '',
}) {
const style = buttonPresets[variant] ?? buttonPresets.default
return (
<button
onClick={onClick}
className={`
inline-flex items-center ${style.gap}
${style.padding} ${style.background} ${style.textColor} ${style.font} ${style.radius}
hover:opacity-90 active:scale-95 transition ${customClass}
`}
>
<span className={style.iconSize}>{icon}</span>
<span>{label}</span>
</button>
)
}
export default IconButton
๐งช ์ฌ์ฉ ์์ (App.jsx)
import { Pencil, Share2 } from 'lucide-react'
import IconButton from './components/IconButton'
function App() {
return (
<div className="flex gap-4 p-6 bg-gray-50">
<IconButton
icon={<Pencil />}
label="์์ ํ๊ธฐ"
onClick={() => alert('์์ ํด๋ฆญ')}
variant="default"
/>
<IconButton
icon={<Share2 />}
label="๊ณต์ ํ๊ธฐ"
onClick={() => alert('๊ณต์ ํด๋ฆญ')}
variant="default"
/>
</div>
)
}
์์ด์ฝ์
lucide-react
๋๋@heroicons/react
๋ฑ ์ฌ์ฉ ๊ฐ๋ฅ
์ค์น:npm install lucide-react
๐ก ํ์ฅ ์์ด๋์ด
- ๋ฒํผ์
disabled
์์ฑ ์ถ๊ฐ iconPosition="left" | "right"
์ผ๋ก ์์ด์ฝ ์์น ๋ฐ๊พธ๊ธฐ- ์์ preset์
primary
,danger
,success
๋ฑ์ผ๋ก ๋ถ๋ฆฌ - ๋ฒํผ ํฌ๊ธฐ preset (
sm
,md
,lg
) ๋์
โ ๋ง๋ฌด๋ฆฌ
์ด์ฒ๋ผ ๋ฒํผ์ ์์ด์ฝ + ํ
์คํธ ์กฐํฉ์ผ๋ก ๋ง๋ค๊ณ ,
Tailwind ์คํ์ผ์ preset์ผ๋ก ๊ด๋ฆฌํ๋ฉด ์ฌ์ฌ์ฉ์ฑ๊ณผ ์ ์ง๋ณด์๊ฐ ํจ์ฌ ์ฌ์ด ๊ตฌ์กฐ๊ฐ ๋ฉ๋๋ค.
๐ ๋ค์ ๊ธ ์๊ณ
๋ค์ ๊ธ์์๋ ๋ฒํผ ๊ทธ๋ฃน ๊ตฌ์ฑ, ๋๋ ๋ก๋ฉ ์ํ๊ฐ ์๋ ๋ฒํผ (๋ก๋ฉ ์คํผ๋ ํฌํจ) ์ปดํฌ๋ํธ๋ฅผ ์๊ฐํ ์์ ์
๋๋ค.
ํ์ํ ์์๊ฐ ์๋ค๋ฉด ๋๊ธ๋ก ๋จ๊ฒจ์ฃผ์ธ์. ๊ฐ์ฌํฉ๋๋ค ๐
๋ฐ์ํ
๋๊ธ
๋ฐ์ํ
๊ณต์ง์ฌํญ
์ต๊ทผ์ ์ฌ๋ผ์จ ๊ธ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
- Total
- Today
- Yesterday
๋งํฌ
TAG
- ํ ํ๋ก์ ํธ#๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ#Python
- ๋ณ๋ ๋์ดํธ#BOJ#ํ์๋ฒ#Python
- PassingCars#Codility#Python
- Swift#Tuples#Range
- Triangle#Sorting#Codility#Python
- N์ผ๋ก ํํ#DP#Programmers#Python
- ํ์ด์ฌ์๊ณ ๋ฆฌ์ฆ์ธํฐ๋ทฐ#4์ฅ
- ๋ฐฑ์ค ์๊ณ ๋ฆฌ์ฆ#BackTracking
- ๋ฐฐ์ดํฉ์น๊ธฐ#๋ถํ ์ ๋ณต#BOJ#Python
- NumberofDiscIntersections#Codility#Sort#Python
- Distinct#Codility#Python
- ๋ ์ง ๊ณ์ฐ#BOJ#์์ ํ์#Python
- ๋ฆฌ๋ชจ์ปจ#์์ ํ์#BOJ#Python
- ๊ณต์ ๊ธฐ ์ค์น#BOJ#์ด๋ถํ์#Python
- ๋์ ์๋ฅด๊ธฐ#์ด๋ถํ์#BOJ#Python
- django#slicing
- ํ ๋งํ #๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ#Python
- ์ํธ์ฝ๋#dp#BOJ#Python
- ์ข ์ด์๋ฅด๊ธฐ#๋ถํ ์ ๋ณต#BOJ#Python
- ๋ฏธ๋ก ํ์#๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ#Python
- django
- ์์ด์ฌ์ดํด#BOJ#Python
- ์ฟผ๋ํธ๋ฆฌ#BOJ#๋ถํ ์ ๋ณต#Python
- ๋๋ฌด์๋ฅด๊ธฐ#BOJ#์ด๋ถํ์#Python
- ์ฌ์๊ฐ์#๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ#Python
- Brackets#Stacks and Queues#Codility#Python
- ๋ฐ๋ณต์์ด#๋ฐฑ์ค์๊ณ ๋ฆฌ์ฆ#Python
- ํฐํ๋น์น#๋ฆฌ์ฝ#xbox#controller
- filter#isalnum#lower
- API#lazy#
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
๊ธ ๋ณด๊ดํจ