Skip to content

Themes

@xngui/theme
@xngui/theme

Runtime appearance and palette presets — XThemeService, XPaletteService, and 38 built-in themes.

Overview

Three layers

Foundation styles load once; appearance and palette are optional layers you can mix.

  1. @xngui/styles foundation

    Primitives, semantic light/dark roles, scale, states — always imported in your global stylesheet.

  2. XThemeService appearance

    Toggles .dark on <html> and sets data-theme — persists under x-theme in localStorage.

  3. XPaletteService palette

    Swaps primary, accent, and other primitive ramps — optional if you use a CSS theme @import instead.

Choose your path

Same presets — three ways to apply primitive color ramps.

CSS @import

Build-time primitive overrides

When the brand palette is fixed before deploy.

  • No JavaScript required
  • Import only the preset file you need
  • Works in any stack — not Angular-specific
Styles — palette CSS imports →

XPaletteService

Runtime palette switching

When users pick presets in-app (picker, settings, demo).

  • This page previews live — tap any preset card below
  • Pairs with light / dark mode from XThemeService
  • Remembers choice in localStorage across reloads

Theme builder

Prototype and export

When tuning ramps before committing CSS or provideXPalettes().

  • Live preview against semantic light / dark CSS
  • Copy CSS overrides or register custom palettes
  • Start from any of the 38 built-in presets
Open theme builder →
styles.css
@import '@xngui/styles';@import '@xngui/styles/themes/chromatic/blue';
palette.ts
import { XPaletteService } from '@xngui/theme';inject(XPaletteService).setPalette('ocean');

Light / dark appearance and color palettes are separate — pick how you apply the 38 built-in presets.

Styles tokens for the CSS token pipeline, primitives, semantic roles, and palette @import path.

Theme

Theme Services

Three runtime services — appearance mode, color ramps, and computed token reads.

XThemeService

Control light, dark, and system appearance.

  • light · dark · system preference.
  • Adds or removes .dark on <html> automatically.
  • Remembers choice in localStorage.
XThemeService.ts
import { XThemeService } from '@xngui/theme';const theme = inject(XThemeService);theme.mode(); // 'light' | 'dark' | 'system'theme.resolvedMode(); // 'light' | 'dark' after system resolvetheme.isDark(); // booleantheme.setMode('dark'); // persists to localStoragetheme.toggle(); // flips resolved light ↔ darktheme.cycle(); // light → dark → system → …
XPaletteService

Swap primitive color ramps without touching semantic CSS.

  • 38 built-in palettes plus any you register at runtime.
  • setPalette() injects a :root style block at runtime.
  • registerPalette() for one-off brand ramps.
XPaletteService.ts
import { XPaletteService } from '@xngui/theme';const palettes = inject(XPaletteService);palettes.palette(); // active palette idpalettes.catalog(); // built-in + registered metapalettes.setPalette('blue'); // injects <style id="x-palette">palettes.registerPalette({  id: 'brand',  label: 'Brand',  description: 'Custom ramp.',  icon: '🎨',  tokens: { '--x-primary-500': 'oklch(0.55 0.14 250)' },});
XTokenResolver

Resolve live token values from the DOM.

  • Read computed values for any --x-* token.
  • Clear cache after theme or palette changes.
  • Used by theme builder and debugging tools.
XTokenResolver.ts
import { XTokenResolver } from '@xngui/theme';const tokens = inject(XTokenResolver);tokens.resolve('--x-primary'); // computedCSSValuetokens.invalidate(); // clear cache after theme/palette change

Appearance

Switch light, dark, or system — the theme service toggles .dark on the document root.

Preference
system
Resolved
light
Active palette
default
theme.ts
import { XPaletteService, XThemeService } from '@xngui/theme';// Appearance — toggles .dark on <html>inject(XThemeService).setMode('dark');inject(XThemeService).toggle();// Primitive ramps — :root block in <style id="x-palette">inject(XPaletteService).setPalette('blue');

Predefined Themes

Chromatic Palettes

Seventeen Tailwind chromatic hues — tap a card to preview live and copy its @import line.

Warm spectrum

Tailwind red → yellow chromatic ramps

  • RedTailwind Red brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/red';
  • OrangeTailwind Orange brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/orange';
  • AmberTailwind Amber brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/amber';
  • YellowTailwind Yellow brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/yellow';

Fresh spectrum

Tailwind lime → teal chromatic ramps

  • LimeTailwind Lime brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/lime';
  • GreenTailwind Green brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/green';
  • EmeraldTailwind Emerald brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/emerald';
  • TealTailwind Teal brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/teal';

Cool spectrum

Tailwind cyan → indigo chromatic ramps

  • CyanTailwind Cyan brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/cyan';
  • SkyTailwind Sky brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/sky';
  • BlueTailwind Blue brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/blue';
  • IndigoTailwind Indigo brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/indigo';

Vivid spectrum

