Skip to content
Back to skills

Shadcn Atomic Design

ASecurity

Build components using shadcn/ui as a foundation, following Atomic Design principles. Business logic never enters atoms or molecules. All visual customization flows through tokens, never through raw class overrides.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 24, 2026
designbashreactapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned November 24, 2026

npx -y skills add iDorgham/Workspace-Factory --skill shadcn_atomic_design --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Shadcn Atomic Design?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Shadcn Atomic Design
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/idorgham-shadcn-atomic-design/badge)](https://www.skillsdirectory.com/skills/idorgham-shadcn-atomic-design)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
type: Skill
subagents: [core-validator, integrity-bot]
agents: [master-guide, swarm-router]
dependencies: [core-orchestration, global-sync]
version: 1.0.0
---



# shadcn/ui + Atomic Design + Component Abstraction

## Purpose
Build components using shadcn/ui as a foundation, following Atomic Design principles. Business logic never enters atoms or molecules. All visual customization flows through tokens, never through raw class overrides.

## Atomic Design Hierarchy

```
TOKENS (CSS variables — packages/ui/src/lib/styles/tokens.css)
  ↓
ATOMS (packages/ui/src/components/atoms/)
  Button, Input, Badge, Icon, Avatar, Spinner, Checkbox, Radio
  ↓
MOLECULES (packages/ui/src/components/molecules/)
  FormField, CardHeader, SearchBar, StatusBadge, PriceBadge, DateDisplay
  ↓
ORGANISMS (packages/ui/src/components/ or apps/[app]/src/components/)
  BookingCard, MembershipCard, VenueHeader, DataTable, BookingForm
  ↓
TEMPLATES (apps/[app]/src/components/layouts/)
  DashboardLayout, AuthLayout, MarketingLayout
  ↓
PAGES (apps/[app]/src/app/[route]/page.tsx)
  BookingListPage, MembershipPage, Dashboard
```

## shadcn/ui Installation & Customization

```bash
# Install shadcn components — customize with tokens, not overrides
npx shadcn@latest add button
npx shadcn@latest add dialog
npx shadcn@latest add form
npx shadcn@latest add input
npx shadcn@latest add select
npx shadcn@latest add table
```

```css
/* globals.css — override shadcn via token mapping */
@layer base {
  :root {
    --background:    var(--color-surface-primary);
    --foreground:    var(--color-content-primary);
    --primary:       var(--color-primary);
    --primary-foreground: var(--color-content-inverse);
    --secondary:     var(--color-surface-secondary);
    --muted:         var(--color-surface-secondary);
    --muted-foreground: var(--color-content-secondary);
    --border:        var(--color-border-default);
    --ring:          var(--color-border-focus);
    --radius:        var(--radius-md);
    --destructive:   var(--color-error);
  }
}
```

## Atom Pattern

```tsx
// packages/ui/src/components/atoms/Button/Button.tsx
import { cva, type VariantProps } from 'class-variance-authority'
import { cn } from '@workspace/ui/lib/utils'

const buttonVariants = cva(
  // Base styles — tokens only
  'inline-flex items-center justify-center gap-[var(--space-2)] rounded-[var(--radius-button)] font-medium text-[length:var(--text-label)] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-border-focus)] disabled:pointer-events-none disabled:opacity-50',
  {
    variants: {
      variant: {
        primary:   'bg-[var(--color-primary)] text-[var(--color-content-inverse)] hover:bg-[var(--color-primary-hover)]',
        secondary: 'bg-[var(--color-surface-secondary)] text-[var(--color-content-primary)] hover:bg-[var(--color-border-default)]',
        ghost:     'hover:bg-[var(--color-surface-secondary)] text-[var(--color-content-primary)]',
        danger:    'bg-[var(--color-error)] text-white hover:opacity-90',
        luxury:    'bg-[var(--color-accent)] text-[var(--color-content-primary)] hover:bg-[var(--color-accent-hover)] shadow-[var(--shadow-button)]',
      },
      size: {
        sm: 'h-8 px-[var(--space-3)] text-[length:var(--text-body-sm)]',
        md: 'h-10 px-[var(--space-6)]',
        lg: 'h-12 px-[var(--space-8)] text-[length:var(--text-body-lg)]',
      },
    },
    defaultVariants: { variant: 'primary', size: 'md' },
  }
)

export interface ButtonProps
  extends React.ButtonHTMLAttributes<HTMLButtonElement>,
    VariantProps<typeof buttonVariants> {
  isLoading?: boolean
  loadingText?: string
}

export function Button({ className, variant, size, isLoading, loadingText, children, ...props }: ButtonProps) {
  return (
    <button
      className={cn(buttonVariants({ variant, size }), className)}
      aria-busy={isLoading}
      disabled={isLoading || props.disabled}
      {...props}
    >
      {isLoading && <Spinner className="size-4" aria-hidden="true" />}
      {isLoading ? loadingText ?? children : children}
    </button>
  )
}
```

## Molecule Pattern

```tsx
// packages/ui/src/components/molecules/FormField/FormField.tsx
// Combines: Label + Input + Error — reusable form building block
import { useTranslations } from 'next-intl'

interface FormFieldProps {
  id:           string
  label:        string
  error?:       string
  required?:    boolean
  children:     React.ReactElement
}

export function FormField({ id, label, error, required, children }: FormFieldProps) {
  const errorId = `${id}-error`

  return (
    <div className="flex flex-col gap-[var(--space-2)]">
      <label htmlFor={id} className="text-[length:var(--text-label)] font-medium text-[var(--color-content-primary)]">
        {label}
        {required && <span aria-hidden="true" className="text-[var(--color-error)] ms-1">*</span>}
      </label>

      {React.cloneElement(children, {
        id,
        'aria-required':   required,
        'aria-invalid':    !!error,
        'aria-describedby': error ? errorId : undefined,
      })}

      {error && (
        <p id={errorId} role="alert" className="text-[length:var(--text-caption)] text-[var(--color-error)]">
          {error}
        </p>
      )}
    </div>
  )
}
```

## Organism Pattern (Domain-Aware)

```tsx
// packages/ui/src/components/organisms/BookingCard/BookingCard.tsx
// Organisms CAN reference domain types — they're assembled from molecules
import type { BookingType } from '@workspace/shared/contracts/booking'
import { useTranslations } from 'next-intl'

interface BookingCardProps {
  booking: BookingType
  onConfirm?: (id: string) => void
  onCancel?: (id: string) => void
}

export function BookingCard({ booking, onConfirm, onCancel }: BookingCardProps) {
  const t = useTranslations('booking')

  return (
    <article
      className="bg-[var(--color-surface-elevated)] rounded-[var(--radius-card)] shadow-[var(--shadow-card)] p-[var(--space-6)]"
      aria-label={t('card.ariaLabel', { guest: booking.guestName })}
    >
      <CardHeader title={booking.guestName} subtitle={booking.venueName} />
      <dl className="grid grid-cols-2 gap-[var(--space-3)] mt-[var(--space-4)]">
        <div>
          <dt className="text-[length:var(--text-caption)] text-[var(--color-content-secondary)]">{t('table.date')}</dt>
          <dd className="text-[length:var(--text-body-sm)] font-medium">{formatDate(booking.startsAt)}</dd>
        </div>
        <div>
          <dt className="text-[length:var(--text-caption)] text-[var(--color-content-secondary)]">{t('table.status')}</dt>
          <dd><StatusBadge status={booking.status} /></dd>
        </div>
      </dl>
      {(onConfirm || onCancel) && (
        <div className="flex gap-[var(--space-3)] mt-[var(--space-6)]">
          {onConfirm && <Button variant="primary" onClick={() => onConfirm(booking.id)}>{t('actions.confirm')}</Button>}
          {onCancel && <Button variant="ghost" onClick={() => onCancel(booking.id)}>{t('actions.cancel')}</Button>}
        </div>
      )}
    </article>
  )
}
```

## File Structure Convention

```
packages/ui/src/components/
├── atoms/
│   ├── Button/
│   │   ├── Button.tsx
│   │   ├── Button.test.tsx
│   │   └── index.ts
│   └── Input/...
├── molecules/
│   ├── FormField/...
│   └── StatusBadge/...
└── organisms/
    ├── BookingCard/...
    └── DataTable/...
```

## Common Mistakes
- Business logic (API calls, state management) in atoms or molecules
- Raw Tailwind colors (`text-blue-600`) instead of token vars
- Duplicating shadcn component code — customize via CSS variables in globals.css
- Organisms in `apps/` when they're reusable across apps — they belong in `packages/ui`
- `className` string concatenation without `cn()` — merge conflicts

## Success Criteria
- [ ] Atoms: no domain types, no API calls, tokens only
- [ ] Molecules: composed from atoms, no business logic
- [ ] Organisms: may reference domain types, no direct API calls
- [ ] All shadcn overrides via CSS variables in globals.css
- [ ] Every component file includes test file
- [ ] `compliance` component check passes

Files in this skill

  • SKILL.md8.1 KB
  • SKILL.md.meta.json617 B
  • core.py368 B
  • manifest.yaml188 B
  • tests/test_core.py308 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in design →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.