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/setup-and-configuration.md
1# shadcn/ui - Setup and Configuration23## What is shadcn/ui?45shadcn/ui is **not** a traditional component library or npm package. Instead:6- It's a **collection of reusable components** that you copy into your project7- Components are **yours to customize** — you own the code8- Built with **Radix UI** primitives for accessibility9- Styled with **Tailwind CSS** utilities10- Includes CLI tool for easy component installation1112## Installation1314### New Project1516```bash17npx create-next-app@latest my-app --typescript --tailwind --eslint --app18cd my-app19npx shadcn@latest init2021# Install essential components22npx shadcn@latest add button input form card dialog select23```2425### Existing Project2627```bash28npm install tailwindcss-animate class-variance-authority clsx tailwind-merge lucide-react29npx shadcn@latest init30```3132### Installing Components3334```bash35npx shadcn@latest add button # single component36npx shadcn@latest add button input form # multiple components37npx shadcn@latest add --all # all components38```3940## Required Dependencies4142```json43{44"dependencies": {45"@radix-ui/react-accordion": "^1.1.2",46"@radix-ui/react-alert-dialog": "^1.0.5",47"@radix-ui/react-dialog": "^1.0.5",48"@radix-ui/react-dropdown-menu": "^2.0.6",49"@radix-ui/react-label": "^2.0.2",50"@radix-ui/react-select": "^2.0.0",51"@radix-ui/react-separator": "^1.0.3",52"@radix-ui/react-slot": "^1.0.2",53"@radix-ui/react-toast": "^1.1.5",54"class-variance-authority": "^0.7.0",55"clsx": "^2.0.0",56"lucide-react": "^0.294.0",57"tailwind-merge": "^2.0.0",58"tailwindcss-animate": "^1.0.7"59}60}61```6263## TSConfig Configuration6465```json66{67"compilerOptions": {68"target": "es5",69"lib": ["dom", "dom.iterable", "es6"],70"allowJs": true,71"skipLibCheck": true,72"strict": true,73"forceConsistentCasingInFileNames": true,74"noEmit": true,75"esModuleInterop": true,76"module": "esnext",77"moduleResolution": "node",78"resolveJsonModule": true,79"isolatedModules": true,80"jsx": "preserve",81"incremental": true,82"baseUrl": ".",83"paths": {84"@/components/*": ["./src/components/*"],85"@/lib/*": ["./src/lib/*"]86}87},88"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],89"exclude": ["node_modules"]90}91```9293## Tailwind Configuration9495```js96// tailwind.config.js97/** @type {import('tailwindcss').Config} */98module.exports = {99darkMode: ["class"],100content: [101'./pages/**/*.{ts,tsx}',102'./components/**/*.{ts,tsx}',103'./app/**/*.{ts,tsx}',104'./src/**/*.{ts,tsx}',105],106prefix: "",107theme: {108container: {109center: true,110padding: "2rem",111screens: { "2xl": "1400px" },112},113extend: {114colors: {115border: "hsl(var(--border))",116input: "hsl(var(--input))",117ring: "hsl(var(--ring))",118background: "hsl(var(--background))",119foreground: "hsl(var(--foreground))",120primary: {121DEFAULT: "hsl(var(--primary))",122foreground: "hsl(var(--primary-foreground))",123},124secondary: {125DEFAULT: "hsl(var(--secondary))",126foreground: "hsl(var(--secondary-foreground))",127},128destructive: {129DEFAULT: "hsl(var(--destructive))",130foreground: "hsl(var(--destructive-foreground))",131},132muted: {133DEFAULT: "hsl(var(--muted))",134foreground: "hsl(var(--muted-foreground))",135},136accent: {137DEFAULT: "hsl(var(--accent))",138foreground: "hsl(var(--accent-foreground))",139},140},141borderRadius: {142lg: "var(--radius)",143md: "calc(var(--radius) - 2px)",144sm: "calc(var(--radius) - 4px)",145},146keyframes: {147"accordion-down": {148from: { height: "0" },149to: { height: "var(--radix-accordion-content-height)" },150},151"accordion-up": {152from: { height: "var(--radix-accordion-content-height)" },153to: { height: "0" },154},155},156animation: {157"accordion-down": "accordion-down 0.2s ease-out",158"accordion-up": "accordion-up 0.2s ease-out",159},160},161},162plugins: [require("tailwindcss-animate")],163}164```165166## CSS Variables (globals.css)167168```css169@tailwind base;170@tailwind components;171@tailwind utilities;172173@layer base {174:root {175--background: 0 0% 100%;176--foreground: 222.2 84% 4.9%;177--card: 0 0% 100%;178--card-foreground: 222.2 84% 4.9%;179--popover: 0 0% 100%;180--popover-foreground: 222.2 84% 4.9%;181--primary: 222.2 47.4% 11.2%;182--primary-foreground: 210 40% 98%;183--secondary: 210 40% 96.1%;184--secondary-foreground: 222.2 47.4% 11.2%;185--muted: 210 40% 96.1%;186--muted-foreground: 215.4 16.3% 46.9%;187--accent: 210 40% 96.1%;188--accent-foreground: 222.2 47.4% 11.2%;189--destructive: 0 84.2% 60.2%;190--destructive-foreground: 210 40% 98%;191--border: 214.3 31.8% 91.4%;192--input: 214.3 31.8% 91.4%;193--ring: 222.2 84% 4.9%;194--radius: 0.5rem;195}196197.dark {198--background: 222.2 84% 4.9%;199--foreground: 210 40% 98%;200--card: 222.2 84% 4.9%;201--card-foreground: 210 40% 98%;202--popover: 222.2 84% 4.9%;203--popover-foreground: 210 40% 98%;204--primary: 210 40% 98%;205--primary-foreground: 222.2 47.4% 11.2%;206--secondary: 217.2 32.6% 17.5%;207--secondary-foreground: 210 40% 98%;208--muted: 217.2 32.6% 17.5%;209--muted-foreground: 215 20.2% 65.1%;210--accent: 217.2 32.6% 17.5%;211--accent-foreground: 210 40% 98%;212--destructive: 0 62.8% 30.6%;213--destructive-foreground: 210 40% 98%;214--border: 217.2 32.6% 17.5%;215--input: 217.2 32.6% 17.5%;216--ring: 212.7 26.8% 83.9%;217}218}219220@layer base {221* {222@apply border-border;223}224body {225@apply bg-background text-foreground;226}227}228```229