shadcn

Manages shadcn/ui components, presets, and registries through the shadcn CLI.

Updated Sep 5, 2023
One-click install
npx skills add https://github.com/eyenalxai/dotfiles --skill shadcn-eyenalxai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shadcn
Source: https://github.com/eyenalxai/dotfiles/tree/main/.agents/skills/shadcn
Command: npx skills add https://github.com/eyenalxai/dotfiles --skill shadcn-eyenalxai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Working with shadcn/ui requires knowing the correct CLI commands, component composition rules, styling conventions, and preset workflows. This Skill provides project-aware guidance for adding, searching, updating, styling, and composing shadcn/ui components so generated code follows the framework's enforced rules instead of common anti-patterns. ## Core Features & Use Cases - Component lifecycle management: Search registries, preview changes with dry-run and diff, add or update components, and smart-merge upstream updates while preserving local modifications. - Enforced composition and styling rules: Detailed Incorrect/Correct references for forms, icons, chat UI, Tailwind styling, and Base UI vs Radix API differences. - Preset and theme workflows: Initialize projects with named presets or preset codes, apply or merge presets into existing projects, and customize themes via CSS variables. - Use Case: When asked to build a settings form in a Next.js shadcn project, the Skill reads the project context via npx shadcn@latest info, fetches component docs, and generates code using FieldGroup, Field, ToggleGroup, semantic color tokens, and the project's configured icon library. ## Quick Start Ask the assistant to add a shadcn/ui component such as a dialog or build a form following shadcn/ui best practices in your project.

Frequently Asked Questions about shadcn

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add shadcn/ui components to my project?

Run npx shadcn@latest add followed by component names, registry-prefixed names like @magicui/shimmer-button, or GitHub addresses like owner/repo/item. Use --dry-run to preview changes and --diff to compare against existing files before writing.

How do I update shadcn components without losing my local changes?

Run npx shadcn@latest add <component> --dry-run to see affected files, then --diff <file> to inspect upstream changes per file. Overwrite files with no local changes and manually merge files you have customized, never using --overwrite without explicit approval.

What is the difference between base and radix in shadcn/ui?

The base field in components.json determines the primitive library, which changes component APIs. Radix uses asChild and type="single"/"multiple" props, while Base UI uses render, a multiple boolean, items props on Select, and scalar Slider values.

How do I apply or switch a shadcn preset code?

Use npx shadcn@latest apply <code> to overwrite an existing project's preset, or npx shadcn@latest init --preset <code> --force --no-reinstall to update only config and CSS. Decode codes with npx shadcn@latest preset decode <code> instead of parsing them manually.

Why should I avoid space-y and raw colors in shadcn/ui code?

The shadcn styling rules require gap-* utilities instead of space-x-*/space-y-* and semantic tokens like bg-primary or text-muted-foreground instead of raw colors like bg-blue-500. Semantic tokens handle dark mode automatically through CSS variables.

Can I use shadcn/ui with monorepos and frameworks other than Next.js?

Yes, the CLI supports next, vite, start, react-router, and astro templates, all with --monorepo scaffolding; laravel is supported without monorepos. The CLI auto-detects the framework and package manager from the project.