Usage
Always use semantic tokens instead of raw Tailwind colors. Select a token by its role. The same class then stays correct when the mode or theme changes.
Tailwind Setup
Register Phi before Tailwind in your application stylesheet.
@import "@dicehub/phi/styles/tailwind";
@import "tailwindcss";
@source "../node_modules/@dicehub/phi/dist";Correct
<template>
<section class="bg-phi-base text-phi-default border border-phi-hairline">
<button class="bg-phi-accent text-phi-accent-contrast hover:bg-phi-accent-hover">
Save changes
</button>
<button class="bg-phi-control text-phi-default">Cancel</button>
</section>
</template>Incorrect
<template>
<!-- Never use raw palette colors or dark: overrides. -->
<section class="bg-white text-gray-950 dark:bg-gray-900 dark:text-white">
<button class="bg-blue-600 hover:bg-blue-700">Save changes</button>
</section>
</template>Mode
Set data-mode on a parent element. Do not add dark: classes. Phi defines explicit light and dark values for each semantic token.
<html data-mode="light">
<body><!-- Semantic utilities use their light values. --></body>
</html>
<html data-mode="dark">
<body><!-- The same utilities now use their dark values. --></body>
</html>Themes
A theme changes token values but keeps the utility names stable. Set data-theme on the same element as data-mode, or scope it to one product area.
<!-- After adding acme to the theme config -->
<html data-mode="dark" data-theme="acme">
<body>
<App />
</body>
</html>Available Themes
phi— default product-agnostic Phi theme
Theme Generator
The canonical token contract is packages/phi/scripts/theme-generator/config.ts. Generated CSS is checked in and package checks detect drift.
# Show every generated token and its purpose
pnpm --filter @dicehub/phi codegen:themes --list
# Generate the base theme and every configured override
pnpm --filter @dicehub/phi codegen:themes
# Preview or verify without writing files
pnpm --filter @dicehub/phi codegen:themes --dry-run
pnpm --filter @dicehub/phi check:themesCreating a New Theme
Add the theme name to AVAILABLE_THEMES, then add overrides only to tokens that change. Every token without an override inherits its light and dark values from the base phi theme.
// In scripts/theme-generator/config.ts
export const AVAILABLE_THEMES = ["phi", "acme"] as const;
export const THEME_CONFIG = {
baseTheme: "phi",
themes: AVAILABLE_THEMES,
color: {
"phi-accent": token(
"oklch(0.5772 0.2324 260)",
"oklch(0.51948 0.2324 260)",
"Primary accent background",
{
theme: {
acme: {
light: "oklch(0.55 0.16 175)",
dark: "oklch(0.7 0.14 175)",
},
},
},
),
},
};Run pnpm --filter @dicehub/phi codegen:themes. The generator emits the scoped data-theme declarations and the package check detects stale output.
Semantic Tokens
Semantic names describe intent, not hue. For example, bg-phi-danger means a destructive indicator. It does not promise a fixed red value.
Surface Hierarchy
Move from the outer canvas to nested surfaces. Do not select a token only because its current shade looks correct.
| Utility | Purpose |
|---|---|
bg-phi-canvas | Outermost page background. |
bg-phi-base | Default component background. |
bg-phi-elevated | Surface that sits above the base layer. |
bg-phi-recessed | Inset controls and grouped navigation. |
bg-phi-tint | Quiet table rows and hover states. |
bg-phi-contrast | High-contrast inverted surface. |
Accent
| Utility | Purpose |
|---|---|
bg-phi-accent | Primary action or selected state. |
bg-phi-accent-hover | Hover state for an accent surface. |
text-phi-accent | Accent-colored text on a neutral surface. |
text-phi-accent-contrast | Text and icons on an accent surface. |
Semantic Status Colors
Each status has three roles: a solid indicator, a low-emphasis tint, and readable text.
| Utility | Purpose |
|---|---|
bg-phi-info / fill-phi-info | Information indicator or icon. |
bg-phi-info-tint | Information background. |
text-phi-info | Information text. |
bg-phi-success / fill-phi-success | Success indicator or icon. |
bg-phi-success-tint | Success background. |
text-phi-success | Success text. |
bg-phi-warning / fill-phi-warning | Warning indicator or icon. |
bg-phi-warning-tint | Warning background. |
text-phi-warning | Warning text. |
bg-phi-danger / fill-phi-danger | Error or destructive indicator. |
bg-phi-danger-tint | Error or destructive background. |
text-phi-danger | Error or destructive text. |
Solid color tokens support bg-*, border-*, ring-*, fill-*, and stroke-*. Text tokens use a separate contrast-safe namespace.
Text Colors
| Utility | Purpose |
|---|---|
text-phi-default | Primary body text. |
text-phi-strong | Headings and important labels. |
text-phi-subtle | Descriptions and secondary labels. |
text-phi-inactive | Disabled or inactive text. |
text-phi-placeholder | Input placeholder text. |
text-phi-inverse | Text on a high-contrast surface. |
text-phi-link | Link text. |
Borders & Rings
| Utility | Purpose |
|---|---|
border-phi-hairline / ring-phi-hairline | Subtle edge between flat surfaces. |
border-phi-line / ring-phi-line | Defined edge used with an elevated surface. |
ring-phi-focus | Strong keyboard focus ring. |
ring-phi-focus-soft | Soft outer focus halo. |
Token Reference
This reference comes directly from the generator config. Toggle the page mode to inspect the live result; each card also shows both source values.
Displaying 59 generated tokens
Text Colors 13
--text-color-phi-default--text-color-phi-inverse--text-color-phi-strong--text-color-phi-subtle--text-color-phi-inactive--text-color-phi-placeholder--text-color-phi-accent--text-color-phi-accent-contrast--text-color-phi-link--text-color-phi-info--text-color-phi-success--text-color-phi-warning--text-color-phi-dangerSurface, State & Theme Colors 30
--color-phi-canvas--color-phi-elevated--color-phi-recessed--color-phi-base--color-phi-tint--color-phi-contrast--color-phi-overlay--color-phi-control--color-phi-interact--color-phi-fill--color-phi-fill-hover--color-phi-accent--color-phi-accent-hover--color-phi-line--color-phi-hairline--color-phi-focus--color-phi-focus-soft--color-phi-shadow-edge--color-phi-shadow-drop--color-phi-arrow-edge--color-phi-arrow-stroke--color-phi-info-tint--color-phi-info--color-phi-success-tint--color-phi-success--color-phi-warning-tint--color-phi-warning--color-phi-danger-tint--color-phi-danger--color-phi-danger-hoverComponent Colors 16
--text-color-phi-badge-orange-subtle--text-color-phi-badge-teal-subtle--text-color-phi-badge-neutral-subtle--text-color-phi-badge-inverted--color-phi-badge-inverted--color-phi-badge-red--color-phi-badge-orange--color-phi-badge-green--color-phi-badge-teal--color-phi-badge-teal-subtle--color-phi-badge-blue--color-phi-badge-purple--color-phi-badge-neutral--color-phi-banner-info--color-phi-banner-warning--color-phi-banner-danger