Skip to main content
UX Design Engineering
Theme
Text size
100%
Typeface

Building your own component system, from first principles.

by Joshua Briley

A step-by-step guide to building an accessible, token-driven React component library from an empty directory to a deployed Storybook.

17 chapters · Updated October 2026

Introduction

About this guide

This guide walks you through building a React component library from scratch. By the end, you’ll have a working system with design tokens, accessible UI components, intrinsic layout primitives, Storybook documentation, and tests.

The guide is opinionated. It makes specific technology choices and explains why. Where reasonable alternatives exist, they are noted, but the guide doesn’t try to cover every possible approach. Covering every approach is how guides become unusable.

Like HeroUI and Untitled UI React, the components are built on React Aria. Unlike them, the library ships plain CSS rather than Tailwind classes.

Who this guide is for

This guide assumes you’re comfortable with:

  • React — You understand components, props, hooks, and the component lifecycle. You’ve built at least one project in React and aren’t relying on this guide to learn React fundamentals.
  • TypeScript — You can read and write typed interfaces, generics, and function signatures. You don’t need deep expertise, but you shouldn’t be encountering TypeScript for the first time.
  • CSS — You understand the box model, flexbox, and responsive design. Familiarity with CSS custom properties is helpful but not required.
  • The terminal — You’re comfortable running commands, navigating directories, and managing packages with npm or a similar tool.
  • Node.js — You have Node 20.19 or later installed, which Vite 7 requires. If you’re unsure, run node -v in your terminal.

You don’t need prior experience with Tailwind CSS, Storybook, design tokens, or accessibility tooling. The guide introduces each of these as they come up.

How to get the most from this guide

Work through chapters in order. Chapters 1 through 3 establish the foundation, the architecture decisions and project setup that everything else builds on. Chapters 4 through 12 are more modular, but they reference the token system and file structure from the earlier chapters. Chapters 13 through 16 extend the finished library and can be read in any order, or skipped until you need them.

Type the code, don’t copy it. Pasting code lets you get to the end faster, but typing it forces you to read each line. The goal is understanding the system, not just having a working repo.

Read the “why” sections. This guide explains the reasoning behind each choice. Those explanations are where the transferable knowledge lives. If you skip them, you’ll have a library but not the judgment to extend it.

Don’t skip Chapter 1. It contains no code. It’s also the most important chapter. The decisions made there shape every chapter that follows.

Expect things to break. Build tools and package ecosystems change. If something doesn’t work, check the version numbers first, then search for the error message. Each chapter specifies the versions it was written against.

Use the companion repository as a reference. A complete implementation of the library built in this guide is available at GitHub. If you get stuck or want to compare your output against a known-good state, that repository is the reference: the component names, prop signatures, token names, and class names in this guide all match what it ships. It also contains more than the guide covers, and a few things the guide points out as gaps.

Series overview

ChapterTitleWhat you’ll build
1The architecture before the codeNothing (decisions only)
2Project setupEmpty repo with Vite, React 19, TypeScript, Tailwind CSS 4
3Design tokens from scratchThree-tier token system with Style Dictionary
4Your first layout primitive: StackStack component with token-driven spacing
5The rest of the layout systemBox, Center, Cluster, Sidebar, Switcher, Grid, Cover
6Typography: Heading, Text, and ProseThree typography components with long-form content rhythm
7Accessible components with React AriaButton, IconButton, and Input with full keyboard and ARIA support
8Form componentsSelect, Checkbox, RadioGroup, Switch
9Overlays and feedbackDialog, Tooltip, Alert, Badge, Card
10Storybook as your documentation layerConfiguration, story conventions, example pages
11Testing accessible componentsVitest, Testing Library, axe-core patterns
12Packaging and distributionVite library mode, npm publishing, versioning
13Theming: eight themes from one pipelinePer-theme token builds switched by data-theme
14The component set beyond the coreMenu, navigation, status, and content components
15Data visualizationBar, line, and donut charts that follow the theme
16Drag and drop that works from the keyboardA Kanban board built on @dnd-kit
17What comes nextRemaining gaps, Figma alignment, governance

Table of contents

  1. 1 The architecture before the code This chapter covers the decisions you need to make before you write a single line of code.
  2. 2 Project setup This chapter gets you from an empty directory to a working development environment with Vite, React 19, TypeScript, and Tailwind CSS 4. No components yet, just the foundation.
  3. 3 Design tokens from scratch This chapter builds the token system that every component and layout primitive will reference.
  4. 4 Your first layout primitive: Stack The Stack is the most frequently used layout primitive you'll build.
  5. 5 The rest of the layout system You have the pattern down from the Stack chapter. This chapter applies that same pattern seven more times.
  6. 6 Typography: Heading, Text, and Prose This chapter adds three components that enforce typographic consistency through the same token system that drives the rest of the library.
  7. 7 Accessible components with React Aria This chapter introduces React Aria and uses it to build three interactive components: Button, IconButton, and Input.
  8. 8 Form components This chapter builds Select, Checkbox, CheckboxGroup, RadioGroup, and Switch. Each one follows the React Aria hook pattern from the previous chapter.
  9. 9 Overlays and feedback This chapter builds Dialog, Tooltip, Alert, Badge, and Card.
  10. 10 Storybook as your documentation layer This chapter configures Storybook 10 and establishes the story conventions that make the documentation useful.
  11. 11 Testing accessible components This chapter covers the testing tools and what to test for each component type.
  12. 12 Packaging and distribution Your library works in Storybook. Your tests pass. Now you need to package it so other projects can install and use it.
  13. 13 Theming: eight themes from one pipeline This chapter turns the single token build from Chapter 3 into a family of themes that change palette, spacing, radius, and typeface without touching a line of component code.
  14. 14 The component set beyond the core This chapter covers the seventeen components that fill the gap between a working library and one people can build a product with.
  15. 15 Data visualization This chapter wraps a charting library so that charts read design tokens, follow the active theme, and stay accessible.
  16. 16 Drag and drop that works from the keyboard This chapter builds a Kanban board, and uses it to work through the accessibility problem that drag-and-drop interfaces almost always get wrong.
  17. 17 What comes next This chapter covers what to build next, how to keep design and code aligned, and what separates a component library from a design system.