Building my own design system with AI as a designer
I'm a product designer, and I've been using AI to build personal projects. In these projects, I handle the core logic and design, while AI turns them into working code. Even without extensive development knowledge, I've found that I can build functional products with AI as long as I clearly define what I want to build and how it should work.
In this note, I'd like to share why I decided to build my own design system at the code level, how I built it with AI, and what changed in my workflow as a result.
My previous workflow
Before building a code-based design system, my workflow generally looked like this.
- Implementing core functionality: I wrote specifications for the core features and logic in Markdown, then had AI implement them. At this stage, I focused on functionality rather than visual design, using a temporary UI generated by AI.
- Applying the initial UI design: I designed the actual UI in Figma and shared its structure with AI through Markdown specifications or exported HTML or PDF files. AI then implemented the UI based on those references, and I adjusted my Figma designs to match the HTML structure it had created.
- Refining the UI: I repeatedly exchanged HTML or PDF files between Figma and AI, refining the visual details until the UI was complete.
This approach allowed me to achieve the visual results I wanted without setting up a dedicated development harness or code-based design system. However, I encountered several problems along the way.
High cost of UI revisions
The first problem was the amount of tokens consumed when making UI changes through HTML or PDF files. Applying an initial UI design could consume nearly half of my monthly token allowance. Even after that, continuing to refine the UI through exported files rather than making changes directly in code often pushed me beyond my monthly limit, requiring me to purchase additional credits.
Loss of design fidelity
The second problem was losing design information during the handoff between Figma and AI. As I exchanged HTML or PDF files between Figma and the coding AI, some design details were lost or misinterpreted. Sometimes, AI would reuse existing styles in ways I hadn't intended, resulting in a UI that differed from my original design.
For example, colors with alpha transparency were sometimes converted into the opaque colors produced when rendered against their backgrounds. In other cases, I discovered only after deployment that UI elements displayed under specific conditions didn't match what I had designed.
Inconsistent style structures across projects
The final problem was that each project ended up with a different internal style structure. In this workflow, AI interpreted the exported HTML or PDF files and generated styles independently for each project, without directly referencing the components and variables I had defined in Figma.
As a result, each project had its own CSS and design token structure. Whenever I needed to make design changes, I first had to understand the styles and tokens AI had already generated, then either instruct AI to work within that structure or modify the code myself.
Designing my own design system
To address these problems, I decided to build a code-based design system for my personal projects.
Previously, AI had generated the UI and styles independently for each project by interpreting HTML or PDF references. My new approach was to create a shared design system in code that AI could directly reference when building a product's UI.
I already had a reasonably organized personal design system in Figma, which I had used to design previous projects. Rather than starting from scratch, I decided to build on that foundation by preparing a few additional resources.
- Headless component library: A headless component library provides the underlying component behavior and accessibility features without imposing a particular visual style. This makes it possible to apply custom designs while relying on existing component functionality. I chose Base UI as the headless component library for my design system.
- Variables spreadsheet (exported as CSV): I moved the design tokens I had previously managed with Figma variables into a spreadsheet. This spreadsheet defines each token's name, value, modes, and references to other tokens.
- Style master (Markdown document based on CSS syntax): The Style master is a Markdown document that defines the styles of my Figma components using CSS-based syntax. Instead of writing separate styles for every color or size variation, I abstracted repeated styles into shared structures with replaceable values.
- Rule master (Markdown document): The Rule master defines how the CSS generator should interpret the Variables CSV and Style master and transform them into actual CSS.
I divided the work between myself and AI based on what each of us was responsible for. As the designer, I defined the overall structure of the design tokens and CSS selectors. I also created the master files (.md and .csv) that described the variables and styles. When I needed a component or behavior that wasn't provided by the headless component library, I described its structure and interactions directly in prompts. Finally, I reviewed the implementation using preview pages generated by AI.
AI, on the other hand, reviewed the master files and requirements for inconsistencies or missing information. It implemented or updated the CSS generator according to the Rule Master, then ran the generator to produce the actual CSS. It also implemented React components by combining the generated styles with headless components and checked the resulting code.
Building the design system
Here's how I built each part of the design system.
Design tokens
I started by moving the variables I had managed in Figma into a spreadsheet, which I could then export as a CSV file. This also marked a change in how I managed my design tokens: I moved their single source of truth from Figma to the spreadsheet. Since Figma Variables and CSS design tokens have different requirements and management structures, I organized the spreadsheet to support both environments. AI then used the CSS generator to transform the exported Variables CSV into CSS that could be used in web projects.
CSS styles
Next, I translated the component styles I had created in Figma into the Style Master, using CSS-based syntax. To avoid repeatedly defining the same styles for different colors and sizes, I created shared structures with replaceable values. Some components, such as inputs, have DOM structures that differ from the layer structures I had created in Figma. In those cases, I wrote the styles to match the actual DOM structure of the headless components. AI then used the CSS generator to transform the Style Master into actual CSS.
As I built more components, I occasionally needed to extend existing styles or make styles originally designed for specific components more reusable. Depending on the situation, I either created new standalone styles or added utility styles that could be combined with existing ones. I also renamed some styles using more general and abstract terms so they could be reused across different components.
Components
I built components primarily by combining headless components with specific CSS selectors. Unlike design tokens and styles, I didn't create separate Markdown specifications for each component. Instead, I wrote prompts directly whenever I needed a new component. Whenever possible, I preserved the original structure and props of the underlying headless component and applied my own styles on top. If a component required additional interactions or properties, I included those requirements in the prompt as well. In some cases, components that were independent of one another in the headless component library shared the same visual design. For these, I kept their underlying component structures while making them share the same styles.
Testing and validation
I primarily tested the components using preview pages generated by AI at the end of each implementation. AI handled the initial code-level validation, while I reviewed how the components behaved and how their styles were combined under different props and states. AI could verify whether styles were being applied correctly according to CSS cascade rules. However, a style being applied correctly according to those rules didn't necessarily mean it was the style I had intended for that particular combination of conditions. For that reason, I still needed to manually inspect the different combinations of states and styles to make sure the results matched my design intentions.
Results
Building my own design system has made working with UI in my personal projects noticeably simpler and more consistent with my designs. Previously, I had to describe the UI in prompts or provide HTML or PDF references. I then had to repeatedly identify differences between the implementation and my original design and ask AI to correct them. UI-related work alone often consumed more than half of my monthly token allowance.
With the design system in place, the UI of each project is built around predefined components and styles. I can now communicate what I want by referring to components already defined in the design system, rather than describing their visual details from scratch. Because AI no longer needs to interpret and implement the same styles from the beginning for every project, I've also noticed a reduction in token consumption during UI revisions.
Of course, moving shared UI components and styles into a separate design system introduces its own trade-offs. For one thing, some of the token consumption associated with UI development has simply shifted from individual projects to the design system itself. Also, when I fix an issue or change a component in the design system, I need to publish an updated version and migrate the projects that use it. However, since AI also handles the development of the design system, it can prepare migration guides for these updates. I can then use those guides to instruct AI to update each project accordingly.
My design system is still a work in progress. I haven't built every component yet, and I'm expanding it based on what my projects actually need. But based on my experience so far, reusing a design system defined directly in code has been more efficient for my workflow than repeatedly asking AI to interpret HTML or Markdown specifications and implement the UI from those references.