tw classed
@tw-classed
TWクラスプロジェクトのモノレポ。コアパッケージと反応パッケージで構成されています。
完全なドキュメント
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