Skip to content

Design Tokens

@akashjs/ui uses Material Design 3 design tokens for consistent theming across every component. Tokens are exposed as both TypeScript objects and CSS custom properties.

Color System

The color system follows MD3 with five key color families, each providing a main color, its "on" contrast color, a container, and an "on-container" contrast.

Primary

TokenLightDark
--md-sys-color-primary#6750A4#D0BCFF
--md-sys-color-on-primary#FFFFFF#381E72
--md-sys-color-primary-container#EADDFF#4F378B
--md-sys-color-on-primary-container#21005D#EADDFF

Secondary

TokenLightDark
--md-sys-color-secondary#625B71#CCC2DC
--md-sys-color-on-secondary#FFFFFF#332D41
--md-sys-color-secondary-container#E8DEF8#4A4458
--md-sys-color-on-secondary-container#1D192B#E8DEF8

Tertiary

TokenLightDark
--md-sys-color-tertiary#7D5260#EFB8C8
--md-sys-color-on-tertiary#FFFFFF#492532
--md-sys-color-tertiary-container#FFD8E4#633B48
--md-sys-color-on-tertiary-container#31111D#FFD8E4

Error

TokenLightDark
--md-sys-color-error#B3261E#F2B8B5
--md-sys-color-on-error#FFFFFF#601410
--md-sys-color-error-container#F9DEDC#8C1D18
--md-sys-color-on-error-container#410E0B#F9DEDC

Surface

TokenLightDark
--md-sys-color-surface#FFFBFE#1C1B1F
--md-sys-color-on-surface#1C1B1F#E6E1E5
--md-sys-color-surface-variant#E7E0EC#49454F
--md-sys-color-on-surface-variant#49454F#CAC4D0
--md-sys-color-surface-dim#DED8E1#141218
--md-sys-color-surface-bright#FFFBFE#3B383E
--md-sys-color-surface-container-lowest#FFFFFF#0F0D13
--md-sys-color-surface-container-low#F7F2FA#1D1B20
--md-sys-color-surface-container#F3EDF7#211F26
--md-sys-color-surface-container-high#ECE6F0#2B2930
--md-sys-color-surface-container-highest#E6E0E9#36343B

Outline & Utility

TokenLightDark
--md-sys-color-outline#79747E#938F99
--md-sys-color-outline-variant#CAC4D0#49454F
--md-sys-color-inverse-surface#313033#E6E1E5
--md-sys-color-inverse-on-surface#F4EFF4#313033
--md-sys-color-inverse-primary#D0BCFF#6750A4
--md-sys-color-scrim#000000#000000
--md-sys-color-shadow#000000#000000

Accessing Colors in TypeScript

ts
import { colors, darkColors } from '@akashjs/ui';

console.log(colors.primary);          // '#6750A4'
console.log(darkColors.primary);      // '#D0BCFF'
console.log(colors.surfaceContainer); // '#F3EDF7'

Typography Scale

The type scale provides 15 roles across 5 categories (display, headline, title, body, label), each in large/medium/small sizes.

Token prefixFont SizeLine HeightWeightLetter Spacing
display-large57px64px400-0.25px
display-medium45px52px4000
display-small36px44px4000
headline-large32px40px4000
headline-medium28px36px4000
headline-small24px32px4000
title-large22px28px4000
title-medium16px24px5000.15px
title-small14px20px5000.1px
body-large16px24px4000.5px
body-medium14px20px4000.25px
body-small12px16px4000.4px
label-large14px20px5000.1px
label-medium12px16px5000.5px
label-small11px16px5000.5px

Each role generates four CSS custom properties:

css
--md-sys-typescale-body-large-font-size: 16px;
--md-sys-typescale-body-large-line-height: 24px;
--md-sys-typescale-body-large-font-weight: 400;
--md-sys-typescale-body-large-letter-spacing: 0.5px;

Accessing Typography in TypeScript

