Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
existential-birds avatar

Shadcn Ui

  • 320 installs
  • 74 repo stars
  • Updated July 21, 2026
  • existential-birds/beagle

shadcn-ui is a Claude Code skill that helps developers implement accessible shadcn/ui components with correct Radix primitives, Tailwind design tokens, variants, and form patterns aligned to a design system.

About

shadcn-ui is a frontend development skill for Claude Code that guides correct implementation of shadcn/ui components using Radix UI primitives, Tailwind CSS tokens, component variants, and accessible form patterns. The skill helps developers wire buttons, dialogs, selects, and form controls so they match project design system conventions instead of copying incomplete snippets. It focuses on accessibility defaults, variant APIs, and composition patterns common in React and Next.js codebases adopting shadcn/ui. Reach for shadcn-ui when you are adding or refactoring UI components and need Radix behavior, Tailwind styling, and form wiring done consistently.

  • Component scaffolding
  • Radix accessibility
  • Tailwind variants
  • Form + dialog patterns
  • Theme token alignment

Shadcn Ui by the numbers

  • 320 all-time installs (skills.sh)
  • Ranked #731 of 2,245 Frontend Development skills by installs in the Skillselion catalog
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/existential-birds/beagle --skill shadcn-ui

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs320
repo stars74
Last updatedJuly 21, 2026
Repositoryexistential-birds/beagle

How do you implement shadcn/ui components correctly?

Implement accessible shadcn/ui components with correct Radix primitives, Tailwind tokens, variants, and form patterns aligned to your design system.

Who is it for?

React and Next.js developers adopting shadcn/ui who need Radix-backed components, Tailwind tokens, and accessible form patterns implemented correctly.

Skip if: Vue or Svelte-only projects, backend API work, or teams using Material UI or Chakra without shadcn/ui in the stack.

When should I use this skill?

The user asks to add, customize, or fix shadcn/ui components, Radix primitives, Tailwind variants, or form patterns in a React frontend.

What you get

Accessible shadcn/ui component implementations with Radix primitives, Tailwind variant classes, and form control patterns

  • Component implementations
  • Form pattern wiring
  • Variant class definitions

Files

SKILL.mdMarkdownGitHub ↗

shadcn/ui Component Development

Contents

CLI Commands

Initialize shadcn/ui

npx shadcn@latest init

This creates a components.json configuration file and sets up:

  • Tailwind CSS configuration
  • CSS variables for theming
  • cn() utility function
  • Required dependencies

Add Components

# Add a single component
npx shadcn@latest add button

# Add multiple components
npx shadcn@latest add button card dialog

# Add all available components
npx shadcn@latest add --all

Important: The package name changed in 2024:

  • Old (deprecated): npx shadcn-ui@latest add
  • Current: npx shadcn@latest add

Common Options

  • -y, --yes - Skip confirmation prompt
  • -o, --overwrite - Overwrite existing files
  • -c, --cwd <cwd> - Set working directory
  • --src-dir - Use src directory structure

Gates (CLI and file changes)

Run these in order before init / add (skip only when you are not running the CLI—e.g. copying snippets from this skill):

1. Working directory: Pass: pwd and package.json at that path identify the app root that should receive components/ and components.json (use -c <cwd> if the shell is elsewhere). 2. After `init`: Pass: components.json exists at that app root (or the documented path for your monorepo layout). 3. Before `--overwrite`: Pass: you can list which tracked files will be replaced, or version control shows the change is intentional and recoverable.

Quick Reference

cn() Utility

import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs))
}

Basic CVA Pattern

import { cva, type VariantProps } from "class-variance-authority"

const buttonVariants = cva(
  "base-classes-applied-to-all-variants",
  {
    variants: {
      variant: {
        default: "bg-primary text-primary-foreground",
        outline: "border bg-background",
      },
      size: {
        sm: "h-8 px-3",
        lg: "h-10 px-6",
      },
    },
    defaultVariants: {
      variant: "default",
      size: "sm",
    },
  }
)

function Button({
  variant,
  size,
  className,
  ...props
}: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants>) {
  return (
    <button
      className={cn(buttonVariants({ variant, size }), className)}
      {...props}
    />
  )
}

export { Button, buttonVariants }

Component Anatomy

Props Typing Patterns

