UI Library Hardening
sharedKeep @athas/ui stable, accessible, and reusable across apps.
Hardening goals
- stable public exports
- predictable variant behavior where variants are needed
- accessibility and styling consistency
- complete Storybook coverage for reusable components
Rules
- Export intentionally from
libs/ui/src/index.ts. - Add variants only when a component has real usage pressure for multiple visual states.
- Use
cva+defaultVariantsfor variantable primitives. - Keep
data-slotmarkers and focus/ARIA behavior intact. - Keep business/domain logic out of shared UI components.
- Validate in both admin and client apps before merge.
Storybook policy
- Every reusable UI or app-shell component in
libs/ui/src/componentsshould have a colocated*.stories.tsxfile. - Stories should cover at least default state and one meaningful alternate/edge state.
- Prefer composition stories for higher-level app components (
app-shell,billing,feedback) to catch integration-level drift early.
Performance checks
- Build and snapshot Storybook metrics with:
bun run storybook:perf
bun run storybook:perf:enforce- The report is written to
docs/performance/storybook-latest.md. - Budget thresholds are defined in
docs/performance/budgets.json. - Metrics are file-output based, so this works with Storybook 10.
Current variant baseline
Button:default|outline|secondary|ghost|destructive|linkBadge:default|secondary|destructive|outline|ghost|linkAlert:default|destructiveButtonGroup:horizontal|verticalEmptyMedia:default|icon