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:
bash npm install -D @axiomatic-design/color npx axiomatic init
bash pnpm add -D @axiomatic-design/color pnpm exec axiomatic init
This 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.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 CSS in your app entry point:
import './theme.css';Then, create a Card component:
import { tokens } from "./theme";
export function Card() { return ( <div className={tokens.surface.card} style={{ padding: "2rem", borderRadius: "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> );}First, import the CSS in your root layout:
<script> 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 CSS in your <head>:
<link rel="stylesheet" href="/theme.css">Then, write the markup:
<div class="surface-card" style="padding: 2rem; border-radius: 8px;"> <h2 style="color: var(--text-high-token)">Hello World</h2> <p style="color: var(--text-subtle-token)">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 Builder: Customize your colors visually.