Skip to content
NativeScript Unified

HTML first

Theming

All colours come from one file: packages/ui/styles/tokens.css. It uses shadcn-style names (--background, --foreground, --primary, and so on) with plain hex values, because NativeScript CSS has no oklch. Both apps import it, so the web and the device share one palette.

The palette is a warm cream background, a deep teal-black foreground and a teal accent.

TokenLightDark
--background#f2ebdd#171a18
--foreground#10302f#f2ebdd
--primary#27695f#5ea396
--secondary, --muted#e3d9c4#2b2d27
--accent#cfe2dd#27403b
--border#d3c7ad#3a3b33
background
primary
secondary
accent
muted
card

Using the tokens

In Tailwind classes, use the token names: bg-background, text-foreground, bg-primary text-primary-foreground, border. The Spartan helm components read the same tokens, so they follow the theme and dark mode without any extra setup.

Dark mode

On the web, dark mode is the dark class on <html>. Use the toggle in the top bar. Your choice is stored in localStorage under ns-unified-theme. An inline script in index.html applies it before first paint, and the first visit follows the operating system setting.

On native the equivalent is the ns-dark class on the root view, and .ns-light is the light counterpart. NativeScript sets it from the system theme. The native app.css imports tokens.css and maps Tailwind's dark: variant onto .ns-dark.

Scoped palettes

The utilities read the tokens where they are used, so redefining a token on an element re-themes everything inside it, helm components included:

A warmer palette, scoped to this box

Badge

Every example screen in packages/shared works this way. Its stylesheet redefines the tokens on .example-<slug>, with a dark set under .dark .example-<slug> and .ns-dark .example-<slug>. Only colours change, and --radius stays shared.

Polyfill variables

The web polyfills read --ns-* variables (--ns-foreground, --ns-primary, --ns-card, --ns-border, --ns-radius, and so on). tokens.css maps them onto the theme tokens, so switching to dark mode restyles polyfilled views as well.