Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Integrate and customize shadcn/ui components—discovery, installation, theming, and Radix/Base UI best practices
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
README.md
1# shadcn/ui Integration Skill23## Install45```bash6npx skills add google-labs-code/stitch-skills --skill shadcn-ui --global7```89## What It Does1011This skill provides expert guidance for integrating shadcn/ui components into your React applications. It helps you discover, install, customize, and optimize shadcn/ui components while following best practices.1213## Example Prompts1415```text16Help me set up shadcn/ui in my Next.js project1718Add a data table component with sorting and filtering to my app1920Show me how to customize the button component with a new variant2122Create a login form using shadcn/ui components with validation2324Build a dashboard layout with sidebar navigation using shadcn/ui blocks25```2627## What is shadcn/ui?2829shadcn/ui is a collection of beautifully designed, accessible, and customizable components built with:30- **Radix UI or Base UI**: Unstyled, accessible component primitives31- **Tailwind CSS**: Utility-first styling framework32- **TypeScript**: Full type safety3334**Key Difference**: Unlike traditional component libraries, shadcn/ui copies components directly into your project. This gives you:35- Full control over the code36- No version lock-in37- Complete customization freedom38- Zero runtime overhead3940## Skill Structure4142```text43skills/shadcn-ui/44├── SKILL.md — Core instructions & workflow45├── README.md — This file46├── examples/ — Example implementations47│ ├── form-pattern.tsx — Form with validation48│ ├── data-table.tsx — Advanced table with sorting49│ └── auth-layout.tsx — Authentication flow50├── resources/ — Reference documentation51│ ├── setup-guide.md — Project initialization52│ ├── component-catalog.md — Component reference53│ ├── customization-guide.md — Theming patterns54│ └── migration-guide.md — Migration from other libraries55└── scripts/ — Utility scripts56└── verify-setup.sh — Validate project configuration57```5859## How It Works6061When activated, the agent follows this workflow:6263### 1. **Discovery & Planning**64- Lists available components using shadcn MCP tools65- Identifies required dependencies66- Plans component composition strategy6768### 2. **Setup & Configuration**69- Verifies or initializes `components.json`70- Checks Tailwind CSS configuration71- Validates import aliases and paths7273### 3. **Component Integration**74- Retrieves component source code75- Installs via CLI or manual integration76- Handles dependency installation7778### 4. **Customization**79- Applies theme customization80- Creates component variants81- Extends components with custom logic8283### 5. **Quality Assurance**84- Validates TypeScript types85- Checks accessibility compliance86- Verifies responsive behavior8788## Prerequisites8990Your project should have:91- **React 18+**92- **Tailwind CSS 3.0+**93- **TypeScript** (recommended)94- **Node.js 18+**9596## Quick Start9798### For New Projects99100```bash101# Create Next.js project with shadcn/ui102npx create-next-app@latest my-app103cd my-app104npx shadcn@latest init105106# Add components107npx shadcn@latest add button108npx shadcn@latest add card109```110111### For Existing Projects112113```bash114# Initialize shadcn/ui115npx shadcn@latest init116117# Configure when prompted:118# - Choose style (default/new-york)119# - Select base color120# - Configure CSS variables121# - Set import aliases122123# Add your first component124npx shadcn@latest add button125```126127## Available Components128129shadcn/ui provides 50+ components including:130131**Layout**: Accordion, Card, Separator, Tabs, Collapsible132**Forms**: Button, Input, Label, Checkbox, Radio Group, Select, Textarea133**Data Display**: Table, Badge, Avatar, Progress, Skeleton134**Overlays**: Dialog, Sheet, Popover, Tooltip, Dropdown Menu135**Navigation**: Navigation Menu, Tabs, Breadcrumb, Pagination136**Feedback**: Alert, Alert Dialog, Toast, Command137138Plus complete **Blocks** like:139- Authentication forms140- Dashboard layouts141- Calendar interfaces142- Sidebar navigation143- E-commerce components144145## Customization Approach146147### Theme-Level Customization148Modify CSS variables in `globals.css`:149```css150:root {151--primary: 221.2 83.2% 53.3%;152--secondary: 210 40% 96.1%;153/* ... */154}155```156157### Component-Level Customization158Components use `class-variance-authority` for variants:159```typescript160const buttonVariants = cva(161"base-classes",162{163variants: {164variant: { default: "...", destructive: "..." },165size: { default: "...", sm: "..." },166}167}168)169```170171### Composition172Create higher-level components:173```typescript174// Compose existing components175export function FeatureCard({ title, description, icon }) {176return (177<Card>178<CardHeader>179{icon}180<CardTitle>{title}</CardTitle>181</CardHeader>182<CardContent>183<p>{description}</p>184</CardContent>185</Card>186)187}188```189190## Integration with MCP Tools191192This skill leverages shadcn MCP server capabilities:193194- `list_components` - Browse component catalog195- `get_component` - Retrieve component source196- `get_component_metadata` - View props and dependencies197- `get_component_demo` - See usage examples198- `list_blocks` - Browse UI blocks199- `get_block` - Retrieve block source with all files200- `search_items_in_registries` - Find components in custom registries201202## Best Practices2032041. **Keep `ui/` pure**: Don't modify components in `components/ui/` directly2052. **Compose, don't fork**: Create wrapper components instead of editing originals2063. **Use the CLI**: Let `shadcn add` handle dependencies and updates2074. **Maintain consistency**: Use the `cn()` utility for all class merging2085. **Respect accessibility**: Preserve ARIA attributes and keyboard handlers2096. **Test responsiveness**: shadcn components are responsive by default—keep it that way210211## Troubleshooting212213### "Module not found" errors214Check your `tsconfig.json` includes path aliases:215```json216{217"compilerOptions": {218"paths": {219"@/*": ["./src/*"]220}221}222}223```224225### Styles not applying226- Import `globals.css` in your root layout227- Verify Tailwind config includes component paths228- Check CSS variable definitions match component expectations229230### TypeScript errors231- Ensure all Radix UI peer dependencies are installed232- Run `npm install` after adding components via CLI233- Check that React types are up to date234235## Further Reading236237- [Official Documentation](https://ui.shadcn.com)238- [Component Source](https://github.com/shadcn-ui/ui)239- [Radix UI Docs](https://www.radix-ui.com)240- [Tailwind CSS Docs](https://tailwindcss.com)241242## Contributing243244Contributions to improve this skill are welcome! See the root [CONTRIBUTING.md](../../CONTRIBUTING.md) for guidelines.245246## License247248See [LICENSE](../../LICENSE) in the repository root.249