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/CUSTOMIZATION.md

View on GitHub
# Component Customization & Theming

## Component Customization Strategies

### Strategy 1: Direct Modification
shadcn/ui components live in your codebase - full ownership.

**Approach:**
- Edit files in `components/ui/` directly
- Add new variants with CVA (Class Variance Authority)
- Modify default styles
- You own the code - complete control

**When to use:**
- Project-specific components
- Unique design requirements
- Custom behavior needed

### Strategy 2: Variant Extension
Use Class Variance Authority (CVA) for type-safe variants.

**Example:**
```tsx
const buttonVariants = cva(
  "inline-flex items-center justify-center rounded-md",
  {
    variants: {
      variant: {
        default: "bg-primary text-primary-foreground",
        destructive: "bg-destructive text-destructive-foreground",
        outline: "border border-input bg-background",
        ghost: "hover:bg-accent hover:text-accent-foreground",
      },
      size: {
        default: "h-10 px-4 py-2",
        sm: "h-9 rounded-md px-3",
        lg: "h-11 rounded-md px-8",
      },
    },
    defaultVariants: {
      variant: "default",
      size: "default",
    },
  }
)
```

**Benefits:**
- Type-safe component props
- Consistent variant patterns
- Easy to extend
- Compound variants for combinations

### Strategy 3: Wrapper Components
Create higher-level components with custom logic.

**Approach:**
- Wrap shadcn/ui components with custom components
- Add default props and behaviors
- Enforce design system constraints
- Add project-specific logic

**Example:**
```tsx
export function PrimaryButton({ children, ...props }) {
  return (
    <Button
      variant="default"
      size="lg"
      className="font-semibold"
      {...props}
    >
      {children}
    </Button>
  )
}
```

### Strategy 4: Theme Customization
Modify design tokens globally.

**Approach:**
- Change colors, spacing, typography in CSS variables
- Affects all components automatically
- Maintain consistency across application
- Single source of truth

**Example:**
```css
:root {
  --primary: 220 90% 56%;
  --radius: 0.5rem;
}
```

## Dark Mode Implementation

### Setup Requirements

#### 1. ThemeProvider
Wrap app with next-themes provider:
```tsx
import { ThemeProvider } from "next-themes"

export default function RootLayout({ children }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body>
        <ThemeProvider
          attribute="class"
          defaultTheme="system"
          enableSystem
          disableTransitionOnChange
        >
          {children}
        </ThemeProvider>
      </body>
    </html>
  )
}
```

#### 2. Class Strategy
Use `class` dark mode (not media query):
```js
// tailwind.config.js
module.exports = {
  darkMode: 'class', // not 'media'
}
```

#### 3. Hydration Fix
Add `suppressHydrationWarning` to `<html>`:
```tsx
<html lang="en" suppressHydrationWarning>
```

#### 4. CSS Variables
Define dark mode tokens in `.dark` class:
```css
:root {
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
}

.dark {
  --background: 222.2 84% 4.9%;
  --foreground: 210 40% 98%;
}
```

### Design Considerations

#### Contrast Requirements
- **Test all components in both modes**
- **Ensure WCAG AA minimum** (4.5:1 text, 3:1 UI)
- **Verify focus indicators** remain visible
- **Check disabled states** have sufficient contrast

#### Color Strategy
- **Use semantic tokens**: `background`, `foreground`, not color names
- **Test gradients**: May need different values per theme
- **Image handling**: Consider dark mode versions of images
- **Chart colors**: Adjust for legibility in both modes

#### Transitions
Smooth theme switching:
```css
* {
  transition: background-color 0.2s, color 0.2s;
}
```

Disable during switch to prevent flash:
```tsx
<ThemeProvider disableTransitionOnChange>
```

### Toggle Component

#### Requirements
- **Show current theme state** (sun/moon icon)
- **Keyboard accessible** (Space/Enter to toggle)
- **Visible focus indicator**
- **System preference detection**

#### Example Implementation
```tsx
import { Moon, Sun } from "lucide-react"
import { useTheme } from "next-themes"

export function ThemeToggle() {
  const { theme, setTheme } = useTheme()

  return (
    <Button
      variant="ghost"
      size="icon"
      onClick={() => setTheme(theme === "light" ? "dark" : "light")}
    >
      <Sun className="h-5 w-5 rotate-0 scale-100 dark:-rotate-90 dark:scale-0" />
      <Moon className="absolute h-5 w-5 rotate-90 scale-0 dark:rotate-0 dark:scale-100" />
      <span className="sr-only">Toggle theme</span>
    </Button>
  )
}
```

### Testing Checklist
- [ ] All components visible in both modes
- [ ] Text contrast meets WCAG AA (4.5:1)
- [ ] UI components meet WCAG AA (3:1)
- [ ] Focus indicators visible in both modes
- [ ] Images appropriate for both modes
- [ ] Gradients work in both modes
- [ ] System preference detected correctly
- [ ] Toggle component keyboard accessible
- [ ] No flash of wrong theme on load
- [ ] Transitions smooth and performant

## Form Architecture

### Validation Strategy: React Hook Form + Zod

#### Benefits
- **Schema-first validation** with type inference
- **Unified error handling** and display
- **Accessible error messages**
- **Performance optimized** (minimal re-renders)

#### Setup
```tsx
import { useForm } from "react-hook-form"
import { zodResolver } from "@hookform/resolvers/zod"
import * as z from "zod"

const formSchema = z.object({
  username: z.string().min(2, {
    message: "Username must be at least 2 characters.",
  }),
  email: z.string().email({
    message: "Please enter a valid email address.",
  }),
})

export function ProfileForm() {
  const form = useForm<z.infer<typeof formSchema>>({
    resolver: zodResolver(formSchema),
    defaultValues: {
      username: "",
      email: "",
    },
  })

  function onSubmit(values: z.infer<typeof formSchema>) {
    console.log(values)
  }

  return (
    <Form {...form}>
      <form onSubmit={form.handleSubmit(onSubmit)}>
        {/* form fields */}
      </form>
    </Form>
  )
}
```

### Reusable Patterns

#### Field Wrappers
Consistent field structure:
```tsx
<FormField
  control={form.control}
  name="username"
  render={({ field }) => (
    <FormItem>
      <FormLabel>Username</FormLabel>
      <FormControl>
        <Input {...field} />
      </FormControl>
      <FormDescription>
        This is your public display name.
      </FormDescription>
      <FormMessage />
    </FormItem>
  )}
/>
```

#### Required Indicators
Clear visual indication:
```tsx
<FormLabel>
  Email <span className="text-destructive">*</span>
</FormLabel>
```

#### Multi-Step Forms
Progress tracking:
```tsx
const [step, setStep] = useState(1)

<div className="mb-8">
  <Progress value={(step / totalSteps) * 100} />
  <p className="text-sm text-muted-foreground mt-2">
    Step {step} of {totalSteps}
  </p>
</div>
```

### Accessibility Requirements
- [ ] Associate labels with inputs (`htmlFor`, `id`)
- [ ] Provide error messages with `aria-describedby`
- [ ] Mark required fields (`aria-required`, `required`)
- [ ] Use appropriate input types (`email`, `tel`, `number`)
- [ ] Include helpful descriptions (`FormDescription`)
- [ ] Ensure keyboard navigation works
- [ ] Validate on blur for immediate feedback
- [ ] Submit on Enter key press
- [ ] Focus first error on submit
- [ ] Announce errors to screen readers
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