# shadcn/ui Component Reference Quick reference for the 40+ pre-installed shadcn/ui components. Documentation: https://ui.shadcn.com/docs/components ## Most Used for Landing Pages | Component | Use Case | Example | |-----------|----------|---------| | `Button` | CTAs, actions | Hero buttons, form submits | | `Badge` | Labels, status | "New", "Popular", "Beta" | | `Card` | Content containers | Feature cards, pricing tiers | | `Accordion` | Collapsible content | FAQ sections | | `Dialog` | Modals | Video players, signup forms | | `NavigationMenu` | Header navigation | Main nav with dropdowns | | `Tabs` | Tabbed content | Feature showcases | | `Carousel` | Sliding content | Testimonials, galleries | ## Full Component List ### Layout & Navigation - `Accordion` — Collapsible sections - `Breadcrumb` — Navigation trail - `Carousel` — Sliding content - `Collapsible` — Expand/collapse - `NavigationMenu` — Header nav with dropdowns - `Pagination` — Page navigation - `Resizable` — Resizable panels - `Scroll-Area` — Custom scrollbars - `Separator` — Visual divider - `Sheet` — Slide-out panels - `Sidebar` — App sidebars - `Tabs` — Tabbed content ### Data Display - `Avatar` — User images - `Badge` — Labels and status - `Card` — Content container - `HoverCard` — Hover popups - `Table` — Data tables ### Forms - `Button` — Actions - `Checkbox` — Multi-select - `Combobox` — Searchable select - `DatePicker` — Date selection - `Form` — Form wrapper with validation - `Input` — Text input - `InputOTP` — One-time password - `Label` — Form labels - `RadioGroup` — Single select - `Select` — Dropdown select - `Slider` — Range selection - `Switch` — Toggle - `Textarea` — Multi-line input - `Toggle` — Toggle button - `ToggleGroup` — Button group ### Feedback - `Alert` — Info messages - `AlertDialog` — Confirmation dialogs - `Dialog` — Modal windows - `Drawer` — Bottom sheets - `Popover` — Popup content - `Progress` — Loading bars - `Skeleton` — Loading placeholders - `Sonner` — Toast notifications - `Toast` — Notifications - `Tooltip` — Hover hints ### Utilities - `AspectRatio` — Maintain ratios - `Calendar` — Date display - `Chart` — Data visualization - `Command` — Command palette - `ContextMenu` — Right-click menus - `DropdownMenu` — Dropdown menus - `Menubar` — App menubars --- ## Code Examples ### Hero with Badge and Buttons ```tsx import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" function Hero() { return ( Now in beta Your headline here Subheadline with more details about your product. Get Started Learn More ) } ``` ### Feature Cards ```tsx import { Card, CardHeader, CardTitle, CardDescription } from "@/components/ui/card" import { Zap, Shield, Globe } from "lucide-react" const features = [ { icon: Zap, title: "Fast", description: "Lightning quick performance" }, { icon: Shield, title: "Secure", description: "Enterprise-grade security" }, { icon: Globe, title: "Global", description: "CDN in 200+ locations" }, ] function Features() { return ( {features.map((f) => ( {f.title} {f.description} ))} ) } ``` ### Pricing Table ```tsx import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" import { Check } from "lucide-react" const plans = [ { name: "Free", price: 0, features: ["5 projects", "Basic support"] }, { name: "Pro", price: 19, features: ["Unlimited projects", "Priority support", "API access"], popular: true }, { name: "Team", price: 49, features: ["Everything in Pro", "Team features", "SSO"] }, ] function Pricing() { return ( {plans.map((plan) => ( {plan.popular && Most Popular} {plan.name} ${plan.price} /month {plan.features.map((f) => ( {f} ))} Get Started ))} ) } ``` ### FAQ Accordion ```tsx import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/components/ui/accordion" const faqs = [ { q: "How does it work?", a: "Our platform uses AI to..." }, { q: "Is there a free trial?", a: "Yes, you get 14 days free..." }, { q: "Can I cancel anytime?", a: "Absolutely, no questions asked..." }, ] function FAQ() { return ( Frequently Asked Questions {faqs.map((faq, i) => ( {faq.q} {faq.a} ))} ) } ``` ### Mobile Navigation with Sheet ```tsx import { Button } from "@/components/ui/button" import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet" import { Menu } from "lucide-react" function MobileNav() { return ( Features Pricing FAQ Get Started ) } ``` ### Video Modal with Dialog ```tsx import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog" import { Button } from "@/components/ui/button" import { Play } from "lucide-react" function VideoModal() { return ( Watch Demo ) } ``` --- ## Styling Tips ### Customizing Colors shadcn uses CSS variables. Override in your globals.css: ```css :root { --primary: 220 90% 56%; --primary-foreground: 0 0% 100%; --accent: 25 95% 53%; } .dark { --primary: 220 90% 66%; } ``` ### Extending Variants ```tsx // components/ui/button.tsx const buttonVariants = cva( "...", { variants: { variant: { default: "...", // Add custom variant gradient: "bg-gradient-to-r from-primary to-accent text-white hover:opacity-90", }, }, } ) ``` ### Using with Tailwind All components accept `className` for additional styling: ```tsx Pill Button Gradient Card ```
Subheadline with more details about your product.