Overview
Component libraries centralize reusable UI elements with clear variants, documentation, and code-to-design mapping for collaborative teams.
Component Structure
### Component Organization
- Group by category: Buttons, Forms, Cards, Navigation, Feedback
- Create main component with all variants
- Use component variants for different states: default, hover, active, disabled, loading
- Create variants per size: sm, md, lg
- Document variant naming consistently
### Component Hierarchy
- Base components: Button, Input, Icon (atomic)
- Compound components: Form Group, Card with Header (molecules)
- Template components: Signup Form, Product Card (organisms)
- Page templates: Landing page structure
- Layer components logically for easy discovery
### Main Component Setup
- Set main component at page top with clear naming
- Include all possible variants in single main component
- Document which variant combinations are valid
- Use annotations for component behavior
- Lock main component to prevent accidental edits
Variant Strategy
### Size Variants
- Small (sm): Compact UI, secondary actions
- Medium (md): Default, primary usage
- Large (lg): Emphasis, mobile-friendly
- Include all applicable sizes per component
- Document size use cases and contexts
### State Variants
- Default: Neutral, clickable state
- Hover: Mouse over or touch interaction
- Active: Pressed or selected
- Disabled: Non-interactive, grayed out
- Loading: Async operation in progress
- Error: Invalid input or failed action
- Success: Completed action confirmation
### Type/Role Variants
- Primary: Main action, emphasized
- Secondary: Alternative action
- Tertiary: Minimal appearance
- Destructive: Dangerous action warning
- Ghost: Minimal, background-only
- Document semantic meaning of each
Component Documentation
### Design Specifications
- Document dimensions (width, height, min/max)
- Specify spacing (padding, gaps, margins)
- Detail typography (font, size, weight, line-height)
- Define colors using design tokens
- Explain animation behavior if applicable
### Usage Guidelines
- When to use this component (do's)
- When not to use (don'ts)
- Content guidelines (text length, image ratios)
- Accessibility considerations (contrast, keyboard, screen readers)
- Mobile vs. desktop differences if applicable
### Behavior Documentation
- Interaction patterns (click, hover, focus)
- Keyboard navigation (Tab order, Enter/Space triggers)
- Mobile touch interactions
- Error handling and validation display
- Loading and async states
### Best Practices
- Link to live examples or Storybook
- Include screenshot comparisons of variants
- Provide code snippets for common uses
- Document common mistakes to avoid
- Link to related components
Design Implementation
### Using Main Components
- Drag main component into design file
- Switch variant in Design panel
- Override text content and images
- Document which overrides are expected
- Keep variant structure unchanged
### Detaching When Necessary
- Detach only when truly custom (rare)
- Document why detaching was necessary
- Consider adding new variant instead
- Sync detached custom components back to library
- Minimize detached instances for consistency
### Updating Component Instances
- When main component updates, instances auto-update
- Review and approve component changes before publishing
- Communicate significant changes to design team
- Update main component carefully to avoid breaking instances
- Use "Reset all changes" to revert overrides if needed
Color and Typography Integration
### Token Application
- Apply design token colors to component fills
- Use semantic tokens (button-primary, text-muted)
- Link typography styles to token values
- Enable theme switching through token swaps
- Document token dependencies for each component
### Style Libraries
- Create shared text styles in Figma library
- Create shared color styles
- Document style naming (TextBody, ButtonLabel)
- Sync styles across component variants
- Version styles as library evolves
Code Integration
### Design-to-Code Mapping
- Document component props in design annotations
- Map design variants to code props (size="lg", variant="primary")
- Document which props control which visuals
- Create component prop documentation
- Link design documentation to code README
### Code Connect (Figma)
- Use Code Connect plugin to link design components to code
- Map component instance properties to code props
- Generate live component documentation in Storybook
- Keep mappings synchronized with code changes
- Document mapping logic for maintainers
### Storybook Documentation
- Create story for each component and variant
- Include interactive controls to change props
- Document props with descriptions and types
- Add accessibility checklist per component
- Link to design in Figma from Storybook
Library Maintenance
### Versioning Components
- Use semantic versioning (major.minor.patch)
- Major: Breaking changes (removed variants, prop changes)
- Minor: New variants or non-breaking additions
- Patch: Bug fixes or documentation updates
- Document migration path for breaking changes
### Publishing Library Updates
- Test component changes in staging environment first
- Get design and engineering approval before publishing
- Document changelog for each version
- Communicate breaking changes prominently
- Provide migration guide for major updates
### Deprecation Process
- Announce deprecation 1-2 releases in advance
- Provide replacement component or path forward
- Mark deprecated components in library
- Remove only after sufficient migration time
- Document deprecation reasons in changelog
Audit and Evolution
### Library Audit
- Review components for consistency and quality
- Check for redundant or similar components
- Verify all variants are documented
- Test accessibility for each variant
- Validate token and style usage throughout
### Identifying Gaps
- Monitor new components created in projects
- Identify opportunities to extract reusable components
- Assess designer and developer feedback
- Prioritize high-value components for library
- Plan component library roadmap
### Performance Optimization
- Minimize component main files
- Archive legacy or rarely-used components
- Use copy strategy when variants diverge significantly
- Keep component count manageable (50-200 typical)
- Document reasoning for included components
Best Practices
- Name components consistently and descriptively
- Keep component logic simple and focused
- Document all components, even seemingly obvious ones
- Version components and track changes
- Get stakeholder buy-in before major changes
- Test components across devices and browsers
- Keep design and code components synchronized
Common Pitfalls
- Creating too many variants for edge cases
- Not documenting component usage or behavior
- Inconsistent naming across components
- Mixing design-specific and code-specific concerns
- Forgetting to deprecate old components properly
- Breaking changes without migration path
- Over-engineering components for flexibility
Collaboration
- Use Figma Shared Libraries for design sharing
- Create public Storybook instance for developer reference
- Establish component review process
- Hold regular component library sync meetings
- Solicit feedback from design and engineering teams
- Document governance and decision-making