Component Library
The@bitwarden/components library is Bitwarden’s comprehensive Angular component library, providing a consistent design system and reusable UI components across all client applications.
Overview
The component library provides:- 50+ Production-ready components - Buttons, forms, dialogs, tables, and more
- Storybook integration - Interactive component documentation and testing
- Tailwind CSS styling - Modern utility-first CSS framework
- Accessibility (a11y) - WCAG-compliant components
- Responsive design - Mobile-first, adaptive layouts
- Angular integration - Built specifically for Angular applications
Installation
Components are imported from@bitwarden/components:
Storybook
The component library uses Storybook for interactive component documentation and development.Running Storybook
http://localhost:6006 and includes:
- Live component previews
- Interactive props/controls
- Component documentation
- Accessibility testing
- Design system guidelines
Storybook Configuration
Location:.storybook/main.ts
The Storybook configuration includes:
- Stories from multiple libraries (
auth,components,vault, etc.) - Accessibility addon (a11y)
- Design addon for Figma integration
- Theme support
- MDX documentation support with GitHub Flavored Markdown
Component Categories
Form Components
Input Controls:- Button (
button/) - Primary, secondary, danger variants with loading states - Input (
input/) - Text inputs with validation - Checkbox (
checkbox/) - Checkbox controls - Radio Button (
radio-button/) - Radio button groups - Select (
select/) - Dropdown select menus - Multi Select (
multi-select/) - Multi-selection dropdowns - Chip Select (
chip-select/) - Tag-based selection - Switch (
switch/) - Toggle switches - Search (
search/) - Search input components
- Form Field (
form-field/) - Form field wrapper with labels and hints - Form Control (
form-control/) - Form control base - Form (
form/) - Form container and validation
Layout Components
Containers:- Container (
container/) - Content containers - Card (
card/) - Card layouts - Section (
section/) - Content sections - Layout (
layout/) - Page layouts - Header (
header/) - Page headers
- Navigation (
navigation/) - Navigation components - Tabs (
tabs/) - Tab navigationTabGroupComponent- Tab containerTabNavBarComponent- Navigation-based tabsTabComponent- Individual tab
- Breadcrumbs (
breadcrumbs/) - Breadcrumb navigation - Menu (
menu/) - Dropdown menus
- Anon Layout (
anon-layout/) - Anonymous/login layouts - Landing Layout (
landing-layout/) - Marketing page layouts
Feedback Components
Notifications:- Toast (
toast/) - Toast notification systemToastService- Programmatic toast management- Auto-dismiss and manual dismiss options
- Banner (
banner/) - Alert banners - Callout (
callout/) - Highlighted information boxes
- Spinner (
spinner/) - Loading spinners - Progress (
progress/) - Progress bars - Skeleton (
skeleton/) - Skeleton loading screens
- Dialog (
dialog/) - Modal dialogsDialogService- Programmatic dialog management- Confirmation dialogs
- Custom content dialogs
- Popover (
popover/) - Contextual popovers - Tooltip (
tooltip/) - Hover tooltips
Data Display Components
Tables:- Table (
table/) - Data tablesTableComponent- Base tableTableScrollComponent- Scrollable tablesTableDataSource- Data source abstractionSortableComponent- Sortable columns- Row and cell directives
- Badge List (
badge-list/) - Badge collections - Item (
item/) - List items - No Items (
no-items/) - Empty state component
- Avatar (
avatar/) - User avatars - Badge (
badge/) - Status badges - Icon (
icon/) - Icon system - Icon Button (
icon-button/) - Icon-only buttons - Icon Tile (
icon-tile/) - Icon tiles - SVG (
svg/) - SVG components
Utility Components
Interactions:- Async Actions (
async-actions/) - Async action handling - Copy Click (
copy-click/) - Click-to-copy functionality - Disclosure (
disclosure/) - Expandable/collapsible content - Toggle Group (
toggle-group/) - Toggle button groups
- Color Password (
color-password/) - Password strength visualization - Stepper (
stepper/) - Multi-step wizards - Berry (
berry/) - Special UI element
- Resize Observer (
resize-observer/) - Element resize detection
Accessibility (a11y)
Location:libs/components/src/a11y/
Accessibility utilities and directives:
Styling System
Tailwind CSS
Components use Tailwind CSS for styling: Configuration Files:tailwind.config.js- Main Tailwind configurationtailwind.config.base.js- Base configurationtw-theme.css- Theme definitionstw-theme-preflight.css- Preflight/reset styles
Theme System
Styles:theme.css- Component theme variablesvariables.scss- SCSS variables
- Typography Module (
typography/) - Typography directives and styles - Web fonts (Inter) included in
webfonts/
Utilities
Location:libs/components/src/utils/
Utility functions and helpers:
- DOM Observables (
dom-observables.ts) - DOM event observables - Function to Observable (
function-to-observable.ts) - Convert functions to observables - Has Scrollable Content (
has-scrollable-content.ts) - Detect scrollable elements - Has Scrolled From (
has-scrolled-from.ts) - Scroll position detection - Responsive Utils (
responsive-utils.ts) - Responsive design utilities - I18n Mock Service (
i18n-mock.service.ts) - Testing utilities - State Mock (
state-mock.ts) - State mocking for tests
Component Structure
Typical component directory structure:Component Example
Location:libs/components/src/button/button.component.ts
Testing
Unit Tests
Testing Utilities
Mock services for testing:i18n-mock.service.ts- Mock internationalizationstate-mock.ts- Mock state management
Storybook Stories
Stories are located alongside components with.stories.ts extension.
Story Example
Documentation Stories
Location:libs/components/src/stories/
Special documentation pages:
introduction.mdx- Component library introductioncolors.mdx- Color system documentationcompact-mode.mdx- Compact mode guidemigration.mdx- Migration guidesresponsive-design.mdx- Responsive design patternsvirtual-scrolling.mdx- Virtual scrolling guideicons/- Icon system documentationkitchen-sink/- Component showcase
Best Practices
Component Usage
-
Use standalone components:
- Modern Angular components are standalone
- Import directly where needed
-
Leverage TypeScript types:
- Use
ButtonType,ButtonSizeenums - Strong typing prevents errors
- Use
-
Follow accessibility guidelines:
- Use semantic HTML
- Include ARIA labels where needed
- Test with screen readers
Styling
-
Use Tailwind utilities:
- Prefer utility classes over custom CSS
- Follow established design tokens
-
Maintain consistency:
- Use existing components before creating new ones
- Follow the design system
Storybook Development
-
Document all component variants:
- Create stories for each state (loading, disabled, etc.)
- Include edge cases
-
Write MDX documentation:
- Explain component purpose and usage
- Provide code examples
- Document props and events
Building and Deployment
Integration Examples
Dialog Service
Table Data Source
Related Libraries
- Platform Library - Platform abstractions and services
- State Management - State provider framework
@bitwarden/auth- Authentication components@bitwarden/vault- Vault UI components
Source Code
- Components Library:
libs/components/src/ - Storybook Config:
.storybook/ - Component Stories:
libs/components/src/*/*.stories.ts - Documentation:
libs/components/src/*/*.mdx