A modern, accessible design system built with Radix UI primitives, CSS Modules, and design tokens. This system provides a comprehensive set of reusable components and design tokens to ensure consistency across Buffer's products.
- π¨ Design Tokens: JSON-based token system for consistent design values
- βΏ Accessibility First: Built on Radix UI primitives with WCAG 2.1 AA compliance
- π― CSS Modules: Scoped styling with better performance
- π Storybook Integration: Interactive documentation and component playground
- π§ TypeScript: Full type safety and IntelliSense support
- π§ͺ Comprehensive Testing: Unit tests, accessibility tests, and visual regression testing
- π± Responsive Design: Mobile-first approach with flexible layouts
npm install @buffer/design-systemimport { Button, Input, Select } from '@buffer/design-system'
import '@buffer/design-system/styles'
function App() {
return (
<div>
<Button variant="primary" size="medium">
Click me
</Button>
<Input placeholder="Enter your name" />
<Select>
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
</Select>
</div>
)
}Access design tokens directly in your applications:
import { tokens } from '@buffer/design-system'
const customStyles = {
color: tokens.color.brand.primary,
spacing: tokens.spacing.medium,
fontSize: tokens.typography.size.body
}- Button - Primary, secondary, and ghost variants with multiple sizes
- Input - Text input with validation states and icons
- Select - Dropdown select with search and multi-select support
- Checkbox - Accessible checkbox with indeterminate state
- Badge - Status indicators and labels
- Modal/Dialog - Accessible modal dialogs with overlay management
- Card - Content containers with consistent spacing and elevation
- Node.js 20.0.0 or higher
- npm 8.0.0 or higher
- Clone the repository:
git clone https://github.com/carolinapowers/design-system.git
cd design-system- Install dependencies:
npm install- Start the development server:
npm run dev- Launch Storybook for component development:
npm run storybook| Command | Description |
|---|---|
npm run dev |
Start Vite development server |
npm run build |
Build the component library |
npm run build-tokens |
Generate design tokens from JSON |
npm run test |
Run unit tests |
npm run test:coverage |
Run tests with coverage report |
npm run test:watch |
Run tests in watch mode |
npm run typecheck |
Run TypeScript type checking |
npm run lint |
Run ESLint |
npm run lint:fix |
Fix ESLint errors automatically |
npm run storybook |
Launch Storybook development server |
npm run build-storybook |
Build Storybook for production |
npm run chromatic |
Run visual regression tests |
src/
βββ tokens/ # Design tokens (JSON-based)
β βββ colors.json
β βββ typography.json
β βββ spacing.json
β βββ build.ts
βββ components/ # Component library
β βββ primitives/ # Basic UI components
β βββ composite/ # Complex components
β βββ layout/ # Layout components
βββ styles/ # Global styles and utilities
β βββ globals.css
β βββ tokens.css
β βββ utilities.module.css
βββ utils/ # Utility functions
βββ cn.ts # Class name utility
- React - Component framework
- TypeScript - Type safety and developer experience
- Radix UI - Accessible primitive components
- CSS Modules - Scoped styling
- Vite - Build tool and development server
- Vitest - Unit testing framework
- Storybook - Component documentation and development
- ESLint - Code linting and formatting
The design system uses a token-based approach for maintaining design consistency:
{
"color": {
"brand": {
"primary": "#168bf8",
"secondary": "#f3f4f6"
},
"semantic": {
"success": "#10b981",
"warning": "#f59e0b",
"error": "#ef4444"
}
},
"spacing": {
"xs": "0.25rem",
"sm": "0.5rem",
"md": "1rem",
"lg": "1.5rem",
"xl": "2rem"
}
}Tokens are automatically converted to CSS custom properties and TypeScript constants.
The design system includes comprehensive testing strategies:
- Unit Tests: Component behavior and logic testing with Vitest
- Accessibility Tests: Automated a11y testing with axe-core
- Visual Regression: Chromatic integration for visual testing
- Type Checking: TypeScript compilation verification
Run all tests:
npm run test- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes following the established patterns
- Add tests for new functionality
- Run the test suite:
npm run test - Run type checking:
npm run typecheck - Run linting:
npm run lint:fix - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow existing patterns: Use established component structure and naming conventions
- Include comprehensive tests: Add unit tests and stories for all components
- Ensure accessibility: Verify WCAG 2.1 AA compliance
- Use design tokens: Leverage the token system for consistent styling
- Document thoroughly: Include JSDoc comments and Storybook stories
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
MIT Β© Buffer