tw classed
@tw-classed
TW 분류 프로젝트의 Monorepo. 코어 및 반응 패키지로 구성됩니다.
전체 문서
React 패키지는 핵심 패키지 주변의 래퍼로, 분류 된 구성 요소를 쉽게 만들 수있는 방법을 제공합니다. React Docs를 참조하십시오
// Button.tsx
import { classed } from "@tw-classed/react" ;
const Button = classed . button ( "px-4 py-2" , {
variants : {
color : {
primary : "bg-blue-500 text-white" ,
secondary : "bg-gray-500 text-white" ,
} ,
} ,
} ) ;
// In your App
const App = ( ) => {
return (
< >
< Button color = "primary" > Primary </ Button >
< Button color = "secondary" > Secondary </ Button >
</ >
) ;
} ; 핵심 패키지는 자신의 분류 구성 요소를 구축하는 데 도움이되는 기능 세트를 제공하는 라이브러리입니다.
핵심 문서를 참조하십시오
import { classed } from "@tw-classed/core" ;
const button = classed ( "px-4 py-2" , {
variants : {
color : {
primary : "bg-blue-500 text-white" ,
secondary : "bg-gray-500 text-white" ,
} ,
} ,
} ) ;
// In your template
const Button = document . createElement ( "button" ) ;
Button . className = button ( { color : "primary" } ) ;
// Or with a framework (Like lit-html)
const Button = ( ) => html ` < button class =" ${ button ( { color : "primary" } ) } " /> ` ; MIT