Skip to content

try-works/role-model / .agents/skills/ui-design-system

ui-design-system

Unverified

React UI component systems with TailwindCSS + Radix + shadcn/ui. Stack: TailwindCSS (styling), Radix UI (primitives), shadcn/ui (components), React/Next.js. Capabilities: design system architecture, accessible components, responsive layouts, theming, dark mode, component composition. Actions: review, design, build, improve, refactor UI components. Keywords: TailwindCSS, Radix UI, shadcn/ui, design system, component library, accessibility, ARIA, responsive, dark mode, theming, CSS variables, component architecture, atomic design, design tokens, variant, slot, composition. Use when: building component libraries, implementing shadcn/ui, creating accessible UIs, setting up design systems, adding dark mode/theming, reviewing UI component architecture.

FileKindSize
SKILL.mdskill md19.6 KB
canvas-fonts/ArsenalSC-OFL.txtmarkdown4.3 KB
canvas-fonts/ArsenalSC-Regular.ttfbinary162.0 KB
canvas-fonts/BigShoulders-Bold.ttfbinary92.3 KB
canvas-fonts/BigShoulders-OFL.txtmarkdown4.3 KB
canvas-fonts/BigShoulders-Regular.ttfbinary92.2 KB
canvas-fonts/Boldonse-OFL.txtmarkdown4.3 KB
canvas-fonts/Boldonse-Regular.ttfbinary75.4 KB
canvas-fonts/BricolageGrotesque-Bold.ttfbinary88.8 KB
canvas-fonts/BricolageGrotesque-OFL.txtmarkdown4.3 KB
canvas-fonts/BricolageGrotesque-Regular.ttfbinary88.8 KB
canvas-fonts/CrimsonPro-Bold.ttfbinary104.8 KB
canvas-fonts/CrimsonPro-Italic.ttfbinary106.3 KB
canvas-fonts/CrimsonPro-OFL.txtmarkdown4.3 KB
canvas-fonts/CrimsonPro-Regular.ttfbinary104.2 KB
canvas-fonts/DMMono-OFL.txtmarkdown4.3 KB
canvas-fonts/DMMono-Regular.ttfbinary47.7 KB
canvas-fonts/EricaOne-OFL.txtmarkdown4.3 KB
canvas-fonts/EricaOne-Regular.ttfbinary24.3 KB
canvas-fonts/GeistMono-Bold.ttfbinary76.5 KB
canvas-fonts/GeistMono-OFL.txtmarkdown4.3 KB
canvas-fonts/GeistMono-Regular.ttfbinary76.4 KB
canvas-fonts/Gloock-OFL.txtmarkdown4.3 KB
canvas-fonts/Gloock-Regular.ttfbinary92.9 KB
canvas-fonts/IBMPlexMono-Bold.ttfbinary132.8 KB
canvas-fonts/IBMPlexMono-OFL.txtmarkdown4.3 KB
canvas-fonts/IBMPlexMono-Regular.ttfbinary130.7 KB
canvas-fonts/IBMPlexSerif-Bold.ttfbinary157.2 KB
canvas-fonts/IBMPlexSerif-BoldItalic.ttfbinary165.9 KB
canvas-fonts/IBMPlexSerif-Italic.ttfbinary166.0 KB
canvas-fonts/IBMPlexSerif-Regular.ttfbinary156.6 KB
canvas-fonts/InstrumentSans-Bold.ttfbinary66.5 KB
canvas-fonts/InstrumentSans-BoldItalic.ttfbinary68.4 KB
canvas-fonts/InstrumentSans-Italic.ttfbinary68.3 KB
canvas-fonts/InstrumentSans-OFL.txtmarkdown4.3 KB
canvas-fonts/InstrumentSans-Regular.ttfbinary66.4 KB
canvas-fonts/InstrumentSerif-Italic.ttfbinary69.2 KB
canvas-fonts/InstrumentSerif-Regular.ttfbinary67.7 KB
canvas-fonts/Italiana-OFL.txtmarkdown4.3 KB
canvas-fonts/Italiana-Regular.ttfbinary26.5 KB
canvas-fonts/JetBrainsMono-Bold.ttfbinary112.1 KB
canvas-fonts/JetBrainsMono-OFL.txtmarkdown4.3 KB
canvas-fonts/JetBrainsMono-Regular.ttfbinary112.2 KB
canvas-fonts/Jura-Light.ttfbinary150.7 KB
canvas-fonts/Jura-Medium.ttfbinary150.9 KB
canvas-fonts/Jura-OFL.txtmarkdown4.3 KB
canvas-fonts/LibreBaskerville-OFL.txtmarkdown4.3 KB
canvas-fonts/LibreBaskerville-Regular.ttfbinary144.1 KB
canvas-fonts/Lora-Bold.ttfbinary130.7 KB
canvas-fonts/Lora-BoldItalic.ttfbinary137.0 KB
canvas-fonts/Lora-Italic.ttfbinary136.1 KB
canvas-fonts/Lora-OFL.txtmarkdown4.3 KB
canvas-fonts/Lora-Regular.ttfbinary130.8 KB
canvas-fonts/NationalPark-Bold.ttfbinary77.4 KB
canvas-fonts/NationalPark-OFL.txtmarkdown4.3 KB
canvas-fonts/NationalPark-Regular.ttfbinary74.6 KB
canvas-fonts/NothingYouCouldDo-OFL.txtmarkdown4.3 KB
canvas-fonts/NothingYouCouldDo-Regular.ttfbinary31.3 KB
canvas-fonts/Outfit-Bold.ttfbinary54.1 KB
canvas-fonts/Outfit-OFL.txtmarkdown4.3 KB
canvas-fonts/Outfit-Regular.ttfbinary53.6 KB
canvas-fonts/PixelifySans-Medium.ttfbinary49.9 KB
canvas-fonts/PixelifySans-OFL.txtmarkdown4.3 KB
canvas-fonts/PoiretOne-OFL.txtmarkdown4.3 KB
canvas-fonts/PoiretOne-Regular.ttfbinary44.2 KB
canvas-fonts/RedHatMono-Bold.ttfbinary33.6 KB
canvas-fonts/RedHatMono-OFL.txtmarkdown4.3 KB
canvas-fonts/RedHatMono-Regular.ttfbinary33.7 KB
canvas-fonts/Silkscreen-OFL.txtmarkdown4.3 KB
canvas-fonts/Silkscreen-Regular.ttfbinary31.2 KB
canvas-fonts/SmoochSans-Medium.ttfbinary58.3 KB
canvas-fonts/SmoochSans-OFL.txtmarkdown4.3 KB
canvas-fonts/Tektur-Medium.ttfbinary74.5 KB
canvas-fonts/Tektur-OFL.txtmarkdown4.3 KB
canvas-fonts/Tektur-Regular.ttfbinary73.8 KB
canvas-fonts/WorkSans-Bold.ttfbinary186.8 KB
canvas-fonts/WorkSans-BoldItalic.ttfbinary171.7 KB
canvas-fonts/WorkSans-Italic.ttfbinary170.2 KB
canvas-fonts/WorkSans-OFL.txtmarkdown4.3 KB
canvas-fonts/WorkSans-Regular.ttfbinary184.5 KB
canvas-fonts/YoungSerif-OFL.txtmarkdown4.3 KB
canvas-fonts/YoungSerif-Regular.ttfbinary102.7 KB
references/CUSTOMIZATION.mdmarkdown7.2 KB
references/DESIGN_TOKENS.mdmarkdown4.3 KB
references/INTEGRATION_PATTERNS.mdmarkdown15.0 KB
references/PERFORMANCE_OPTIMIZATION.mdmarkdown7.8 KB
references/RADIX_REFERENCE.mdmarkdown15.1 KB
references/RESPONSIVE_PATTERNS.mdmarkdown4.2 KB
references/SHADCN_REFERENCE.mdmarkdown10.9 KB
references/TAILWIND_REFERENCE.mdmarkdown10.1 KB
references/canvas-design-system.mdmarkdown7.7 KB
scripts/.coverageother52.0 KB
scripts/requirements.txtmanifest444 B
scripts/shadcn_add.pyscript7.8 KB
scripts/tailwind_config_gen.pyscript13.3 KB
scripts/tests/coverage-ui.jsonconfig48.8 KB
scripts/tests/requirements.txtmanifest52 B
scripts/tests/test_shadcn_add.pyscript9.7 KB
scripts/tests/test_tailwind_config_gen.pyscript11.9 KB

