Loading...
Loading...
Best practices for working with shadcn/ui components, imports, theming, and forms. Use when building UI with shadcn, adding components, configuring theming, or creating forms.
npx skill4agent add moderndegree/agent-skills shadcn-best-practices@/components/ui/{component-name}cn()migrate radixmigrate rtlcn()import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { cn } from "@/lib/utils"
function MyComponent({ className }) {
return (
<Button className={cn("base-class", className)}>
<Input placeholder="Enter email" />
</Button>
)
}// Using relative paths
import { Button } from "../../components/ui/button"
// Hardcoding colors
<Button className="bg-blue-500 text-white" />
// Building table manually
data.map(item => <tr><td>{item.name}</td></tr>)
// Assuming Radix - wrong for Base UI projects
import * as DialogPrimitive from "@radix-ui/react-dialog"// Check components.json to determine which library the project uses
// Look for "style" field:
// - "base-*" styles use @base-ui/react
// - Other styles use @radix-ui/react-* or radix-ui
// Example: reading the config
// import fs from "fs"
// const config = JSON.parse(fs.readFileSync("components.json", "utf-8"))
// config.style === "base-vega" // true = Base UI, false = Radix
// The API is identical regardless of library
import { Dialog, DialogContent } from "@/components/ui/dialog"
// Works the same for both Radix and Base UI projects