Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build React UIs using shadcn/ui components with Tailwind CSS, Radix primitives, and proper accessibility patterns.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/ui-components.md
1# shadcn/ui - UI Components Reference23## Button45```bash6npx shadcn@latest add button7```89```tsx10import { Button } from "@/components/ui/button"11import { Loader2 } from "lucide-react"1213// Variants: default | destructive | outline | secondary | ghost | link14// Sizes: default | sm | lg | icon15<Button variant="default">Default</Button>16<Button variant="destructive">Delete</Button>17<Button variant="outline">Outline</Button>18<Button size="sm">Small</Button>19<Button size="icon"><Icon className="h-4 w-4" /></Button>2021// Loading state22<Button disabled>23<Loader2 className="mr-2 h-4 w-4 animate-spin" />24Please wait25</Button>26```2728## Input & Label2930```bash31npx shadcn@latest add input label32```3334```tsx35import { Input } from "@/components/ui/input"36import { Label } from "@/components/ui/label"3738// Basic input39<Input type="email" placeholder="Email" />4041// Input with label42<div className="grid w-full max-w-sm items-center gap-1.5">43<Label htmlFor="email">Email</Label>44<Input type="email" id="email" placeholder="Email" />45</div>4647// Input with button48<div className="flex w-full max-w-sm items-center gap-2">49<Input type="email" placeholder="Email" />50<Button type="submit" variant="outline">Subscribe</Button>51</div>52```5354## Card5556```bash57npx shadcn@latest add card58```5960```tsx61import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"6263<Card>64<CardHeader>65<CardTitle>Card Title</CardTitle>66<CardDescription>Card Description</CardDescription>67</CardHeader>68<CardContent>69<p>Card Content</p>70</CardContent>71<CardFooter className="flex justify-between">72<Button variant="outline">Cancel</Button>73<Button>Deploy</Button>74</CardFooter>75</Card>76```7778## Dialog (Modal)7980```bash81npx shadcn@latest add dialog82```8384```tsx85import {86Dialog, DialogContent, DialogDescription, DialogFooter,87DialogHeader, DialogTitle, DialogTrigger,88} from "@/components/ui/dialog"8990<Dialog>91<DialogTrigger asChild>92<Button variant="outline">Open Dialog</Button>93</DialogTrigger>94<DialogContent className="sm:max-w-[425px]">95<DialogHeader>96<DialogTitle>Edit profile</DialogTitle>97<DialogDescription>Make changes to your profile here.</DialogDescription>98</DialogHeader>99<div className="grid gap-4 py-4">100<div className="grid grid-cols-4 items-center gap-4">101<Label htmlFor="name" className="text-right">Name</Label>102<Input id="name" className="col-span-3" />103</div>104</div>105<DialogFooter>106<Button type="submit">Save changes</Button>107</DialogFooter>108</DialogContent>109</Dialog>110```111112## Sheet (Slide-over)113114```bash115npx shadcn@latest add sheet116```117118```tsx119import {120Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger,121} from "@/components/ui/sheet"122123// sides: top | right | bottom | left (default: right)124<Sheet>125<SheetTrigger asChild>126<Button variant="outline">Open Sheet</Button>127</SheetTrigger>128<SheetContent side="right">129<SheetHeader>130<SheetTitle>Settings</SheetTitle>131<SheetDescription>Configure your application settings.</SheetDescription>132</SheetHeader>133{/* Sheet content */}134</SheetContent>135</Sheet>136```137138## Select (Dropdown)139140```bash141npx shadcn@latest add select142```143144```tsx145import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"146147<Select>148<SelectTrigger className="w-[180px]">149<SelectValue placeholder="Select a fruit" />150</SelectTrigger>151<SelectContent>152<SelectItem value="apple">Apple</SelectItem>153<SelectItem value="banana">Banana</SelectItem>154<SelectItem value="orange">Orange</SelectItem>155</SelectContent>156</Select>157```158159## Toast Notifications160161```bash162npx shadcn@latest add toast163```164165Add `<Toaster />` to root layout:166167```tsx168// app/layout.tsx169import { Toaster } from "@/components/ui/toaster"170171export default function RootLayout({ children }) {172return (173<html lang="en">174<body>175{children}176<Toaster />177</body>178</html>179)180}181```182183Using toast:184185```tsx186import { useToast } from "@/components/ui/use-toast"187188export function ToastDemo() {189const { toast } = useToast()190191return (192<Button onClick={() => toast({ title: "Success", description: "Changes saved." })}>193Show Toast194</Button>195)196}197198// Variants199toast({ title: "Success", description: "Changes have been saved." })200toast({ variant: "destructive", title: "Error", description: "Something went wrong." })201toast({ title: "Undo?", action: <ToastAction altText="Undo">Undo</ToastAction> })202```203204## Table205206```bash207npx shadcn@latest add table208```209210```tsx211import {212Table, TableBody, TableCaption, TableCell,213TableHead, TableHeader, TableRow,214} from "@/components/ui/table"215216const invoices = [217{ invoice: "INV001", status: "Paid", method: "Credit Card", amount: "$250.00" },218{ invoice: "INV002", status: "Pending", method: "PayPal", amount: "$150.00" },219]220221<Table>222<TableCaption>A list of your recent invoices.</TableCaption>223<TableHeader>224<TableRow>225<TableHead>Invoice</TableHead>226<TableHead>Status</TableHead>227<TableHead>Method</TableHead>228<TableHead className="text-right">Amount</TableHead>229</TableRow>230</TableHeader>231<TableBody>232{invoices.map((invoice) => (233<TableRow key={invoice.invoice}>234<TableCell className="font-medium">{invoice.invoice}</TableCell>235<TableCell>{invoice.status}</TableCell>236<TableCell>{invoice.method}</TableCell>237<TableCell className="text-right">{invoice.amount}</TableCell>238</TableRow>239))}240</TableBody>241</Table>242```243244## Menubar & Navigation245246```bash247npx shadcn@latest add menubar248```249250```tsx251import {252Menubar, MenubarContent, MenubarItem, MenubarMenu,253MenubarSeparator, MenubarShortcut, MenubarSub,254MenubarSubContent, MenubarSubTrigger, MenubarTrigger,255} from "@/components/ui/menubar"256257<Menubar>258<MenubarMenu>259<MenubarTrigger>File</MenubarTrigger>260<MenubarContent>261<MenubarItem>New Tab <MenubarShortcut>⌘T</MenubarShortcut></MenubarItem>262<MenubarItem>New Window <MenubarShortcut>⌘N</MenubarShortcut></MenubarItem>263<MenubarSeparator />264<MenubarItem>Print</MenubarItem>265</MenubarContent>266</MenubarMenu>267<MenubarMenu>268<MenubarTrigger>Edit</MenubarTrigger>269<MenubarContent>270<MenubarItem>Undo <MenubarShortcut>⌘Z</MenubarShortcut></MenubarItem>271<MenubarSeparator />272<MenubarSub>273<MenubarSubTrigger>Find</MenubarSubTrigger>274<MenubarSubContent>275<MenubarItem>Search the web</MenubarItem>276<MenubarItem>Find...</MenubarItem>277</MenubarSubContent>278</MenubarSub>279</MenubarContent>280</MenubarMenu>281</Menubar>282```283