// HTML elements
function Component({ className, ...props }: React.ComponentProps<"div">) {
  return <div className={cn("base-classes", className)} {...props} />
}

// Radix primitives
function Component({ className, ...props }: React.ComponentProps<typeof RadixPrimitive.Root>) {
  return <RadixPrimitive.Root className={cn("base-classes", className)} {...props} />
}

// With CVA variants
function Component({
  variant, size, className, ...props
}: React.ComponentProps<"button"> & VariantProps<typeof variants>) {
  return <button className={cn(variants({ variant, size }), className)} {...props} />
}

asChild Pattern

Enables polymorphic rendering via @radix-ui/react-slot:

import { Slot } from "@radix-ui/react-slot"

function Button({
  asChild = false,
  className,
  variant,
  size,
  ...props
}: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & { asChild?: boolean }) {
  const Comp = asChild ? Slot : "button"
  return (
    <Comp
      data-slot="button"
      className={cn(buttonVariants({ variant, size }), className)}
      {...props}
    />
  )
}

Usage:

<Button>Click me</Button>                           // Renders <button>
<Button asChild><a href="/home">Home</a></Button>   // Renders <a> with button styling
<Button asChild><Link href="/dash">Dash</Link></Button>  // Works with Next.js Link

data-slot Attributes

Every component includes data-slot for CSS targeting:

function Card({ ...props }) { return <div data-slot="card" {...props} /> }
function CardHeader({ ...props }) { return <div data-slot="card-header" {...props} /> }

CSS/Tailwind targeting:

[data-slot="button"] { /* styles */ }
[data-slot="card"] [data-slot="button"] { /* nested targeting */ }
<div className="[&_[data-slot=button]]:shadow-lg">
  <Button>Automatically styled</Button>
</div>

Conditional layouts with has():

<div
  data-slot="card-header"
  className={cn(
    "grid gap-2",
    "has-data-[slot=card-action]:grid-cols-[1fr_auto]"
  )}
/>

Component Patterns

Compound Components

export { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter }

function Card({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card"
      className={cn("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm", className)}
      {...props}
    />
  )
}

function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
  return <div data-slot="card-header" className={cn("grid gap-2 px-6", className)} {...props} />
}

function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
  return <div data-slot="card-title" className={cn("leading-none font-semibold", className)} {...props} />
}

Styling Techniques

CVA Variants

Multiple dimensions:

const buttonVariants = cva("base-classes", {
  variants: {
    variant: {
      default: "bg-primary text-primary-foreground",
      destructive: "bg-destructive text-white",
      outline: "border bg-background",
      ghost: "hover:bg-accent",
      link: "text-primary underline-offset-4 hover:underline",
    },
    size: {
      default: "h-9 px-4 py-2",
      sm: "h-8 px-3",
      lg: "h-10 px-6",
      icon: "size-9",
    },
  },
  defaultVariants: { variant: "default", size: "default" },
})

Compound variants:

compoundVariants: [
  { variant: "outline", size: "lg", class: "border-2" },
]

Type extraction:

type ButtonVariants = VariantProps<typeof buttonVariants>
// Result: { variant?: "default" | "outline" | ..., size?: "sm" | "lg" | ... }

Modern CSS Selectors in Tailwind

has() selector:

<button className="px-4 has-[>svg]:px-3">  // Adjusts padding when contains icon
<div className="has-data-[slot=action]:grid-cols-[1fr_auto]">  // Conditional layout

Group/peer selectors:

<div className="group" data-state="collapsed">
  <div className="group-data-[state=collapsed]:hidden">Hidden when collapsed</div>
</div>

<button className="peer/menu" data-active="true">Menu</button>
<div className="peer-data-[active=true]/menu:text-accent">Styled when sibling active</div>

Container queries:

<div className="@container/card">
  <div className="@md:flex-row">Responds to container width</div>
</div>

Accessibility States

className={cn(
  // Focus
  "outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
  // Invalid
  "aria-invalid:border-destructive aria-invalid:ring-destructive/20",
  // Disabled
  "disabled:pointer-events-none disabled:opacity-50",
)}

<span className="sr-only">Close</span>  // Screen reader only

Dark Mode

Semantic tokens adapt automatically:

className="bg-background text-foreground dark:bg-input/30 dark:hover:bg-input/50"

Tokens: bg-background, text-foreground, bg-primary, text-primary-foreground, bg-card, text-card-foreground, border-input, text-muted-foreground