Tailwind violet → rose chromatic ramps

  • VioletTailwind Violet brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/violet';
  • PurpleTailwind Purple brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/purple';
  • FuchsiaTailwind Fuchsia brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/fuchsia';
  • PinkTailwind Pink brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/pink';
  • RoseTailwind Rose brand spectrum — full 50–950 ramps with wheel-neighbor accent and tinted semantics; page chrome stays on default achromatic neutrals.@import '@xngui/styles/themes/chromatic/rose';

Nature Themes

Twelve season and nature presets — four seasons plus land, sea, and sky moods with curated role anchors.

Seasons

Spring, summer, autumn, and winter mood presets

  • SpringCherry blossom pink with fresh bud green — renewal and soft rain.@import '@xngui/styles/themes/nature/spring';
  • SummerOpen sky blue with sun gold accents — high sun and beach heat.@import '@xngui/styles/themes/nature/summer';
  • AutumnHarvest amber and rust with burgundy shadows — dry leaves and dusk.@import '@xngui/styles/themes/nature/autumn';
  • WinterSnow white chrome with frost blue — ice, crisp air, short days.@import '@xngui/styles/themes/nature/winter';

Nature & sky

Land, sea, and sky scene presets

  • SunsetWarm coral and amber glow with rose accents — inviting golden hour.@import '@xngui/styles/themes/nature/sunset';
  • OceanDeep sea blue primary with teal foam accents — calm and professional.@import '@xngui/styles/themes/nature/ocean';
  • ForestMossy greens and bark browns — organic, grounded, easy on the eyes.@import '@xngui/styles/themes/nature/forest';
  • DesertSaharan sand and terracotta with cool dusk teal shadows.@import '@xngui/styles/themes/nature/desert';
  • AuroraNorthern lights — mint and violet on a polar night sky.@import '@xngui/styles/themes/nature/aurora';
  • Starry nightMoonlit teal on midnight void — clear cold sky.@import '@xngui/styles/themes/nature/starry-night';
  • MountainAlpine slate and mist gray with pine green accents.@import '@xngui/styles/themes/nature/mountain';
  • RainStorm sky blue with wet green — lush air after rainfall.@import '@xngui/styles/themes/nature/rain';

Inspired Themes

Palettes inspired by published design systems — not official products. See themes/THIRD_PARTY_NOTICES.md.

Inspired themes

Palettes inspired by published design systems — not official products

  • GitHubInspired by GitHub Primer — success green primary with Primer blue accent.@import '@xngui/styles/themes/branding/github';
  • DraculaInspired by Dracula — purple primary with cyan accent and vivid semantics.@import '@xngui/styles/themes/branding/dracula';
  • MaterialInspired by Material 3 baseline — purple primary with balanced secondary containers.@import '@xngui/styles/themes/branding/material';
  • NordInspired by Nord — arctic frost blue primary on polar night neutrals.@import '@xngui/styles/themes/branding/nord';
  • CatppuccinInspired by Catppuccin Mocha — mauve primary with pastel blue accent.@import '@xngui/styles/themes/branding/catppuccin';
  • Tokyo NightInspired by Tokyo Night — electric blue primary with violet accent.@import '@xngui/styles/themes/branding/tokyo-night';
  • GruvboxInspired by Gruvbox — warm orange primary with retro earth-tone semantics.@import '@xngui/styles/themes/branding/gruvbox';

Utility Themes

Minimal monochrome and high-contrast presets for layout clarity and accessibility demos.

Utility

Minimal and accessibility-focused presets

  • MonochromeAchromatic ramps across all roles — minimal, timeless, print-like.@import '@xngui/styles/themes/utility/monochrome';
  • High contrastStrong foreground separation and saturated role fills for accessibility.@import '@xngui/styles/themes/utility/high-contrast';

Brand Spectrum

Each hue ships full 50–950 ramps for all eight roles — primary is exact Tailwind, semantics pick up subtle brand gravity.

Red
primary
secondary
accent
neutral
success
warning
danger
info
Green
primary
secondary
accent
neutral
success
warning
danger
info
Blue
primary
secondary
accent
neutral
success
warning
danger
info
Violet
primary
secondary
accent
neutral
success
warning
danger
info

Custom Palettes

Register brand ramps at bootstrap or runtime with palette providers and registerPalette(). Prototype ramps in the theme builder before exporting CSS overrides.

palettes.ts
import { provideXPalettes } from '@xngui/theme';export const appConfig = {  providers: [    provideXPalettes([      {        id: 'brand',        label: 'Brand',        description: 'Company primary ramp.',        icon: '🎨',        tokens: {          'x-primary-500': 'oklch(0.55 0.14 250)',          'x-primary-600': 'oklch(0.48 0.16 250)',        },      },    ]),  ],};
register.ts
import { XPaletteService } from '@xngui/theme';const palettes = inject(XPaletteService);palettes.registerPalette({  id: 'brand',  label: 'Brand',  description: 'Runtime palette.',  icon: '🎨',  tokens: { '--x-primary-500': 'oklch(0.55 0.14 250)' },});palettes.setPalette('brand');