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/reference.md
1# shadcn.io Component Library23shadcn.io is a comprehensive React UI component library built on shadcn/ui principles, providing developers with production-ready, composable components for modern web applications. The library serves as a centralized resource for React developers who need high-quality UI components with TypeScript support, ranging from basic interactive elements to advanced AI-powered integrations. Unlike traditional component libraries that require package installations, shadcn.io components are designed to be copied directly into your project, giving you full control and customization capabilities.45The library encompasses four major categories: composable UI components (terminal, dock, credit cards, QR codes, color pickers), chart components built with Recharts, animation components with Tailwind CSS integration, and custom React hooks for state management and lifecycle operations. Each component follows best practices for accessibility, performance, and developer experience, with comprehensive TypeScript definitions and Next.js compatibility. The platform emphasizes flexibility and customization, allowing developers to modify components at the source level rather than being constrained by package APIs.67## Core Components89### Terminal Component10Interactive terminal emulator with typing animations and command execution simulation for developer-focused interfaces.1112```tsx13import { Terminal } from "@/components/ui/terminal"1415export default function DemoTerminal() {16return (17npm install @repo/terminalInstalling dependencies...npm start18)19}20```2122### Dock Component23macOS-style application dock with smooth magnification effects on hover, perfect for navigation menus.2425```tsx26import { Dock, DockIcon } from "@/components/ui/dock"27import { Home, Settings, User, Mail } from "lucide-react"2829export default function AppDock() {30return (3132)33}34```3536### Credit Card Component37Interactive 3D credit card component with flip animations for payment forms and card displays.3839```tsx40import { CreditCard } from "@/components/ui/credit-card"41import { useState } from "react"4243export default function PaymentForm() {44const [cardData, setCardData] = useState({45number: "4532 1234 5678 9010",46holder: "JOHN DOE",47expiry: "12/28",48cvv: "123"49})5051return (52console.log("Card flipped:", flipped)}53/>54)55}56```5758### Image Zoom Component59Zoomable image component with smooth modal transitions for image galleries and product displays.6061```tsx62import { ImageZoom } from "@/components/ui/image-zoom"6364export default function ProductGallery() {65return (666768)69}70```7172### QR Code Component73Generate and display customizable QR codes with styling options for links, contact information, and authentication.7475```tsx76import { QRCode } from "@/components/ui/qr-code"7778export default function ShareDialog() {79const shareUrl = "https://shadcn.io"8081return (828384Scan to visit shadcn.io858687)88}89```9091### Color Picker Component92Advanced color selection component supporting multiple color formats (HEX, RGB, HSL) with preview.9394```tsx95import { ColorPicker } from "@/components/ui/color-picker"96import { useState } from "react"9798export default function ThemeCustomizer() {99const [color, setColor] = useState("#3b82f6")100101return (102103104Selected: {color}105106)107}108```109110## Chart Components111112### Bar Chart Component113Clean bar chart component for data comparison and categorical analysis using Recharts.114115```tsx116import { BarChart } from "@/components/ui/bar-chart"117118export default function SalesChart() {119const data = [120{ month: "Jan", sales: 4000, revenue: 2400 },121{ month: "Feb", sales: 3000, revenue: 1398 },122{ month: "Mar", sales: 2000, revenue: 9800 },123{ month: "Apr", sales: 2780, revenue: 3908 },124{ month: "May", sales: 1890, revenue: 4800 },125{ month: "Jun", sales: 2390, revenue: 3800 }126]127128return (129`$${value.toLocaleString()}`}130yAxisWidth={60}131/>132)133}134```135136### Line Chart Component137Smooth line chart for visualizing trends and time-series data with multiple data series support.138139```tsx140import { LineChart } from "@/components/ui/line-chart"141142export default function MetricsChart() {143const data = [144{ date: "2024-01", users: 1200, sessions: 3400 },145{ date: "2024-02", users: 1800, sessions: 4200 },146{ date: "2024-03", users: 2400, sessions: 5800 },147{ date: "2024-04", users: 3100, sessions: 7200 },148{ date: "2024-05", users: 3800, sessions: 8900 }149]150151return (152153)154}155```156157### Pie Chart Component158Donut chart component for displaying proportional data and percentage distributions.159160```tsx161import { PieChart } from "@/components/ui/pie-chart"162163export default function MarketShareChart() {164const data = [165{ name: "Product A", value: 400, fill: "#3b82f6" },166{ name: "Product B", value: 300, fill: "#10b981" },167{ name: "Product C", value: 300, fill: "#f59e0b" },168{ name: "Product D", value: 200, fill: "#ef4444" }169]170171return (172`${entry.name}: ${entry.value}`}173/>174)175}176```177178### Area Chart Component179Stacked area chart for visualizing volume changes over time with multiple data series.180181```tsx182import { AreaChart } from "@/components/ui/area-chart"183184export default function TrafficChart() {185const data = [186{ month: "Jan", mobile: 2000, desktop: 3000, tablet: 1000 },187{ month: "Feb", mobile: 2200, desktop: 3200, tablet: 1100 },188{ month: "Mar", mobile: 2800, desktop: 3800, tablet: 1300 },189{ month: "Apr", mobile: 3200, desktop: 4200, tablet: 1500 },190{ month: "May", mobile: 3800, desktop: 4800, tablet: 1800 }191]192193return (194195)196}197```198199### Radar Chart Component200Multi-axis chart for comparing multiple variables across different categories simultaneously.201202```tsx203import { RadarChart } from "@/components/ui/radar-chart"204205export default function SkillsChart() {206const data = [207{ skill: "JavaScript", score: 85, industry: 75 },208{ skill: "TypeScript", score: 80, industry: 70 },209{ skill: "React", score: 90, industry: 80 },210{ skill: "Node.js", score: 75, industry: 72 },211{ skill: "CSS", score: 88, industry: 78 }212]213214return (215216)217}218```219220### Mixed Chart Component221Combined bar and line chart for displaying multiple data types with different visualization methods.222223```tsx224import { MixedChart } from "@/components/ui/mixed-chart"225226export default function PerformanceChart() {227const data = [228{ month: "Jan", revenue: 4000, growth: 5.2 },229{ month: "Feb", revenue: 4200, growth: 5.0 },230{ month: "Mar", revenue: 4800, growth: 14.3 },231{ month: "Apr", revenue: 5200, growth: 8.3 },232{ month: "May", revenue: 5800, growth: 11.5 }233]234235return (236237)238}239```240241## Animation Components242243### Magnetic Effect Component244Magnetic hover effect that smoothly follows cursor movement for interactive buttons and cards.245246```tsx247import { Magnetic } from "@/components/ui/magnetic"248249export default function InteractiveButton() {250return (251252Hover me253254)255}256```257258### Animated Cursor Component259Custom animated cursor with interactive effects and particle trails for immersive experiences.260261```tsx262import { AnimatedCursor } from "@/components/ui/animated-cursor"263264export default function Layout({ children }) {265return (266<>267268{children}269270)271}272```273274### Apple Hello Effect Component275Recreation of Apple's iconic "hello" animation with multi-language text transitions.276277```tsx278import { AppleHello } from "@/components/ui/apple-hello"279280export default function WelcomeScreen() {281const greetings = [282{ text: "Hello", lang: "en" },283{ text: "Bonjour", lang: "fr" },284{ text: "こんにちは", lang: "ja" },285{ text: "Hola", lang: "es" },286{ text: "你好", lang: "zh" }287]288289return (290291)292}293```294295### Liquid Button Component296Button with fluid liquid animation effect on hover for engaging call-to-action elements.297298```tsx299import { LiquidButton } from "@/components/ui/liquid-button"300301export default function CTASection() {302return (303console.log("CTA clicked")}304>305Get Started306307)308}309```310311### Rolling Text Component312Text animation that creates a rolling effect with smooth character transitions.313314```tsx315import { RollingText } from "@/components/ui/rolling-text"316317export default function AnimatedHeading() {318return (319320)321}322```323324### Shimmering Text Component325Text with animated shimmer effect for attention-grabbing headings and highlights.326327```tsx328import { ShimmeringText } from "@/components/ui/shimmering-text"329330export default function Hero() {331return (332333)334}335```336337## React Hooks338339### useBoolean Hook340Enhanced boolean state management with toggle, enable, and disable methods for cleaner component logic.341342```tsx343import { useBoolean } from "@/hooks/use-boolean"344345export default function TogglePanel() {346const modal = useBoolean(false)347const loading = useBoolean(false)348349const handleSubmit = async () => {350loading.setTrue()351try {352await submitForm()353modal.setFalse()354} finally {355loading.setFalse()356}357}358359return (360<>361Toggle Modal362{modal.value && (363364365Status: {loading.value ? "Saving..." : "Ready"}366367Submit368369370)}371372)373}374```375376### useCounter Hook377Counter hook with increment, decrement, reset, and set functionality for numeric state management.378379```tsx380import { useCounter } from "@/hooks/use-counter"381382export default function CartCounter() {383const quantity = useCounter(0, { min: 0, max: 99 })384385return (386387388-389{quantity.value}390+391392Reset393394395)396}397```398399### useLocalStorage Hook400Persist state in browser localStorage with automatic serialization and deserialization.401402```tsx403import { useLocalStorage } from "@/hooks/use-local-storage"404405export default function UserPreferences() {406const [theme, setTheme] = useLocalStorage("theme", "light")407const [settings, setSettings] = useLocalStorage("settings", {408notifications: true,409emailUpdates: false410})411412return (413414415setTheme(e.target.value)}>416LightDark setSettings({417...settings,418notifications: e.target.checked419})}420/>421Enable Notifications422423424)425}426```427428### useDebounceValue Hook429Debounce values to prevent excessive updates and API calls during rapid user input.430431```tsx432import { useDebounceValue } from "@/hooks/use-debounce-value"433import { useState, useEffect } from "react"434435export default function SearchBox() {436const [search, setSearch] = useState("")437const debouncedSearch = useDebounceValue(search, 500)438const [results, setResults] = useState([])439const [apiCalls, setApiCalls] = useState(0)440441useEffect(() => {442if (debouncedSearch) {443setApiCalls(prev => prev + 1)444fetch(`/api/search?q=${debouncedSearch}`)445.then(res => res.json())446.then(setResults)447}448}, [debouncedSearch])449450return (451452453setSearch(e.target.value)}454placeholder="Search..."455/>456457458API calls: {apiCalls}459460461)462}463```464465### useHover Hook466Track hover state on elements with customizable enter and leave delays for tooltip and preview functionality.467468```tsx469import { useHover } from "@/hooks/use-hover"470import { useRef } from "react"471472export default function ImagePreview() {473const hoverRef = useRef(null)474const isHovering = useHover(hoverRef, {475enterDelay: 200,476leaveDelay: 100477})478479return (480481482483{isHovering && (484485486487488)}489490491)492}493```494495### useCountdown Hook496Countdown timer with play, pause, reset controls and completion callbacks for time-limited features.497498```tsx499import { useCountdown } from "@/hooks/use-countdown"500501export default function OTPTimer() {502const countdown = useCountdown({503initialSeconds: 60,504onComplete: () => alert("OTP expired! Request a new code.")505})506507return (508509510{countdown.seconds}s511512{!countdown.isRunning ? (513Start514) : (515Pause516)}517Reset518519Status: {countdown.isComplete ? "Expired" : countdown.isRunning ? "Active" : "Paused"}520521522)523}524```525526## Installation and Usage527528### CLI Installation529Install components directly into your project using the shadcn CLI for instant integration.530531```bash532# Initialize shadcn in your project533npx shadcn@latest init534535# Add individual components536npx shadcn@latest add terminal537npx shadcn@latest add dock538npx shadcn@latest add credit-card539540# Add multiple components at once541npx shadcn@latest add bar-chart line-chart pie-chart542543# Add hooks544npx shadcn@latest add use-boolean use-counter use-local-storage545```546547### Project Configuration548Configure your project to work with shadcn.io components using TypeScript and Tailwind CSS.549550```typescript551// tailwind.config.ts552import type { Config } from "tailwindcss"553554const config: Config = {555darkMode: ["class"],556content: [557"./pages/**/*.{ts,tsx}",558"./components/**/*.{ts,tsx}",559"./app/**/*.{ts,tsx}",560],561theme: {562extend: {563colors: {564border: "hsl(var(--border))",565input: "hsl(var(--input))",566ring: "hsl(var(--ring))",567background: "hsl(var(--background))",568foreground: "hsl(var(--foreground))",569primary: {570DEFAULT: "hsl(var(--primary))",571foreground: "hsl(var(--primary-foreground))",572},573},574},575},576plugins: [require("tailwindcss-animate")],577}578579export default config580```581582## Summary583584The shadcn.io component library serves as a comprehensive toolkit for React developers building modern web applications with Next.js and TypeScript. The library's primary use cases include rapid prototyping of user interfaces, building data-rich dashboards with interactive charts, creating engaging user experiences with animations and effects, and implementing common UI patterns without writing boilerplate code. The copy-paste approach gives developers complete ownership of their components, allowing for deep customization while maintaining consistency with shadcn/ui design principles. Components are particularly well-suited for SaaS applications, admin panels, marketing websites, and e-commerce platforms that require professional, accessible UI elements.585586Integration patterns center around composability and customization rather than rigid package dependencies. Developers can cherry-pick individual components using the CLI, modify them at the source level to match their design system, and combine them with existing shadcn/ui components for a cohesive interface. The library supports both light and dark themes through CSS variables, integrates seamlessly with Tailwind CSS utility classes, and follows React best practices for performance and accessibility. Custom hooks provide reusable logic patterns that complement the visual components, creating a complete ecosystem for building feature-rich applications. The TypeScript-first approach ensures type safety throughout the development process, while the Recharts integration for data visualization provides powerful charting capabilities without additional configuration overhead.