Tailwind CSS 프로젝트에서 SEED를 사용하는 방법을 알아봅니다.
SEED에서 제공하는 토큰을 Tailwind CSS 3과 4 유틸리티 클래스를 통해 쉽게 사용하고, SEED React 컴포넌트의 스타일을 오버라이드할 수 있습니다.
npm install @seed-design/css @seed-design/tailwind4-theme pnpm add @seed-design/css @seed-design/tailwind4-theme yarn add @seed-design/css @seed-design/tailwind4-theme bun add @seed-design/css @seed-design/tailwind4-theme
@layer theme , base , seed-base , components , seed-components , utilities ;
@import "@seed-design/css/base.layered.css" ;
@import "tailwindcss" ;
@import "@seed-design/tailwind4-theme" ; SEED React 컴포넌트가 layered CSS 파일을 사용하도록 번들러의 module resolution 설정에 seed-layered condition을 추가하세요.
번들러별 설정 방법은 Cascade Layers 문서를 참고하세요.
Tailwind CSS 스타일시트는 theming 스크립트와 별개로 작동합니다. 아래 가이드를 참고하여 테마 설정을 진행하세요.
npm install @seed-design/css @seed-design/tailwind3-plugin pnpm add @seed-design/css @seed-design/tailwind3-plugin yarn add @seed-design/css @seed-design/tailwind3-plugin bun add @seed-design/css @seed-design/tailwind3-plugin
import "@seed-design/css/base.css" ;
import seedPlugin from "@seed-design/tailwind3-plugin" ;
/** @type {import('tailwindcss').Config} */
export default {
content: [ "./index.html" , "./src/**/*.{js,ts,jsx,tsx}" ],
theme: {
extend: {},
},
plugins: [seedPlugin],
}; Tailwind CSS 스타일시트는 theming 스크립트와 별개로 작동합니다. 아래 가이드를 참고하여 테마 설정을 진행하세요.
SEED의 모든 디자인 토큰을 Tailwind 유틸리티 클래스로 사용할 수 있습니다.
bg-bg-informative-weak
bg-palette-gray-200
border-stroke-brand-solid
border-palette-red-500
import { VStack, Text } from "@seed-design/react" ;
export default function TailwindColors () {
return (
< VStack gap = "x4" >
{ /* 텍스트 색상 */ }
< VStack gap = "x2" >
< div className = "p-x3 rounded-r2" >
< p className = "text-fg-brand t4-bold" >text-fg-brand</ p >
</ div >
< div className = "p-x3 rounded-r2" >
< p className = "text-fg-neutral t4-bold" >text-fg-neutral</ p >
</ div >
< div className = "p-x3 rounded-r2" >
< p className = "text-palette-blue-500 t4-bold" >text-palette-blue-500</ p >
</ div >
</ VStack >
{ /* 배경 색상 */ }
< VStack gap = "x2" >
< div className = "bg-bg-informative-weak p-x3 rounded-r2" >
< Text >bg-bg-informative-weak</ Text >
</ div >
< div className = "bg-palette-gray-200 p-x3 rounded-r2" >
< Text >bg-palette-gray-200</ Text >
</ div >
</ VStack >
{ /* 테두리 색상 */ }
< VStack gap = "x2" >
< div className = "border-2 border-stroke-brand-solid p-x3 rounded-r2" >
< Text >border-stroke-brand-solid</ Text >
</ div >
< div className = "border-2 border-palette-red-500 p-x3 rounded-r2" >
< Text >border-palette-red-500</ Text >
</ div >
</ VStack >
</ VStack >
);
}
screen-title t3-regular
t3-bold
t4-medium
article-body
import { VStack } from "@seed-design/react" ;
export default function TailwindTypography () {
return (
< VStack gap = "x3" >
< h1 className = "screen-title text-fg-neutral" >screen-title</ h1 >
< p className = "t3-regular text-fg-neutral" >t3-regular</ p >
< p className = "t3-bold text-fg-neutral" >t3-bold</ p >
< p className = "t4-medium text-fg-neutral" >t4-medium</ p >
< p className = "article-body text-fg-neutral" >article-body</ p >
</ VStack >
);
}
import { VStack, HStack, Text } from "@seed-design/react" ;
export default function TailwindSpacing () {
return (
< VStack gap = "x4" >
{ /* 크기 유틸리티 */ }
< HStack gap = "x3" align = "center" >
< div className = "size-x6 bg-palette-gray-400 rounded-r1" />
< Text >size-x6</ Text >
</ HStack >
< HStack gap = "x3" align = "center" >
< div className = "w-x8 h-x4 bg-palette-gray-400 rounded-r1" />
< Text >w-x8 h-x4</ Text >
</ HStack >
{ /* 패딩 유틸리티 */ }
< HStack gap = "x3" align = "center" >
< div className = "p-x2 bg-palette-gray-600 rounded-r3" >
< div className = "size-x6 bg-palette-gray-400 rounded-r1" />
</ div >
< Text >p-x2</ Text >
</ HStack >
< HStack gap = "x3" align = "center" >
< div className = "px-x4 py-x2 bg-palette-gray-600 rounded-r3" >
< div className = "size-x6 bg-palette-gray-400 rounded-r1" />
</ div >
< Text >px-x4 py-x2</ Text >
</ HStack >
{ /* 간격 유틸리티 */ }
< HStack gap = "x3" align = "center" >
< div className = "flex gap-x3 p-x2 bg-palette-gray-600 rounded-r3" >
< div className = "size-x6 bg-palette-gray-400 rounded-r1" />
< div className = "size-x6 bg-palette-gray-400 rounded-r1" />
< div className = "size-x6 bg-palette-gray-400 rounded-r1" />
</ div >
< Text >p-x2 gap-x3</ Text >
</ HStack >
</ VStack >
);
}
import { HStack, VStack, Text } from "@seed-design/react" ;
export default function TailwindBorderRadius () {
return (
< HStack gap = "x4" align = "center" >
< VStack gap = "x3" align = "center" >
< div className = "size-x10 bg-bg-neutral-solid rounded-r2" />
< Text textStyle = "t4Regular" >rounded-r2</ Text >
</ VStack >
< VStack gap = "x3" align = "center" >
< div className = "size-x10 bg-bg-neutral-solid rounded-r4" />
< Text textStyle = "t4Regular" >rounded-r4</ Text >
</ VStack >
< VStack gap = "x3" align = "center" >
< div className = "size-x10 bg-bg-neutral-solid rounded-full" />
< Text textStyle = "t4Regular" >rounded-full</ Text >
</ VStack >
</ HStack >
);
}
bg-gradient-glow-magic-[90deg]
bg-gradient-highlight-magic-[90deg] import { VStack, Text } from "@seed-design/react" ;
export default function TailwindGradient () {
return (
< VStack gap = "x4" >
< VStack gap = "x2" >
< div className = "h-x10 bg-gradient-glow-magic-[90deg] rounded-r2" />
< Text >bg-gradient-glow-magic-[90deg]</ Text >
</ VStack >
< VStack gap = "x2" >
< div className = "h-x10 bg-gradient-highlight-magic-[90deg] rounded-r2" />
< Text >bg-gradient-highlight-magic-[90deg]</ Text >
</ VStack >
</ VStack >
);
}
SEED breakpoint를 Tailwind의 sm:, md:, lg:, xl: 변형으로 쓸 수 있습니다. 이 값은 SEED 컴포넌트의 반응형 prop, @seed-design/css/breakpoints와 원천이 같습니다. 그래서 SEED를 업그레이드하면 Tailwind 변형의 전환점도 함께 바뀝니다. 값은 반응형 디자인 문서를 참고하세요.
지금은 선택해서 켜는 기능입니다. 다음 major 버전부터 기본으로 적용할 예정입니다.
@import "tailwindcss" ;
@import "@seed-design/tailwind4-theme" ;
@import "@seed-design/tailwind4-theme/breakpoints.css" ; breakpoints.css는 tailwindcss 뒤에 불러오세요.
plugins : [ seedPlugin ({ breakpoints: true })],
켜면 Tailwind 기본 breakpoint를 대체합니다. 2xl: 변형은 제공하지 않습니다.
base에는 변형이 없습니다. 접두사 없는 클래스가 base에 해당합니다.
Tailwind 설정에 SEED breakpoint 값을 직접 적어 두었다면 지우세요. 복제한 값은 SEED가 바뀔 때 따라 바뀌지 않습니다.
breakpoint를 추가하려면 Tailwind CSS 4에서는 @theme에 --breakpoint-*를, Tailwind CSS 3에서는 theme.extend.screens를 쓰세요. Tailwind CSS 4에서는 변형이 값 순서로 정렬되므로 SEED와 같이 px 단위를 쓰세요.
Tailwind CSS를 사용하지 않아도 SEED 토큰을 쉽게 사용할 수 있습니다.
레이아웃 컴포넌트에서 SEED 토큰을 사용하는 방법을 알아봅니다.
fade-mask, glow-magic, glow-magic-pressed, highlight-magic, highlight-magic-pressed, shimmer-magic, shimmer-neutral을 사용할 수 있습니다.
방향: bg-shimmer-neutral-to-r 또는 bg-gradient-shimmer-neutral-to-r. t, tr, r, br, b, bl, l, tl을 지원합니다.
각도: bg-gradient-glow-magic-[120deg]. 정수·소수·음수 모두 대괄호 문법을 사용합니다.
임의 각도: bg-gradient-fade-mask-[45.5deg], bg-gradient-glow-magic-[-45deg], bg-gradient-highlight-magic-[0.25turn].
@seed-design/css/base.css를 불러오면 --seed-gradient-*의 light/dark stop을 사용합니다. data-seed-color-mode="light-only" / "dark-only"를 적용한 영역에서도 해당 모드의 stop을 따릅니다.
fade-mask는 양쪽 모드에서 동일한 16개 alpha stop을 사용합니다. 이 유틸리티는 배경이며 마스크를 자동으로 적용하지 않습니다.