
One palette, every component: building a shared UI foundation
How I turned the visual language of my website into a reusable React component library, using CSS tokens, Tailwind CSS v4, shadcn/ui and Storybook.
One palette, a shared component library
I have a few applications and side projects that I work on, and over time I noticed that they were starting to look like they belonged to different people.
That wasn't because I wanted each app to have its own design. Quite the opposite. I wanted them to share the same visual language: the same typography, colours, spacing, borders and interaction patterns. If someone moves from one of my applications to another, the experience should feel familiar.
At first, this sounds like a fairly straightforward problem. Create a shared stylesheet, copy the components you need, and reuse them.
The problem is keeping everything consistent as the projects grow. A small adjustment to a button in one app shouldn't require me to remember to make the same adjustment in three other places. And if I add a new component, I don't want to spend time figuring out how to make it look like the rest of the interface.
So I decided to build a shared component library: @konopskidev/ui.
The idea is simple. I want one place that owns the visual language, and a set of reusable components that follow it. Each application should be able to install the package, import its stylesheet, and use the same UI without copying implementation details from another repository.
In this first article, I'll go through the repository as it stands: why the tools are what they are, and how the styling foundation the components are written against is put together. I'll also cover one of the more interesting parts of the implementation: taking components from the shadcn registry and automatically adapting them to my own design conventions.
The source code is in the konopskidevui repository, and every path in this article is a path in it.
That is also the view this article takes. It is a walk through the finished library rather than a diary of building it: every file it shows is the file that ships, so the decisions are already made and you can see what they add up to.
The problem I wanted to solve
My website already had a visual identity I was happy with. It used a paper-white background, a deep blue primary colour, a small set of typefaces with distinct roles, one corner radius, and borders instead of decorative shadows.
The problem was that the design existed as part of the website. Other applications couldn't simply reuse it.
I could copy the CSS into each project, but that would give me several versions of the same design system. Eventually, one would change and the others would fall behind. I could also create a package containing only unstyled components and leave the styling to each application, but then every consumer would have to recreate the same design decisions.
Neither option was particularly appealing.
What I wanted was a package that could be installed in any of my React applications and provide both parts of the experience:
- A shared visual foundation: colours, typography, radii, borders, focus styles, utilities and prose styles.
- A reusable component set: buttons, inputs, dialogs, cards, navigation elements and the rest of the UI building blocks.
The important part is that these two things should work together. A component shouldn't have its own independent idea of what a border or a primary colour looks like. It should use the same tokens as every other component.
That led to the first architectural decision: the CSS tokens would be the source of truth, not the components.
What I built
The repository is a React component library, but I think of it as a small design system rather than just a collection of components.
The library is based on the full radix-nova shadcn registry, adapted to the visual language of my website, with a set of hand-written house primitives alongside it. It uses TypeScript and Tailwind CSS v4, and Storybook provides the development and documentation environment.
The project also includes tests and a build setup for distributing the package. I'll cover those in more detail in the next two parts, but here's the general shape of the stack:
Area | Choice | Why |
|---|---|---|
Language | TypeScript | Component APIs should be explicit and reusable across projects. |
UI | React | The library is intended for my React applications. |
Styling | Tailwind CSS v4 | It gives me a utility-based workflow and a theme system built around CSS variables. |
Component foundation | shadcn registry and Radix primitives | I get a broad set of accessible, composable components without treating the result as a black-box dependency. |
Component variants | class-variance-authority | Variants and sizes can be represented as typed component APIs. |
Documentation | Storybook 10 | I can develop components in isolation and expose their props through interactive controls. |
Tests | Vitest | I can test component behaviour and run browser-based story tests. |
Package tooling | pnpm, Vite/Rollup and TypeScript | The package can be built into distributable JavaScript and declaration files. |
I also use ESLint and Prettier to keep the codebase consistent. Prettier's Tailwind plugin sorts utility classes, and the configuration points it at Storybook's stylesheet so it can understand the complete Tailwind setup.
I won't spend much time on repository scaffolding here. The project uses pnpm, Node 24, strict TypeScript, Vitest, ESLint's flat config, and Storybook's Vite builder. Those choices are useful context, but they aren't the interesting part of this article.
Where everything lives
Four directories carry the whole design system:
1src/styles/ the design: tokens, theme, base, utilities, prose, variants
2src/components/ui/ every component, each with a story and a test beside it
3scripts/ the style contract, the barrel, the build
4.storybook/ the preview stylesheet and the docgen configurationEverything else in the repository exists to build, test, document or publish those four. src/styles is the subject of this article: the palette, the file that turns it into Tailwind classes, the one stylesheet an application imports, and the element rules and vocabulary the components are written in. src/components/ui is the subject of the second part.
The interesting part is how the styling works.
Start with the design tokens
Everything starts with where the design values live.
src/styles/tokens.css is the single source of truth for the palette. Colours, radius values and the other design tokens are declared there. Other stylesheets are allowed to reference those values, but they shouldn't redefine them.
There are a few rules behind this setup:
- Tokens are declared once, in
tokens.css. theme.cssmaps tokens to Tailwind theme variables; it doesn't define a second palette.- The consuming application controls the active theme by adding or removing a
.darkclass on an ancestor, usually<html>. - Token declarations stay unlayered so that the dark-theme overrides behave as expected alongside Tailwind's generated utilities.
The last point is easy to overlook, so it's worth explaining. Tailwind v4 uses CSS cascade layers. If I put the token declarations inside @layer base, their precedence can differ from unlayered declarations. In this setup, that would cause problems when .dark overrides interact with utilities generated through @theme inline. Keeping the tokens unlayered avoids that issue.
The file starts with a light theme:
1:root {
2 --radius: 0.5rem;
3
4 --background: #fbfbfa;
5 --foreground: #1d2329;
6
7 --primary: #1f4fa3;
8 --primary-foreground: #ffffff;
9
10 --border: #e1e4e7;
11 --input: #d8dce0;
12 --ring: #1f4fa3;
13
14 /* card, popover, secondary, muted, accent, destructive,
15 success, code and the remaining colour tokens */
16}The dark theme overrides the values that need to change:
1.dark {
2 /* dark-theme token values */
3}This means components don't need to know whether the application is in light or dark mode. They use var(--background), var(--foreground) or var(--primary), and the cascade takes care of the rest.
The palette in both themes. The complete file contains forty-three colour tokens; each value is declared in one place.
There were also a few values that didn't exist in the original website stylesheet but were needed by the library.
The first was a consistent stacking scale. One of the site's dialogs referenced --z-index-modal, but that variable had never been defined. I added the missing values:
1--z-index-dropdown: 40;
2--z-index-overlay: 50;
3--z-index-modal: 50;
4--z-index-popover: 60;
5--z-index-toast: 70;
6--z-index-tooltip: 80;The overlay and modal intentionally share the same value. The overlay is the backdrop and the modal is the panel; they belong to the same floating layer, so separate numbers wouldn't provide any useful distinction.
I also added syntax-highlighting tokens (--tok-*) and used them as the basis for the chart palette:
1/* A chart, a code block and a diff use the same colour language. */
2--chart-1: var(--tok-keyword);
3--chart-2: var(--tok-string);
4--chart-3: var(--tok-number);The website didn't have charts, so there was no existing chart palette to reuse. Rather than invent another group of unrelated colours, I derived the chart colours from the syntax palette.
Finally, I added sidebar tokens as references to existing values:
1--sidebar-primary: var(--primary);This is useful because CSS custom properties are resolved where they are used. A derived token like this follows the active theme without needing another set of light and dark values.
The result is more than a list of colours. It's a contract: components can use the available tokens, but they don't get to invent a new shade or radius every time a new UI element is added.
Make the tokens available to Tailwind
Declaring CSS variables is only half of the job. I also wanted to use them through Tailwind classes such as bg-background, text-foreground and border-border.
That's what src/styles/theme.css is for.
Tailwind CSS v4 introduces the @theme directive, which lets you define theme variables that generate utility classes. I use @theme inline to map the tokens from tokens.css into Tailwind's theme:
1@custom-variant dark (&:is(.dark *));
2
3@theme inline {
4 --font-sans: var(--font-lato, 'Lato'), ui-sans-serif, system-ui, sans-serif;
5
6 --text-h1: clamp(2rem, 4.8vw, 2.75rem);
7 --text-h1--line-height: 1.12;
8 --text-h2: 1.75rem;
9 --text-h2--line-height: 1.2;
10
11 --color-background: var(--background);
12 --color-foreground: var(--foreground);
13
14 --radius-sm: calc(var(--radius) - 4px);
15
16 /* Remaining colour, typography and radius aliases */
17}The inline keyword is important here.
Without it, Tailwind can generate a theme variable that points to another variable defined elsewhere. With @theme inline, the reference is inlined into the generated utility. That means the browser resolves the token where the utility is used, so a .dark class on an ancestor can override it naturally.
In other words, I don't copy the palette into Tailwind's theme. I make Tailwind utilities read from the palette.
I use the same file to define the typography scale. For example, --text-h1 and --text-h2 become text-h1 and text-h2 utilities. The base heading styles can use those same utilities, while individual components can choose a different visual size when necessary.
The radius follows the same idea. The design has one base radius, 0.5rem, and smaller radius values are derived from it:
1--radius-sm: calc(var(--radius) - 4px);That might seem like a small detail, but it prevents the design from slowly accumulating slightly different corner radii.
Put the styles behind one import
At this point, I had the tokens and the Tailwind theme mapping. Next, I needed to make them easy to consume.
I didn't want every application to import six or seven separate CSS files. The package should expose one stylesheet, and that stylesheet should take care of the internal dependencies.
src/styles/globals.css is the entry point the package exports:
1@import 'tw-animate-css';
2@import './variants.css';
3@import './tokens.css';
4@import './theme.css';
5@import './utilities.css';
6@import './base.css';
7@import './prose.css';
8@import './sonner.css';The order is intentional. The variants and tokens are the foundation. The theme maps those values to Tailwind utilities. The remaining files use the definitions provided by the earlier files.
There is one important thing missing from this file:
1@import 'tailwindcss';I deliberately don't import Tailwind itself from the library.
The consuming application owns its Tailwind setup. If the package imported the framework, it could interfere with the application's own @theme, @source and utility definitions. I want the library to provide styles that work with Tailwind, not take control of how the application builds its CSS.
The consumer imports Tailwind first, followed by the library stylesheet:
1@import 'tailwindcss';
2@import '@konopskidev/ui/styles.css';That's the only stylesheet import the application needs from the package.
The stylesheet pipeline. The consumer imports one entry point; the entry point brings in the tokens, theme mapping and styles in dependency order.
I split the remaining styles into three files, each with a specific responsibility.
Base styles
base.css defines the defaults for HTML elements. It makes sure that semantic elements look consistent even when they're not rendered inside one of the library's components.
For example:
1@layer base {
2 * {
3 @apply border-border;
4 }
5
6 h1,
7 h2,
8 h3,
9 h4,
10 h5,
11 h6 {
12 @apply font-display font-semibold tracking-tight;
13 }
14
15 h1 {
16 @apply text-h1;
17 }
18
19 /* The remaining heading levels follow the same scale. */
20
21 ::selection {
22 @apply bg-primary/15 text-foreground;
23 }
24
25 *:focus-visible {
26 @apply focus-ring;
27 }
28
29 img {
30 @apply block h-auto max-w-full;
31 }
32}One decision here is particularly useful: I separate the semantic heading level from its visual size.
An h2 should represent a second-level heading in the document outline. That doesn't mean every h2 must always look like the same size. A card title might need to look like an h3, while still using the semantic element that makes sense for the page.
So the base styles provide sensible defaults, and components can override the visual step with utilities such as text-h3. This becomes important when components are composed into real pages.
Reusable utilities
utilities.css contains the small set of layout and design utilities that I already use on the website.
Some examples are:
1@utility card {
2 @apply rounded-sm border border-border bg-card text-card-foreground;
3}
4
5/* An outline that doesn't change the element's layout. */
6@utility focus-ring {
7 @apply focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring;
8}
9
10@utility eyebrow {
11 @apply font-sans text-xs font-medium tracking-[0.08em] text-muted-foreground uppercase;
12}The complete set includes utilities for page containers, grids, stacks, titles and cards.
I could recreate these classes in every application, but that would bring me back to the original problem. Shipping them with the library means that the same card utility has the same radius, border and background wherever I use it.
Article typography
The final stylesheet is prose.css.
Unlike the utility classes, article typography needs to style descendants: paragraphs, lists, tables, links and other elements inside a content container. I use a component class for that:
1.prose-article {
2 @apply font-serif text-base leading-[1.75];
3}
4
5.prose-article a {
6 @apply text-primary underline underline-offset-4;
7}There is a reason the link is always underlined. The primary colour on the body text background doesn't have enough contrast to distinguish a link by colour alone. Underlining gives the link another visual cue, which is important for accessibility.
I also set the font on .prose-article itself. The website gets its body typography from the app shell, but a reusable library can't assume that the consuming application has the same <body> styles.
Use shadcn as the starting point
The styling foundation is also what the components are written against.
I didn't want to implement dozens of primitives from scratch. There is a lot of work involved in getting dialogs, menus, selects, popovers and other interactive components right. Accessibility, keyboard interactions and focus management are easy to underestimate.
That's why I chose the shadcn registry as the starting point.
One thing worth clarifying: I'm not using shadcn as a traditional runtime component dependency. The registry gives me source code that I can bring into my own repository and adapt. That gives me control over the components while still benefiting from the work that has gone into the registry and its underlying primitives.
I configured the CLI in components.json to use the radix-nova style and my own stylesheet:
1{
2 "$schema": "https://ui.shadcn.com/schema.json",
3 "style": "radix-nova",
4 "rsc": false,
5 "tsx": true,
6 "tailwind": {
7 "config": "",
8 "css": "src/styles/globals.css",
9 "baseColor": "neutral",
10 "cssVariables": true,
11 "prefix": ""
12 },
13 "iconLibrary": "lucide",
14 "aliases": {
15 "components": "@/components",
16 "utils": "@/lib/utils",
17 "ui": "@/components/ui",
18 "lib": "@/lib",
19 "hooks": "@/hooks"
20 }
21}Now I can add a component through the CLI:
1pnpm dlx shadcn@latest add dialogThe generated code gives me a working starting point, but it isn't ready to publish as part of my library. There are a few things I need to adapt.
Fix the imports
The first issue is the aliases.
The registry generates imports such as:
1import { Button } from '@/components/ui/button';That's convenient inside an application with a matching TypeScript path alias. It's not what I want in the published package. Once the files are compiled into dist, their imports need to resolve relative to the generated files.
I could fix these imports manually, but that would be repetitive and easy to forget. Instead, I handle them in the same script that applies the rest of the library's styling conventions.
Bring the registry's styles into the library
The second issue is that the registry components expect a collection of Tailwind variants and utilities to exist.
For example, the generated components use names such as data-open, data-checked, no-scrollbar and scroll-fade. These are part of the styling layer provided by shadcn's CLI.
The library needs those definitions, but I don't want consumers to install the shadcn CLI just to make the components render correctly.
I therefore vendor the relevant layer into src/styles/variants.css. It contains the variants and utilities the components rely on, but not a competing colour palette:
1@custom-variant data-open {
2 &:where([data-state='open']),
3 &:where([data-open]:not([data-open='false'])) {
4 @slot;
5 }
6}The file is copied from [email protected] and its header records that version. If the registry changes the variants or utilities in a future release, I can compare the upstream file and update the vendored copy deliberately.
This is a small maintenance responsibility, but it keeps the package self-contained and avoids introducing a runtime dependency on the CLI.
Make the components look like my design
The third issue is the most visible one.
The registry has its own design language. It uses larger rounded corners, subtle ring borders, compact controls and shadows in places where my website uses a different visual treatment.
If I simply imported the components and changed the primary colour, the result would still look like shadcn with a blue accent. That wasn't the goal.
I wanted to preserve the component behaviour and structure while replacing the visual conventions with my own.
There are two ways to do this. I could edit every component by hand, or I could automate the transformations that have an unambiguous answer and keep the more subjective decisions in the component code.
I chose the second option.
Automate the house style
scripts/apply-house-style.mjs translates the registry's conventions into the conventions used by my library.
The script is essentially an ordered list of replacements. For example, I want every registry radius to use the same small radius:
1const RULES = [
2 // Package imports should be relative, not @/ aliases.
3 { find: /from "@\/components\/ui\/([a-z0-9-]+)"/g, replace: 'from "./$1"' },
4 { find: /from "@\/hooks\/([a-z0-9-]+)"/g, replace: 'from "../../hooks/$1"' },
5 { find: /from "@\/lib\/([a-z0-9-]+)"/g, replace: 'from "../../lib/$1"' },
6
7 // One radius scale throughout the library.
8 { find: /rounded-(t|b|l|r|tl|tr|bl|br)-(xl|lg|md)/g, replace: 'rounded-$1-sm' },
9 { find: /rounded-\[(?:2|4|6)px\]/g, replace: 'rounded-sm' },
10 { find: /rounded-(xl|lg|md)/g, replace: 'rounded-sm' },
11
12 // Replace ring-based focus styles with the house focus utility.
13 {
14 find: /focus-visible:ring-\d+ focus-visible:ring-ring\/\d+/g,
15 replace: 'focus-ring',
16 },
17 { find: /focus-visible:ring-destructive\/\d+/g, replace: 'focus-visible:outline-destructive' },
18
19 // Surface borders should be real borders.
20 { find: /ring-1 ring-foreground\/\d+/g, replace: 'border border-border' },
21
22 // Controls use the house text size.
23 { find: /\btext-base md:text-sm\b/g, replace: 'text-sm' },
24
25 // Additional focus, depth and disabled-state rules...
26];The order of the rules matters. Directional radius classes such as rounded-t-xl need to be handled before the generic rounded-xl rule. Otherwise, the generic replacement can match part of the directional class and leave an incorrect result.
After applying the rules, the script also cleans up extra whitespace left behind by replacements. It only does that inside double-quoted strings, so it doesn't accidentally alter the source formatting.
I also made the script idempotent. That means running it more than once produces the same result as running it once. This is useful because I can run it whenever I add a component from the registry without worrying that repeated runs will keep changing the files.
Here are some of the transformations it performs:
Registry convention | Library convention |
|---|---|
| |
| Directional |
| |
| |
| |
| Removed |
| |
| |
Disabled elements | Also receive |
I deliberately don't try to automate every styling decision.
For example, the registry uses h-8 for many controls. My design uses a 40px default height for inputs, while buttons use padding-based sizing. Simply replacing every h-8 with h-10 would be dangerous: not every element with a height is a form control.
So the script handles the transformations that have one correct answer. The rest stays in the component implementation, where I can make a decision based on what the component actually does.
That distinction is important. A script like this should remove repetitive work, not pretend that every design decision can be expressed as a regular expression.
A few conventions shared by every component
Once the generated code has been adapted, I still want the components to follow a consistent set of implementation conventions.
These are not all visual decisions. Some are about making the components predictable to use, compose and test.
Use data-slot to identify component parts
Every component part gets a data-slot attribute.
For example, a card can expose its root, header, title and footer as separate slots. This gives me stable selectors for CSS and tests without relying on class names that might change when the design evolves.
Let consumer classes win
I use a shared cn() helper to merge classes. It is always applied after the component's default classes and variant classes:
1const Comp = asChild ? Slot.Root : 'button';
2
3return (
4 <Comp
5 data-slot="button"
6 data-variant={variant}
7 data-size={size}
8 type={type}
9 className={cn(buttonVariants({ variant, size }), className)}
10 {...props}
11 />
12);The order matters because the class merger resolves conflicts from right to left. Applying the consumer's className last means the caller can override the defaults when needed.
Rather than maintaining another local copy of clsx and tailwind-merge, the package uses the cn package and re-exports the helper:
1export { cn } from 'cn';This also means that applications consuming the library can use the same class-merging semantics as the components themselves.
Keep composition flexible with asChild
Some components need to render as a different HTML element depending on how they're used.
A button might need to behave as a link, for example. I use Radix's Slot.Root for this:
1const Comp = asChild ? Slot.Root : 'button';That allows the component to pass its styles and props to the child instead of nesting one interactive element inside another.
I use the same pattern where it makes sense for components such as CardTitle and Badge. The goal is to keep the API flexible without sacrificing semantic HTML.
Extend the upstream API where it makes sense
I don't want to replace the shadcn component APIs just for the sake of being different. I keep the existing variants and add house-specific options where they are useful.
For example, Button retains the upstream variants and adds primary, ghost-primary and ghost-destructive, along with the icon sizes. This gives me the familiar shadcn API while allowing the components to express the visual treatments used by my applications.
Put small behaviour conventions in one place
Not every shared decision belongs in CSS.
One example is optional form fields. I want their placeholders to communicate that they're optional without every application having to remember to append the text manually:
1export function getPlaceholder(placeholder?: string, required?: boolean) {
2 if (!placeholder || required) return placeholder;
3
4 return `${placeholder} (optional)`;
5}Another example is useIsMobile.
I use useSyncExternalStore rather than a useState value updated by a resize listener. It gives the hook an explicit server snapshot, so the server and hydration render start with the same value:
1'use client';
2
3import * as React from 'react';
4
5const MOBILE_BREAKPOINT = 768;
6const QUERY = `(max-width: ${MOBILE_BREAKPOINT - 1}px)`;
7
8function subscribe(onChange: () => void) {
9 const mql = window.matchMedia(QUERY);
10 mql.addEventListener('change', onChange);
11
12 return () => mql.removeEventListener('change', onChange);
13}
14
15function getSnapshot() {
16 return window.innerWidth < MOBILE_BREAKPOINT;
17}
18
19/** `false` on the server and during hydration, then the real viewport. */
20function getServerSnapshot() {
21 return false;
22}
23
24export function useIsMobile() {
25 return React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
26}And then there's CardImage. Instead of making the library depend on a particular framework's image component, it owns the aspect-ratio container and accepts the image as children:
1function CardImage({ className, aspect = 'aspect-video', children }: CardImageProps) {
2 return (
3 <div
4 data-slot="card-image"
5 className={cn('relative overflow-hidden rounded-t-sm', aspect, className)}
6 >
7 {children}
8 </div>
9 );
10}A Next.js application can pass next/image, while a Vite application can pass a regular <img>. The library doesn't need to know which one is being used.
Use Storybook as the development environment
At this point, the library has a design foundation and a set of components that follow it. I still need a place where I can develop and review those components without constantly opening one of the consuming applications.
That's where Storybook comes in.
I use Storybook 10 with the Vite builder. Each component has its own stories, and the stories expose the component's public props through the Controls panel.
The important thing is that Storybook should render the components in an environment that resembles a real consuming application. So the preview stylesheet imports Tailwind first and the library stylesheet second:
1@import 'tailwindcss';
2@import '../src/styles/globals.css';
3
4/*
5 * Storybook is the application shell for the preview iframe.
6 * The library deliberately leaves the body treatment to the consumer.
7 */
8body {
9 background: var(--background);
10 color: var(--foreground);
11 font-family: var(--font-sans);
12 -webkit-font-smoothing: antialiased;
13}
14
15.docs-story {
16 background: var(--background);
17}The fonts are loaded through @fontsource as development dependencies. A consuming application is responsible for providing its own fonts, so the library uses sensible fallbacks.
For theme switching, I use the Storybook themes addon to apply the light or dark class to <html>:
1withThemeByClassName({
2 themes: { light: 'light', dark: 'dark' },
3 defaultTheme: 'light',
4 parentSelector: 'html',
5});This is the same mechanism that a consuming application uses. The components don't need theme-specific logic; they just read the CSS variables.
Make the Controls panel useful
One configuration detail took a little more investigation than I expected: TypeScript prop inference.
Many of the components use class-variance-authority to define their variants. The default React docgen parser doesn't always understand those types correctly, and the Controls panel ends up showing a plain string instead of a select containing the available variant values.
I switched Storybook to react-docgen-typescript:
1typescript: {
2 reactDocgen: 'react-docgen-typescript',
3 reactDocgenTypescriptOptions: {
4 shouldExtractLiteralValuesFromEnum: true,
5 shouldRemoveUndefinedFromOptional: true,
6 savePropValueAsString: true,
7 propFilter: (prop) =>
8 (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
9 },
10},This allows Storybook to read the actual TypeScript types and build controls from literal unions. Instead of a text field for variant, I get a select containing the available options.
There is one small complication: VariantProps can include null in addition to the actual variant values. Storybook's docgen option removes undefined, but not null, so I use an argTypes enhancer to strip that extra value before controls are generated.
The same button story in both themes. The component doesn't know which theme is active; the tokens and the class on the root element handle that.
I also group controls into categories. For a button, that means things like Appearance, State, Composition, Behaviour, Content, Styling and Events. It makes the Controls panel easier to navigate than a long, unstructured list of props.
Controls grouped by purpose. Variant and size belong together under Appearance, rather than being mixed in with event handlers.
The stories will do more than document the components. In the next part, I'll show how I use them as part of the testing workflow, including running them in a real browser.
Where this leaves the project
The styling foundation is now in place.
The package has one source of truth for design tokens, a Tailwind theme that maps those tokens to utilities, and a single stylesheet entry point for consuming applications. The registry components have been brought into the repository, their styling conventions are adapted automatically where possible, and the remaining decisions are handled in the component implementations.
The result is a library that can give my applications a consistent look without making each application responsible for maintaining its own copy of the design system.
There are still two big pieces of the project to cover.
In Part 2, I'll go through the components themselves: how I structure them, extend the shadcn APIs, document their props, and test their behaviour.
In Part 3, I'll focus on getting the package ready for other projects to consume. I'll walk through the build process, the output formats, package exports, and the GitHub Actions workflow that builds and publishes a release.
For now, the most important decision is also the simplest one: the palette comes first. Once every component reads from the same set of design tokens, keeping the whole library consistent becomes a much more manageable problem.