tw classed
@tw-classed
Monorepo des TW Classed Project. Besteht aus Kern- und Reaktionspaketen.
Vollständige Dokumentation
Das React -Paket ist ein Wrapper um das Kernpaket, das eine einfache Möglichkeit bietet, klassische Komponenten zu erstellen. Siehe die React -Dokumente
// 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 >
</ >
) ;
} ; Das Kernpaket ist eine Bibliothek, die eine Reihe von Funktionen bietet, mit denen Sie Ihre eigenen klassischen Komponenten erstellen können.
Siehe die Kerndokumente
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