Skip to content

20. Using shadcn as our component library

Date: 2025-04-19

Accepted

When we initially built our component library, we relied on basic Tailwind CSS for styling and component creation. This approach gave us flexibility but required significant effort to maintain consistency and implement complex interactive components.

As our application grew, we attempted to standardize by adopting HeadlessUI components. However, we encountered several challenges with HeadlessUI, particularly around version compatibility and testing. Our test suite frequently encountered issues with HeadlessUI components, as seen in our Dropdown component tests where we struggled with proper event handling and component rendering in the test environment.

We needed a more robust solution that would:

  1. Provide consistent, accessible components
  2. Work well with our testing infrastructure
  3. Be well-maintained and have good documentation
  4. Allow for customization to match our design system
  5. Standardize our approach across multiple applications

After researching alternatives, shadcn/ui emerged as a highly recommended solution in the React ecosystem, with strong community support and compatibility with our tech stack.

We decided on shadcn/ui https://ui.shadcn.com/ as our Component LIbrary.

  • Consistent, accessible components across all applications
  • Better testing experience with reliable component behavior
  • Reduced development time for common UI patterns
  • Strong TypeScript support and type safety
  • Active community and comprehensive documentation
  • Copy-paste approach allows for easy customization
  • Migration effort required from existing HeadlessUI components
  • Need to learn shadcn/ui patterns and conventions
  • Potential bundle size increase compared to minimal custom components
  • Plan gradual migration strategy to avoid breaking existing functionality
  • Ensure team training on shadcn/ui best practices
  • Monitor bundle size impact and optimize as needed
  • Establish guidelines for when to use shadcn components vs custom solutions