بنقرة واحدة
shadcn-ui
Shadcn UI component library - beautifully designed React components built with Radix UI and Tailwind CSS
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Shadcn UI component library - beautifully designed React components built with Radix UI and Tailwind CSS
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | shadcn-ui |
| description | Shadcn UI component library - beautifully designed React components built with Radix UI and Tailwind CSS |
Expert assistance with shadcn/ui - a collection of beautifully-designed, accessible components built with TypeScript, Tailwind CSS, and Radix UI primitives. Supports Next.js, Vite, Remix, Astro, Laravel, and more.
This skill should be triggered when:
# Initialize shadcn/ui in a project
npx shadcn@latest init
# Add specific components
npx shadcn@latest add button
npx shadcn@latest add dialog form input
# Add all components
npx shadcn@latest add
import { Button } from "@/components/ui/button"
export default function Example() {
return (
<div className="flex gap-2">
<Button>Default</Button>
<Button variant="destructive">Delete</Button>
<Button variant="outline">Cancel</Button>
<Button variant="ghost">Ghost</Button>
<Button variant="link">Link</Button>
<Button size="sm">Small</Button>
<Button size="lg">Large</Button>
</div>
)
}
import { zodResolver } from "@hookform/resolvers/zod"
import { useForm } from "react-hook-form"
import { z } from "zod"
import { Button } from "@/components/ui/button"
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form"
import { Input } from "@/components/ui/input"
const formSchema = z.object({
username: z.string().min(2).max(50),
email: z.string().email(),
})
export default function ProfileForm() {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
})
function onSubmit(values: z.infer<typeof formSchema>) {
console.log(values)
}
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
<FormField
control={form.control}
name="username"
render={({ field }) => (
<FormItem>
<FormLabel>Username</FormLabel>
<FormControl>
<Input placeholder="johndoe" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<Button type="submit">Submit</Button>
</form>
</Form>
)
}
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
export default function Example() {
return (
<Dialog>
<DialogTrigger asChild>
<Button>Open Dialog</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Are you sure?</DialogTitle>
<DialogDescription>
This action cannot be undone.
</DialogDescription>
</DialogHeader>
</DialogContent>
</Dialog>
)
}
import { useToast } from "@/hooks/use-toast"
import { Button } from "@/components/ui/button"
export default function Example() {
const { toast } = useToast()
return (
<Button
onClick={() => {
toast({
title: "Success",
description: "Your changes have been saved.",
})
}}
>
Show Toast
</Button>
)
}
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table"
const invoices = [
{ id: "INV001", status: "Paid", amount: "$250.00" },
{ id: "INV002", status: "Pending", amount: "$150.00" },
]
export default function DataTable() {
return (
<Table>
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead>Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices.map((invoice) => (
<TableRow key={invoice.id}>
<TableCell>{invoice.id}</TableCell>
<TableCell>{invoice.status}</TableCell>
<TableCell>{invoice.amount}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
)
}
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
export default function Example() {
return (
<Select>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="Select a fruit" />
</SelectTrigger>
<SelectContent>
<SelectItem value="apple">Apple</SelectItem>
<SelectItem value="banana">Banana</SelectItem>
<SelectItem value="orange">Orange</SelectItem>
</SelectContent>
</Select>
)
}
// app/providers.tsx
"use client"
import { ThemeProvider } from "next-themes"
export function Providers({ children }: { children: React.ReactNode }) {
return (
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
{children}
</ThemeProvider>
)
}
// Usage in component
import { useTheme } from "next-themes"
import { Button } from "@/components/ui/button"
export function ThemeToggle() {
const { setTheme } = useTheme()
return (
<Button onClick={() => setTheme("dark")}>Dark Mode</Button>
)
}
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
export default function Example() {
return (
<Card>
<CardHeader>
<CardTitle>Card Title</CardTitle>
<CardDescription>Card description goes here</CardDescription>
</CardHeader>
<CardContent>
<p>Card content</p>
</CardContent>
</Card>
)
}
import { Check, ChevronsUpDown } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem } from "@/components/ui/command"
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"
const frameworks = [
{ value: "next", label: "Next.js" },
{ value: "react", label: "React" },
{ value: "vue", label: "Vue" },
]
export default function Combobox() {
const [open, setOpen] = React.useState(false)
const [value, setValue] = React.useState("")
return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<Button variant="outline" className="w-[200px] justify-between">
{value || "Select framework..."}
<ChevronsUpDown className="ml-2 h-4 w-4" />
</Button>
</PopoverTrigger>
<PopoverContent className="w-[200px] p-0">
<Command>
<CommandInput placeholder="Search..." />
<CommandEmpty>No framework found.</CommandEmpty>
<CommandGroup>
{frameworks.map((framework) => (
<CommandItem
key={framework.value}
onSelect={() => {
setValue(framework.value)
setOpen(false)
}}
>
<Check className={value === framework.value ? "mr-2 h-4 w-4" : "mr-2 h-4 w-4 opacity-0"} />
{framework.label}
</CommandItem>
))}
</CommandGroup>
</Command>
</PopoverContent>
</Popover>
)
}
This skill includes comprehensive documentation in references/:
Complete overview of shadcn/ui with links to all components and features. Covers:
Additional documentation mirroring llms.md content with organized sections for:
Use view references/llms.md for quick access to component links and documentation structure.
npx shadcn@latest initreferences/llms.md to explore available components by categorynpx shadcn@latest add form inputcomponents.json to configure paths and stylingUnlike traditional libraries, shadcn/ui components are added to your project via CLI:
components/ui directoryadd commandCentral configuration file that controls:
cn() utility for conditional classesclass-variance-authorityAll components built on Radix UI primitives ensure:
Works with any React framework through appropriate setup:
"use server"
async function onSubmit(formData: FormData) {
const data = {
name: formData.get("name"),
email: formData.get("email"),
}
// Process data
return { success: true }
}
Use Dialog for desktop, Sheet for mobile:
import { useMediaQuery } from "@/hooks/use-media-query"
import { Dialog, DialogContent } from "@/components/ui/dialog"
import { Sheet, SheetContent } from "@/components/ui/sheet"
const isDesktop = useMediaQuery("(min-width: 768px)")
if (isDesktop) {
return <Dialog>...</Dialog>
}
return <Sheet>...</Sheet>
const [open, setOpen] = useState(false)
const [value, setValue] = useState("")
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent>...</DialogContent>
</Dialog>
Create and publish your own component collections:
Ensure your tsconfig.json has the correct path aliases:
{
"compilerOptions": {
"paths": {
"@/*": ["./*"]
}
}
}
tailwind.config.jscn() utility is in lib/utils.tsRun npx shadcn@latest add <component-name> to install missing components