Skip to main content
Rudiment A field guide

A field guide · 13 chapters

Building your own component system, from first principles.

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

Figure 01 Stacking primitives: tokens, layout, components, composition.

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.

The architecture follows the same patterns used by libraries like HeroUI and Untitled UI React.

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 18 or later installed. 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 and later are more modular, but they reference the token system and file structure from the earlier chapters.

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, the companion repository is the reference. It mirrors the final state of the guide exactly.

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 and @theme
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 and Input with full keyboard and ARIA support
8Form componentsSelect, Checkbox, RadioGroup, Switch
9Overlays and feedbackDialog, Tooltip, Alert, Badge, Card, Tabs
10Storybook as your documentation layerConfiguration, story conventions, the kitchen sink page
11Testing accessible componentsVitest, Testing Library, axe-core patterns
12Packaging and distributionVite library mode, npm publishing, versioning
13What comes nextTheming, Figma alignment, scaling the system
End of Introduction

Table of contents

Thirteen chapters, written to be read in order.

Each chapter establishes one layer of the system. Earlier layers compound into later ones.

  1. 01

    The architecture before the code

    This chapter covers the decisions you need to make before you write a single line of code.

  2. 02

    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. 03

    Design tokens from scratch

    This chapter builds the token system that every component and layout primitive will reference.

  4. 04

    Your first layout primitive: Stack

    The Stack is the most frequently used layout primitive you'll build.

  5. 05

    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. 06

    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. 07

    Accessible components with React Aria

    This chapter introduces React Aria and uses it to build three interactive components: Button, IconButton, and Input.

  8. 08

    Form components

    This chapter builds Select, Checkbox, CheckboxGroup, RadioGroup, and Switch. Each one follows the React Aria hook pattern from the previous chapter.

  9. 09

    Overlays and feedback

    This chapter builds Dialog, Tooltip, Alert, Badge, Card, and Tabs

  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

    What comes next

    This chapter covers the next steps for scaling the system.