When building a design system on my own with AI as a designer rather than a developer, implementing what I had in mind was not as simple as I expected. This was because the way designers visually understand and design components differs from how those components are actually implemented in code. To build a code-based design system, a designer needs to understand how components are implemented at the code level, particularly how CSS styles that define their visual appearance are written and managed.

In this article, I would like to share some of the challenges I encountered while building my design system.

1. Style priority across theme and state combinations

‍

My design system defines two sets of styles, one for light backgrounds and the other for dark backgrounds. These primarily correspond to the light and dark themes applied at the system and browser levels. In addition, there were cases where I needed to invert the theme within a specific area of a page or apply styles designed for a particular background regardless of the current theme.

Problems arose when base styles needed to be overridden under certain conditions. For example, some color families, such as yellow, required a different set of styles from other color families. Various component states, such as selected, error, and disabled states, also required their own styles. In these cases, the base styles had to be overridden by styles defined for each condition. As these combinations of conditions became more complex, the resulting visual appearance often differed from what I had intended for each theme and condition. This was not much of an issue for components with relatively simple combinations of styles and states, such as buttons. However, for components such as radios and checkboxes, the actual style priority in CSS often differed from what I had intended.

To address this, I needed to adjust style priorities so that specific combinations would produce the intended visual results. I used two approaches. The first was to define priorities between groups of styles using CSS cascade layers (@layer), and the second was to adjust selector specificity using :where(). I used cascade layers for cases such as disabled and read-only states, where the same grayscale styles were always applied regardless of the component’s color property. This eliminated the need for unnecessary color-specific handling and simplified the structure of my CSS styles. When selector specificity still caused unintended styles to appear after separating the layers, I used :where() to reduce the specificity of selectors that had higher specificity than those defining the intended styles.

Since I did not have an in-depth understanding of CSS, I relied on AI to handle these specificity adjustments. AI also suggested an appropriate source order and specificity hierarchy for selectors under different conditions, so that styles would override one another in a way that matched my design intent even when multiple conditions were combined.

2. Building components not provided by a Headless component library

‍

Wrapping an existing headless component and applying my intended styles was a completely different task from building a component that the library did not provide. When working with an existing headless component, I could focus on applying styles based on its predefined structure. If necessary, I only needed to instruct AI to modify specific parts of its structure or behavior. In contrast, when building a component that was not provided by the library, I first had to define its structure and behavior before addressing its styles. When testing the component implemented by AI, I also had to carefully check how it behaved and how it handled edge cases.

One example from my design system was a component called ValueChip, a type of chip that allows users to enter and edit its value directly through an embedded Input component. Base UI, the headless component library I used to build my design system, provided chips only as subcomponents of its Combobox. These chips displayed predefined values but did not allow users to edit those values directly. I therefore had to build ValueChip as a separate component by combining components provided by Base UI. ValueChip required careful consideration of various behaviors, including entering and exiting edit mode, handling empty values, reverting changes, and creating new chips. I had to continually review whether the component implemented by AI matched my intentions and communicate the necessary adjustments through prompts.

Even when relying on AI for development in this way, understanding which headless components could be combined to build a new component and communicating that structure to AI made it much easier to create a component that matched my design intent and apply the appropriate styles to it.

3. Unintended interaction effects from shared styles

‍

When designers "draw" components in Figma, visual styles of each component are managed through individual variants. Although I take a different approach by using variable modes to manage styles, the styles are still defined within individual variants. In a code-based design system, however, CSS styles are defined and managed independently of components, and then applied to individual components. Multiple components can share the same style. A style can also include variations based on interactions, attributes, or other states, independently of component props. In other words, while designers may think of a component's style as an inherent characteristic of that component, CSS styles are not tied to individual components. Additional styles can be defined for specific states without assuming which component will use them.

I approached components in the same way I did in design tools like Figma, allowing components with visually identical styles to share the same CSS style. This led to an unexpected problem: hover and active styles were applied even to areas where these interactions were not intended to cause any visual changes. When building components in Figma, styles are primarily managed through individual variants. Even when components share the same visual style, it is relatively easy to have some components change their styles across different states while others retain a single base style. However, when implementing this in code, even components that were not intended to have visual interactions exhibited unintended visual changes if their shared styles included interaction-specific style rules. In other words, using the same CSS class meant that not only its base style but also the conditional styles defined for that class would be applied whenever their respective conditions were met.

I had two options to address this issue. One was to split an existing style into two separate classes: one with state-specific style rules and another containing only the base style. The other was to add a custom data attribute to DOM elements to control whether interaction-related visual changes should be applied. To avoid increasing the number of styles in my design system, I opted for the data attribute approach. Style changes in response to interactions were applied only when a specific data attribute was present on a DOM element. This allowed me to control visual interactions independently for each component, even when multiple components shared the same style.

Building a design system directly in code allowed me to experience the difference between how designers approach components and how those components are actually implemented in code. When building a design system independently without a developer, designers need some understanding of code-level implementation if they don't want to leave all implementation and decision-making to AI as a black box.

In particular, AI may make a design system unnecessarily complex and difficult for designers to modify, or implement it in ways that differ from their design intent. To reduce these risks, designers need to understand how components and styles are implemented at the code level. They should take this understanding into account when designing component structures and styles.

Tags
design system
ai
css
css selector
component styling
Published on
November 30, 2026
Notes