references/INTEGRATION_PATTERNS.md

View on GitHub
# Advanced Integration Patterns

Advanced patterns for integrating TailwindCSS, Radix UI, and shadcn/ui in production applications.

## Table of Contents
- [Theme System Architecture](#theme-system-architecture)
- [Component Variant Patterns](#component-variant-patterns)
- [Form Patterns](#form-patterns)
- [Responsive Component Patterns](#responsive-component-patterns)
- [Performance Optimization](#performance-optimization)
- [Testing Strategies](#testing-strategies)

## Theme System Architecture

### CSS Variables + Tailwind Config

```css
/* globals.css */
@layer base {
  :root {
    /* Color primitives */
    --gray-50: 250 250 250;
    --gray-900: 24 24 27;

    /* Semantic tokens */
    --background: var(--gray-50);
    --foreground: var(--gray-900);
    --primary: 222 47% 11%;
    --primary-foreground: 210 40% 98%;
    --destructive: 0 84% 60%;
    --destructive-foreground: 0 0% 98%;

    /* Component tokens */
    --radius: 0.5rem;
    --input-height: 2.5rem;
  }

  .dark {
    --background: var(--gray-900);
    --foreground: var(--gray-50);
    /* ... other dark tokens */
  }
}
```

```typescript
// tailwind.config.ts
export default {
  theme: {
    extend: {
      colors: {
        background: 'hsl(var(--background))',
        foreground: 'hsl(var(--foreground))',
        primary: {
          DEFAULT: 'hsl(var(--primary))',
          foreground: 'hsl(var(--primary-foreground))',
        },
      },
      borderRadius: {
        lg: 'var(--radius)',
        md: 'calc(var(--radius) - 2px)',
        sm: 'calc(var(--radius) - 4px)',
      },
    },
  },
}
```

### Multi-Brand Theme Switching

```tsx
// contexts/theme-context.tsx
export const THEMES = {
  default: {
    primary: '222 47% 11%',
    radius: '0.5rem',
  },
  rounded: {
    primary: '221 83% 53%',
    radius: '1rem',
  },
  sharp: {
    primary: '142 71% 45%',
    radius: '0rem',
  },
}

export function ThemeProvider({ children }) {
  const [theme, setTheme] = useState<keyof typeof THEMES>('default')

  useEffect(() => {
    const root = document.documentElement
    const tokens = THEMES[theme]

    Object.entries(tokens).forEach(([key, value]) => {
      root.style.setProperty(`--${key}`, value)
    })
  }, [theme])

  return (
    <ThemeContext.Provider value={{ theme, setTheme }}>
      {children}
    </ThemeContext.Provider>
  )
}
```

## Component Variant Patterns

### Using Class Variance Authority

```tsx
// components/ui/button.tsx
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"

const buttonVariants = cva(
  // Base styles
  "inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50",
  {
    variants: {
      variant: {
        default: "bg-primary text-primary-foreground hover:bg-primary/90",
        destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
        outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
        secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
        ghost: "hover:bg-accent hover:text-accent-foreground",
        link: "text-primary underline-offset-4 hover:underline",
      },
      size: {
        default: "h-10 px-4 py-2",
        sm: "h-9 rounded-md px-3",
        lg: "h-11 rounded-md px-8",
        icon: "h-10 w-10",
      },
    },
    defaultVariants: {
      variant: "default",
      size: "default",
    },
  }
)

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

export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
  ({ className, variant, size, asChild = false, ...props }, ref) => {
    const Comp = asChild ? Slot : "button"
    return (
      <Comp
        className={cn(buttonVariants({ variant, size, className }))}
        ref={ref}
        {...props}
      />
    )
  }
)
```

### Compound Variants

```tsx
const buttonVariants = cva("base-classes", {
  variants: {
    variant: {
      primary: "bg-primary",
      secondary: "bg-secondary",
    },
    size: {
      small: "text-sm",
      large: "text-lg",
    },
  },
  compoundVariants: [
    {
      variant: "primary",
      size: "large",
      className: "font-bold uppercase", // Only when both match
    },
  ],
})
```

## Form Patterns

### Reusable Form Fields

```tsx
// components/form/form-field-wrapper.tsx
import { UseFormReturn } from "react-hook-form"
import { FormField, FormItem, FormLabel, FormControl, FormDescription, FormMessage } from "@/components/ui/form"

interface FormFieldWrapperProps {
  form: UseFormReturn<any>
  name: string
  label?: string
  description?: string
  required?: boolean
  children: (field: any) => React.ReactNode
}

export function FormFieldWrapper({
  form,
  name,
  label,
  description,
  required,
  children,
}: FormFieldWrapperProps) {
  return (
    <FormField
      control={form.control}
      name={name}
      render={({ field }) => (
        <FormItem>
          {label && (
            <FormLabel>
              {label}
              {required && <span className="text-destructive ml-1">*</span>}
            </FormLabel>
          )}
          <FormControl>{children(field)}</FormControl>
          {description && <FormDescription>{description}</FormDescription>}
          <FormMessage />
        </FormItem>
      )}
    />
  )
}

// Usage
<FormFieldWrapper
  form={form}
  name="email"
  label="Email"
  description="We'll never share your email"
  required
>
  {(field) => <Input type="email" placeholder="you@example.com" {...field} />}
</FormFieldWrapper>
```

### Multi-Step Forms

```tsx
// components/form/multi-step-form.tsx
export function MultiStepForm() {
  const [step, setStep] = useState(1)
  const form = useForm<z.infer<typeof schema>>({
    resolver: zodResolver(schema),
  })

  const steps = [
    { title: "Personal Info", fields: ["name", "email"] },
    { title: "Address", fields: ["street", "city"] },
    { title: "Confirmation", fields: [] },
  ]

  function onSubmit(data: z.infer<typeof schema>) {
    if (step < steps.length) {
      setStep(step + 1)
      return
    }
    // Final submission
    console.log(data)
  }

  return (
    <Form {...form}>
      <form onSubmit={form.handleSubmit(onSubmit)}>
        {/* Progress indicator */}
        <div className="flex gap-2 mb-8">
          {steps.map((s, i) => (
            <div
              key={i}
              className={cn(
                "h-2 flex-1 rounded-full",
                i < step ? "bg-primary" : "bg-gray-200"
              )}
            />
          ))}
        </div>

        {/* Step content */}
        {step === 1 && <Step1Fields form={form} />}
        {step === 2 && <Step2Fields form={form} />}
        {step === 3 && <Step3Summary form={form} />}

        {/* Navigation */}
        <div className="flex justify-between mt-8">
          {step > 1 && (
            <Button type="button" variant="outline" onClick={() => setStep(step - 1)}>
              Back
            </Button>
          )}
          <Button type="submit">
            {step < steps.length ? "Next" : "Submit"}
          </Button>
        </div>
      </form>
    </Form>
  )
}
```

## Responsive Component Patterns

### Responsive Dialog/Drawer

```tsx
// components/responsive-dialog.tsx
import { useMediaQuery } from "@/hooks/use-media-query"
import { Dialog, DialogContent } from "@/components/ui/dialog"
import { Drawer, DrawerContent } from "@/components/ui/drawer"

interface ResponsiveDialogProps {
  children: React.ReactNode
  open?: boolean
  onOpenChange?: (open: boolean) => void
}

export function ResponsiveDialog({
  children,
  open,
  onOpenChange,
}: ResponsiveDialogProps) {
  const isDesktop = useMediaQuery("(min-width: 768px)")

  if (isDesktop) {
    return (
      <Dialog open={open} onOpenChange={onOpenChange}>
        <DialogContent className="sm:max-w-[425px]">{children}</DialogContent>
      </Dialog>
    )
  }

  return (
    <Drawer open={open} onOpenChange={onOpenChange}>
      <DrawerContent>{children}</DrawerContent>
    </Drawer>
  )
}

// Usage
<ResponsiveDialog>
  <DialogHeader>
    <DialogTitle>Edit Profile</DialogTitle>
  </DialogHeader>
  {/* Content works for both dialog and drawer */}
</ResponsiveDialog>
```

### Responsive Navigation

```tsx
// components/nav.tsx
export function Navigation() {
  const [mobileMenuOpen, setMobileMenuOpen] = useState(false)

  return (
    <>
      {/* Desktop nav */}
      <nav className="hidden md:flex items-center gap-6">
        <NavLink href="/">Home</NavLink>
        <NavLink href="/about">About</NavLink>
        <NavLink href="/contact">Contact</NavLink>
      </nav>

      {/* Mobile menu button */}
      <Button
        variant="ghost"
        size="icon"
        className="md:hidden"
        onClick={() => setMobileMenuOpen(true)}
      >
        <MenuIcon />
      </Button>

      {/* Mobile sheet */}
      <Sheet open={mobileMenuOpen} onOpenChange={setMobileMenuOpen}>
        <SheetContent side="left">
          <nav className="flex flex-col gap-4">
            <NavLink href="/" onClick={() => setMobileMenuOpen(false)}>
              Home
            </NavLink>
            <NavLink href="/about" onClick={() => setMobileMenuOpen(false)}>
              About
            </NavLink>
          </nav>
        </SheetContent>
      </Sheet>
    </>
  )
}
```

## Performance Optimization

### Code Splitting Components

```tsx
// Lazy load heavy components
import { lazy, Suspense } from 'react'
import { Skeleton } from '@/components/ui/skeleton'

const DataTable = lazy(() => import('@/components/data-table'))
const Chart = lazy(() => import('@/components/chart'))

export function Dashboard() {
  return (
    <div className="space-y-8">
      <Suspense fallback={<Skeleton className="h-[400px] w-full" />}>
        <DataTable />
      </Suspense>

      <Suspense fallback={<Skeleton className="h-[300px] w-full" />}>
        <Chart />
      </Suspense>
    </div>
  )
}
```

### Virtualized Lists

```tsx
// components/virtualized-list.tsx
import { useVirtualizer } from '@tanstack/react-virtual'
import { useRef } from 'react'

export function VirtualizedList({ items }: { items: any[] }) {
  const parentRef = useRef<HTMLDivElement>(null)

  const virtualizer = useVirtualizer({
    count: items.length,
    getScrollElement: () => parentRef.current,
    estimateSize: () => 50, // Estimated row height
    overscan: 5, // Render extra items off-screen
  })

  return (
    <div ref={parentRef} className="h-[600px] overflow-auto">
      <div
        style={{
          height: `${virtualizer.getTotalSize()}px`,
          position: 'relative',
        }}
      >
        {virtualizer.getVirtualItems().map((virtualRow) => (
          <div
            key={virtualRow.index}
            style={{
              position: 'absolute',
              top: 0,
              left: 0,
              width: '100%',
              height: `${virtualRow.size}px`,
              transform: `translateY(${virtualRow.start}px)`,
            }}
          >
            <ListItem item={items[virtualRow.index]} />
          </div>
        ))}
      </div>
    </div>
  )
}
```

### Optimizing Tailwind Bundle

```javascript
// tailwind.config.ts
export default {
  // Only scan files that use Tailwind
  content: [
    './app/**/*.{ts,tsx}',
    './components/**/*.{ts,tsx}',
    // Don't scan node_modules except specific packages
    './node_modules/@my-company/ui/**/*.{ts,tsx}',
  ],

  // Remove unused variants
  corePlugins: {
    float: false,
    objectFit: false,
    objectPosition: false,
    // ... disable unused utilities
  },
}
```

## Testing Strategies

### Component Testing with Testing Library

```tsx
// __tests__/button.test.tsx
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { Button } from '@/components/ui/button'

describe('Button', () => {
  it('renders correctly', () => {
    render(<Button>Click me</Button>)
    expect(screen.getByRole('button', { name: /click me/i })).toBeInTheDocument()
  })

  it('calls onClick when clicked', async () => {
    const handleClick = jest.fn()
    render(<Button onClick={handleClick}>Click me</Button>)

    await userEvent.click(screen.getByRole('button'))
    expect(handleClick).toHaveBeenCalledTimes(1)
  })

  it('is disabled when disabled prop is true', () => {
    render(<Button disabled>Click me</Button>)
    expect(screen.getByRole('button')).toBeDisabled()
  })
})
```

### Accessibility Testing

```tsx
// __tests__/dialog.test.tsx
import { render, screen } from '@testing-library/react'
import { axe, toHaveNoViolations } from 'jest-axe'
import { Dialog, DialogContent, DialogTrigger } from '@/components/ui/dialog'

expect.extend(toHaveNoViolations)

describe('Dialog accessibility', () => {
  it('should not have accessibility violations', async () => {
    const { container } = render(
      <Dialog>
        <DialogTrigger>Open</DialogTrigger>
        <DialogContent>Content</DialogContent>
      </Dialog>
    )

    const results = await axe(container)
    expect(results).toHaveNoViolations()
  })

  it('traps focus within dialog', async () => {
    render(
      <Dialog open>
        <DialogContent>
          <button>First</button>
          <button>Last</button>
        </DialogContent>
      </Dialog>
    )

    const first = screen.getByRole('button', { name: /first/i })
    const last = screen.getByRole('button', { name: /last/i })

    // Tab through and verify focus trap
    first.focus()
    await userEvent.tab()
    expect(last).toHaveFocus()
    await userEvent.tab()
    expect(first).toHaveFocus() // Should loop back
  })
})
```

### Visual Regression Testing

```tsx
// __tests__/visual/button.stories.tsx
import type { Meta, StoryObj } from '@storybook/react'
import { Button } from '@/components/ui/button'

const meta: Meta<typeof Button> = {
  title: 'UI/Button',
  component: Button,
}

export default meta
type Story = StoryObj<typeof Button>

export const AllVariants: Story = {
  render: () => (
    <div className="flex flex-col gap-4">
      <Button variant="default">Default</Button>
      <Button variant="secondary">Secondary</Button>
      <Button variant="destructive">Destructive</Button>
      <Button variant="outline">Outline</Button>
      <Button variant="ghost">Ghost</Button>
    </div>
  ),
}
```

## Best Practices Summary

1. **Theme System**: Use CSS variables + Tailwind config for flexible theming
2. **Component Variants**: Use CVA for type-safe variant management
3. **Forms**: Create reusable field wrappers, use Zod for validation
4. **Responsive**: Build mobile-first, use media queries or responsive components
5. **Performance**: Code split, virtualize large lists, optimize Tailwind
6. **Testing**: Test behavior, accessibility, and visual regressions
7. **Composition**: Build complex components from simple primitives
8. **Customization**: Modify shadcn/ui components directly (you own the code)

---

These patterns provide a solid foundation for building production-ready applications with the modern UI stack.
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall