How to Build Unified Design System Components: Buttons, Badges, Inputs & Cards

The Quick Answer

To build a unified design system in CSS, establish a single set of shared core design tokens (color ramps, spacing multipliers, border radii, and elevation levels) that every component inherits. By binding buttons, badges, text inputs, and cards to common variables like var(--radius-md), var(--space-4), and var(--brand-primary), updating a single token instantly harmonizes the entire application interface.

Interactive Demo Live Preview
Cohesive Component Suite
Status Badge
Input text...

Step 1: Single Source of Truth: Token Inheritance

The secret to world-class design systems like Apple Human Interface or GitHub Primer is token inheritance. Components never define their own arbitrary paddings or corner radiuses. They subscribe directly to global tokens.

system-tokens.css
:root {
  --radius-component: 8px;
  --focus-ring: 0 0 0 3px rgba(99, 102, 241, 0.4);
  --brand-color: #6366f1;
}

/* Button, Input, and Badge all share the identical radius and focus ring */
.btn, .input, .badge {
  border-radius: var(--radius-component);
}

.btn:focus-visible, .input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

Step 2: Size Modifiers: sm, md, and lg Scales

Scale components proportionally across small, medium, and large variants by pairing font sizes with typographic em padding or spacing multiplier tokens. Using em units allows padding to grow automatically with text size.

component-sizes.css
/* Standardized Height Ramps */
.btn-sm, .input-sm {
  font-size: 12px;
  padding: 4px 10px;
  height: 28px;
}

.btn-md, .input-md {
  font-size: 14px;
  padding: 8px 16px;
  height: 38px;
}

.btn-lg, .input-lg {
  font-size: 16px;
  padding: 12px 24px;
  height: 48px;
}

Step 3: Variant Modifiers: Solid, Outline & Ghost Styles

Build semantic variants (primary solid, secondary outline, tertiary ghost) with consistent hover physics. Leveraging color-mix() generates matching tinted hover and active states automatically.

component-variants.css
.btn-solid {
  background: var(--brand-color);
  color: #ffffff;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--brand-color);
  color: var(--brand-color);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: color-mix(in srgb, var(--brand-color) 12%, transparent);
}

Step 4: The Compound Card Assembly Pattern

Assemble individual components into complex composite cards. When a card combines a media thumbnail, heading, status badge, and action button, shared design tokens guarantee every corner and margin aligns mathematically.

compound-card.html
<article class="system-card">
  <div class="card-header">
    <span class="badge badge-success">Production Ready</span>
    <time>Nov 18</time>
  </div>
  <h3 class="card-title">Analytics Engine</h3>
  <div class="card-actions">
    <button class="btn btn-solid btn-sm">Deploy</button>
  </div>
</article>

Next-Level Addons: Elevating Your Implementation

Take this technique further by combining it with complementary design token studios and animation tools:

Global Suite Sync 4 TOOLS LINKED

1. Unified Component Styler in Studio

Explore in Unified Component Builder →

Adjust a single theme control and watch buttons, badges, inputs, and cards adapt instantaneously across light and dark modes.

--space-2 (8px), --space-4 (16px)

2. Shared 8pt Spacing in Spacing Scale Generator

Explore in 4pt/8pt Spacing Scale Generator →

Govern component paddings and margins with mathematical 8pt grid tokens to eliminate visual dissonance.

--radius-component: 8px

3. Consistent Corner Radius in Radius Tokens Studio

Explore in Radius & Border Width Tokens →

Ensure nested cards and child buttons share verified concentric corner radii (R_inner = R_outer - padding).

Chaam
Chaam's Pro Tip

Here's my golden rule when implementing this in production: test across multiple devices and browsers early. Keep your DOM hierarchy shallow, optimize assets with modern formats (like WebP/AVIF), and verify keyboard navigation for accessibility.

Why I Built the Unified Component Builder Studio

I got tired of guessing values and testing browser quirks in DevTools, so I built this tool to tweak and preview values in real time with 1-click code export.

Open in Unified Component Builder ↗

Frequently Asked Questions

Practical answers to common implementation questions, browser quirks, and performance tips.

Why should buttons and form inputs share identical height and padding tokens?

When buttons and text inputs sit adjacent to one another in search bars or inline forms, mismatched heights or border-radii create glaring visual misalignment. Sharing height tokens guarantees clean optical symmetry.

What is the advantage of using CSS custom properties for component libraries?

CSS variables allow consumers of your design system to override brand themes, dark mode variables, and corner radii globally without touching component source stylesheets or recompiling SCSS.

How many size variants should a component library provide?

Most mature design systems provide three standard sizes: Small (sm, 28px–32px height), Medium (md, 36px–40px default height), and Large (lg, 44px–48px touch-optimized height).

How should disabled states be styled across design system components?

Set opacity: 0.5, pointer-events: none, and cursor: not-allowed. Ensure color contrast remains readable and declare aria-disabled="true" for accessibility.

Can CSS color-mix() replace dozens of manual button hover variables?

Yes. color-mix(in srgb, var(--primary), white 15%) calculates light hover tints on the fly, eliminating the need to maintain separate hex codes for every interaction state.

← Back to all blog guides Launch Generator Studio →