UX system
The Baseleg UX system defines the approved building blocks for all UI work: design tokens, components, and composition patterns. Its purpose is to prevent styling drift, keep UI decisions explicit and reviewable, and give every contributor a shared visual language.
Principles
- Token-first: every colour, spacing value, radius, and shadow must come from a design token, not a hardcoded value.
- Component-first: before writing custom UI, check if a component in
@baseleg/uialready covers the need. - Pattern-explicit: interaction patterns (empty states, loading, errors) are documented and consistent across the product.
- Minimal surface: prefer a small set of well-understood components over a large library of one-offs.
Rules
- Use
@baseleg/uicomponents first. Only build custom UI when no existing component fits. - All colours, spacing, typography, radius, and shadow values must use tokens. Do not hardcode e.g.
#1e40afor16pxdirectly. - Every new reusable component must be added to
@baseleg/uiand documented in this section. - New component libraries (external) require an ADR before adoption.
- Every view must implement loading, empty, error, and success states — see the empty / loading / error pattern.
Structure
| Section | Purpose |
|---|---|
| Design tokens | Colour palette, spacing scale, typography, radius, shadows |
| Standards | Rules for using the UI system in product code |
| Components | Individual component specifications and variants |
| Patterns | Composition patterns: empty/loading/error, page shells |
| Diagrams | Architecture and domain diagrams |
How to document a new component
When adding a reusable component to @baseleg/ui:
- Implement it in
packages/ui/. - Create a page in
docs/ux/components/<name>.md. - Include: purpose and usage guidance, props/variants API, do/don’t examples, accessibility notes, and all required states (loading, empty, error, success where applicable).
When to raise an ADR
Raise an ADR before:
- Adding an external component library (e.g. Headless UI, Radix, shadcn/ui).
- Introducing a new approach to icons, animations, or custom CSS outside the token system.
- Making breaking changes to the token scale that would require updating many components.