The components.build project follows a set of core principles designed to ensure that UI components are high-quality, accessible, and developer-friendly. When building or consuming components within this ecosystem, adhere to these mental models:
Composition and Reusability
Prefer composition over inheritance. Build components that can be combined and nested to create complex UIs. Use clear APIs (via props or slots) to allow developers to inject child elements or callbacks, enabling customization of behavior and appearance without deep class hierarchies.
Accessibility by Default
Components must be usable by everyone from the start.
- Use semantic HTML (e.g.,
<button> for actions, <ul>/<li> for lists). - Extend with WAI-ARIA attributes where necessary.
- Support keyboard navigation and focus management (e.g., arrow key navigation in menus, focus traps in modals).
- Ensure correct ARIA roles/states and test with screen readers.
Customizability and Theming
Avoid hardcoding visual styles that cannot be overridden. Components should be easy to restyle to fit any design system. Recommended mechanisms include:
- CSS variables
- Well-documented class names
- Style props
- Providing sensible defaults while allowing overrides via
className or design tokens.
Lightweight and Performance-Oriented
Keep components lean to ensure fast rendering and interaction.
- Minimize large library dependencies.
- Minimize unnecessary re-renders.
- For data-intensive components (like large lists or tables), use patterns like virtualization or incremental rendering, but keep these features optional to avoid bloat.
Transparency and Code Ownership
Follow an 'open-source first' mentality. Components should not be 'black boxes'. Developers should be able to see how a component works and modify it if necessary. This supports the 'copy-and-paste' distribution model. Even when distributed via a package, provide source maps, readable code, and thorough documentation.
Documentation and Developer Experience (DX)
A component is only as good as its documentation. To ensure high DX, always document:
- The purpose of the component.
- All available props.
- Usage examples.
- Accessibility notes (keyboard controls, ARIA attributes).
- Customization options.