Decision Tables

When to Use CVA

ScenarioUse CVAAlternative
Multiple visual variants (primary, outline, ghost)YesPlain className
Size variations (sm, md, lg)YesPlain className
Compound conditions (outline + large = thick border)YesConditional cn()
One-off custom stylingNoclassName prop
Dynamic colors from propsNoInline styles or CSS variables

When to Use Compound Components

ScenarioUse CompoundAlternative
Complex UI with multiple semantic partsYesSingle component with many props
Optional sections (header, footer)YesBoolean show/hide props
Different styling for each partYesCSS selectors
Shared state between partsYes + ContextProps drilling
Simple wrapper with childrenNoSingle component

When to Use asChild

ScenarioUse asChildAlternative
Component should work as link or buttonYesDuplicate component
Need button styles on custom elementYesExport variant styles
Integration with routing librariesYesWrapper components
Always renders same elementNoStandard component

When to Use Context

ScenarioUse ContextAlternative
Deep prop drilling (>3 levels)YesProps
State shared by many siblingsYesLift state up
Plugin/extension architectureYesProps
Simple parent-child communicationNoProps

Common Patterns

Form Input

function Input({ className, type, ...props }: React.ComponentProps<"input">) {
  return (
    <input
      type={type}
      data-slot="input"
      className={cn(
        "h-9 w-full rounded-md border px-3 py-1",
        "outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
        "aria-invalid:border-destructive aria-invalid:ring-destructive/20",
        "disabled:cursor-not-allowed disabled:opacity-50",
        "placeholder:text-muted-foreground dark:bg-input/30",
        className
      )}
      {...props}
    />
  )
}

Dialog Content

function DialogContent({ children, showCloseButton = true, ...props }) {
  return (
    <DialogPortal>
      <DialogOverlay />
      <DialogPrimitive.Content
        data-slot="dialog-content"
        className={cn(
          "fixed top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%] w-full max-w-lg",
          "bg-background border rounded-lg p-6 shadow-lg",
          "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
          "data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
        )}
        {...props}
      >
        {children}
        {showCloseButton && (
          <DialogPrimitive.Close className="absolute top-4 right-4">
            <XIcon /><span className="sr-only">Close</span>
          </DialogPrimitive.Close>
        )}
      </DialogPrimitive.Content>
    </DialogPortal>
  )
}

Sidebar with Context

function SidebarProvider({ defaultOpen = true, children }) {
  const isMobile = useIsMobile()
  const [open, setOpen] = React.useState(defaultOpen)

  React.useEffect(() => {
    const handleKeyDown = (e: KeyboardEvent) => {
      if (e.key === "b" && (e.metaKey || e.ctrlKey)) {
        e.preventDefault()
        setOpen(o => !o)
      }
    }
    window.addEventListener("keydown", handleKeyDown)
    return () => window.removeEventListener("keydown", handleKeyDown)
  }, [])

  const contextValue = React.useMemo(
    () => ({ state: open ? "expanded" : "collapsed", open, setOpen, isMobile }),
    [open, setOpen, isMobile]
  )

  return (
    <SidebarContext.Provider value={contextValue}>
      <div
        data-slot="sidebar-wrapper"
        style={{ "--sidebar-width": "16rem", "--sidebar-width-icon": "3rem" } as React.CSSProperties}
      >
        {children}
      </div>
    </SidebarContext.Provider>
  )
}

Reference Files

For comprehensive examples and advanced patterns:

  • [components.md](./references/components.md) - Full implementations: Button, Card, Badge, Input, Label, Textarea, Dialog
  • [cva.md](./references/cva.md) - CVA patterns: compound variants, responsive variants, type extraction
  • [patterns.md](./references/patterns.md) - Architectural patterns: compound components, asChild, controlled state, Context, data-slot, has() selectors

Related skills

FAQ

What stack does shadcn-ui assume?

shadcn-ui targets React frontends using shadcn/ui components built on Radix UI primitives and Tailwind CSS, including variant APIs and form patterns common in Next.js design systems.

When should developers use the shadcn-ui skill?

shadcn-ui fits when adding or refactoring UI components in a shadcn/ui codebase and the developer needs correct Radix behavior, Tailwind token usage, and accessible form wiring rather than generic CSS advice.

Frontend Developmentfrontendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.