Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
AI-powered design system generator that produces complete, tailored design systems from project requirements.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/states-and-variants.md
1# States and Variants23Component state definitions and variant patterns.45## Interactive States67### State Definitions89| State | Trigger | Visual Change |10|-------|---------|---------------|11| default | None | Base appearance |12| hover | Mouse over | Slight color shift |13| focus | Tab/click | Focus ring |14| active | Mouse down | Darkest color |15| disabled | disabled attr | Reduced opacity |16| loading | Async action | Spinner + opacity |1718### State Priority1920When multiple states apply, priority (highest to lowest):21221. disabled232. loading243. active254. focus265. hover276. default2829### State Transitions3031```css32/* Standard transition for interactive elements */33.interactive {34transition-property: color, background-color, border-color, box-shadow;35transition-duration: var(--duration-fast);36transition-timing-function: ease-in-out;37}38```3940| Transition | Duration | Easing |41|------------|----------|--------|42| Color changes | 150ms | ease-in-out |43| Background | 150ms | ease-in-out |44| Transform | 200ms | ease-out |45| Opacity | 150ms | ease |46| Shadow | 200ms | ease-out |4748## Focus States4950### Focus Ring Spec5152```css53/* Standard focus ring */54.focusable:focus-visible {55outline: none;56box-shadow: 0 0 0 var(--ring-offset) var(--color-background),570 0 0 calc(var(--ring-offset) + var(--ring-width)) var(--ring-color);58}59```6061| Property | Value |62|----------|-------|63| Ring width | 2px |64| Ring offset | 2px |65| Ring color | primary (blue-500) |66| Offset color | background |6768### Focus Within6970```css71/* Container focus when child is focused */72.container:focus-within {73border-color: var(--color-ring);74}75```7677## Disabled States7879### Visual Treatment8081```css82.disabled {83opacity: var(--opacity-disabled); /* 0.5 */84pointer-events: none;85cursor: not-allowed;86}87```8889| Property | Disabled Value |90|----------|----------------|91| Opacity | 50% |92| Pointer events | none |93| Cursor | not-allowed |94| Background | muted |95| Color | muted-foreground |9697### Accessibility9899- Use `aria-disabled="true"` for semantic disabled100- Use `disabled` attribute for form elements101- Maintain sufficient contrast (3:1 minimum)102103## Loading States104105### Spinner Placement106107| Component | Spinner Position |108|-----------|------------------|109| Button | Replace icon or center |110| Input | Trailing position |111| Card | Center overlay |112| Page | Center of viewport |113114### Loading Treatment115116```css117.loading {118position: relative;119pointer-events: none;120}121122.loading::after {123content: '';124/* spinner styles */125}126127.loading > * {128opacity: 0.7;129}130```131132## Error States133134### Visual Indicators135136```css137.error {138border-color: var(--color-error);139color: var(--color-error);140}141142.error:focus-visible {143box-shadow: 0 0 0 2px var(--color-background),1440 0 0 4px var(--color-error);145}146```147148| Element | Error Treatment |149|---------|-----------------|150| Input border | red-500 |151| Input focus ring | red/20% |152| Helper text | red-600 |153| Icon | red-500 |154155### Error Messages156157- Position below input158- Use error color159- Include icon for accessibility160- Clear on valid input161162## Variant Patterns163164### Color Variants165166```css167/* Pattern for color variants */168.component {169--component-bg: var(--color-primary);170--component-fg: var(--color-primary-foreground);171background: var(--component-bg);172color: var(--component-fg);173}174175.component.secondary {176--component-bg: var(--color-secondary);177--component-fg: var(--color-secondary-foreground);178}179180.component.destructive {181--component-bg: var(--color-destructive);182--component-fg: var(--color-destructive-foreground);183}184```185186### Size Variants187188```css189/* Pattern for size variants */190.component {191--component-height: 40px;192--component-padding: var(--space-4);193--component-font: var(--font-size-sm);194}195196.component.sm {197--component-height: 32px;198--component-padding: var(--space-3);199--component-font: var(--font-size-xs);200}201202.component.lg {203--component-height: 48px;204--component-padding: var(--space-6);205--component-font: var(--font-size-base);206}207```208209## Accessibility Requirements210211### Color Contrast212213| Element | Minimum Ratio |214|---------|---------------|215| Normal text | 4.5:1 |216| Large text (18px+) | 3:1 |217| UI components | 3:1 |218| Focus indicator | 3:1 |219220### State Indicators221222- Never rely on color alone223- Use icons, text, or patterns224- Ensure focus is visible225- Provide loading announcements226227### ARIA States228229```html230<!-- Disabled -->231<button disabled aria-disabled="true">Submit</button>232233<!-- Loading -->234<button aria-busy="true" aria-describedby="loading-text">235<span id="loading-text" class="sr-only">Loading...</span>236</button>237238<!-- Error -->239<input aria-invalid="true" aria-describedby="error-msg">240<span id="error-msg" role="alert">Error message</span>241```242