ts
import { typography } from '@akashjs/ui';

console.log(typography.bodyLarge);
// { fontSize: '16px', lineHeight: '24px', fontWeight: '400', letterSpacing: '0.5px' }

Spacing Scale

A linear spacing scale for margins, paddings, and gaps.

KeyValueCSS Property
00--md-sys-spacing-0
14px--md-sys-spacing-1
28px--md-sys-spacing-2
312px--md-sys-spacing-3
416px--md-sys-spacing-4
520px--md-sys-spacing-5
624px--md-sys-spacing-6
832px--md-sys-spacing-8
1040px--md-sys-spacing-10
1248px--md-sys-spacing-12
1664px--md-sys-spacing-16
ts
import { spacing } from '@akashjs/ui';

console.log(spacing[4]); // '16px'

Elevation

Five elevation levels with Material Design shadow values.

LevelShadowCSS Property
0none--md-sys-elevation-0
10 1px 2px 0 rgba(0,0,0,0.3), 0 1px 3px 1px rgba(0,0,0,0.15)--md-sys-elevation-1
20 1px 2px 0 rgba(0,0,0,0.3), 0 2px 6px 2px rgba(0,0,0,0.15)--md-sys-elevation-2
30 4px 8px 3px rgba(0,0,0,0.15), 0 1px 3px 0 rgba(0,0,0,0.3)--md-sys-elevation-3
40 6px 10px 4px rgba(0,0,0,0.15), 0 2px 3px 0 rgba(0,0,0,0.3)--md-sys-elevation-4
50 8px 12px 6px rgba(0,0,0,0.15), 0 4px 4px 0 rgba(0,0,0,0.3)--md-sys-elevation-5
ts
import { elevation } from '@akashjs/ui';

console.log(elevation[3]);
// '0 4px 8px 3px rgba(0,0,0,0.15), 0 1px 3px 0 rgba(0,0,0,0.3)'

Shape (Border Radius)

KeyValueCSS Property
none0--md-sys-shape-none
extraSmall4px--md-sys-shape-extra-small
small8px--md-sys-shape-small
medium12px--md-sys-shape-medium
large16px--md-sys-shape-large
extraLarge28px--md-sys-shape-extra-large
full9999px--md-sys-shape-full
ts
import { shape } from '@akashjs/ui';

console.log(shape.medium); // '12px'
console.log(shape.full);   // '9999px'

Motion (Durations and Easings)

Durations

KeyValue
short150ms
short2100ms
short3150ms
short4200ms
medium1250ms
medium2300ms
medium3350ms
medium4400ms
long1450ms
long2500ms

Easings

KeyValue
standardcubic-bezier(0.2, 0, 0, 1)
standardDeceleratecubic-bezier(0, 0, 0, 1)
standardAcceleratecubic-bezier(0.3, 0, 1, 1)
emphasizedcubic-bezier(0.2, 0, 0, 1)
emphasizedDeceleratecubic-bezier(0.05, 0.7, 0.1, 1)
emphasizedAcceleratecubic-bezier(0.3, 0, 0.8, 0.15)
ts
import { motion } from '@akashjs/ui';

console.log(motion.duration.medium2); // '300ms'
console.log(motion.easing.standard);  // 'cubic-bezier(0.2, 0, 0, 1)'

generateTokenCSS() API

ts
function generateTokenCSS(dark?: boolean): string

Returns a complete CSS string with a :root block containing all token custom properties.

ParameterTypeDefaultDescription
darkbooleanfalseWhen true, uses the dark color palette instead of light

Returns: A string of CSS that sets all --md-sys-* custom properties on :root.

ts
import { generateTokenCSS } from '@akashjs/ui';

// Light theme
const lightCSS = generateTokenCSS();

// Dark theme
const darkCSS = generateTokenCSS(true);

// Inject into the document
const style = document.createElement('style');
style.textContent = lightCSS;
document.head.appendChild(style);

Released under the MIT License.