Quick Start
This guide will walk you through setting up the Axiomatic Color and building your first themed component.
1. Install & Initialize
Section titled “1. Install & Initialize”Run the following commands in your project root:
pnpm is recommended (this repo uses pnpm). npm generally works as a best-effort alternative.
npm install -D @axiomatic-design/colornpx axiomatic initpnpm add -D @axiomatic-design/colorpnpm exec axiomatic initThis creates a color-config.json file with default settings.
2. Generate Assets
Section titled “2. Generate Assets”Now, generate the CSS and TypeScript definitions.
npx axiomatic build --out ./src/theme.cssnpx axiomatic export --format typescript --out ./src/theme.tspnpm exec axiomatic build --out ./src/theme.csspnpm exec axiomatic export --format typescript --out ./src/theme.ts3. Build a Card
Section titled “3. Build a Card”Let’s build a simple “Card” component to see the system in action.
First, import the engine and your generated theme in your app entry point:
import "@axiomatic-design/color/engine.css";import "./theme.css";Then, create a Card component:
export function Card() { return ( <div className="surface-card" style={{ padding: "2rem", borderRadius: "8px" }} > <h2 className="text-strong">Hello World</h2> <p className="text-subtle">I am a themed card.</p> </div> );}First, import the engine and your generated theme in your root layout:
<script> import "@axiomatic-design/color/engine.css"; import "../theme.css";</script><slot />Then, create a Card component:
<script> import { tokens } from "$lib/theme";</script>
<div class={tokens.surface.card} style="padding: 2rem; border-radius: 8px;"> <h2 style="color: {tokens.context.text.high}">Hello World</h2> <p style="color: {tokens.context.text.subtle}">I am a themed card.</p></div>Link the engine and your generated theme in your <head>:
Note: If you are using a bundler (like Vite, Webpack, or Astro), you should import the CSS file in your JavaScript/TypeScript entry point instead (e.g.
import './theme.css').
<link rel="stylesheet" href="https://unpkg.com/@axiomatic-design/color@latest/engine.css"/><link rel="stylesheet" href="./src/theme.css" />Then, write the markup using the utility classes:
<div class="surface-card" style="padding: 2rem; border-radius: 8px;"> <h2 class="text-strong">Hello World</h2> <p class="text-subtle">I am a themed card.</p></div>4. Next Steps
Section titled “4. Next Steps”You now have a working theme system!
- React Integration: Deep dive into React patterns.
- Svelte Integration: Deep dive into Svelte patterns.
- The Theme Studio: Customize your colors visually.