Flavors & theming
A flavor is a complete palette: twelve neutrals from the deepest background to body text, plus twelve accents. Nyxwire has four, one wire from the deepest dark to daylight.
| Flavor | Theme | Character | Use for |
|---|---|---|---|
abyss |
dark | Near-black indigo, the deepest base | Dense dashboards, HUDs |
nocturne |
dark | Deep electric indigo | Websites and docs, default |
twilight |
dark | Dusky violet-indigo, softest dark | Long reading |
lumen |
light | Lavender daylight, deeper accents | Light mode |
The three dark flavors share the exact same accent values; only their neutrals change.
Try it
Section titled “Try it”preference auto · resolved nocturne · theme dark
This is the Vue NwFlavorSelect from @nyxwire/vue, driven by useFlavor. It shares one runtime with the flavor select in the header: change either and the other follows, and the choice survives a reload.
Three attributes
Section titled “Three attributes”| Attribute | Values | Effect |
|---|---|---|
data-flavor |
abyss, nocturne, twilight, lumen |
Selects the palette for the element and its descendants |
data-theme |
dark, light |
Set with the flavor; drives the Tailwind dark:/lumen: variants and Starlight |
data-accent |
one of the 12 accents | Re-points --nw-primary, and with it buttons, links, focus and glow |
<html data-flavor="nocturne" data-theme="dark" data-accent="ice"></html>With no data-flavor on the root, Nocturne applies, or Lumen when the system prefers a light color scheme. An explicit attribute always wins over that fallback.
Nested scopes
Section titled “Nested scopes”Every semantic token is re-declared on each [data-flavor] and [data-accent] element, so a nested scope resolves against its own palette:
<section data-flavor="lumen" data-theme="light"> <button class="nw-btn nw-btn-primary">Lumen</button> <div data-flavor="abyss" data-theme="dark" data-accent="matrix"> <button class="nw-btn nw-btn-primary">Abyss, matrix accent</button> </div></section>Accents
Section titled “Accents”data-accent swaps the primary intent for one subtree. Everything derived from it follows: solid buttons, links, focus rings and glow. The generated palette CSS re-resolves the accent inside nested flavor scopes against that flavor’s own value, so an accent set on an ancestor carries into a Lumen scope and picks up Lumen’s deeper hex.
An inner data-accent beats an outer one. The generated selectors cover an accent scope inside an accent scope inside a flavor scope; nest accent scopes deeper than that and the nearest accent stops being re-resolved, so avoid going past two.
Persisting the choice
Section titled “Persisting the choice”The visitor’s flavor is stored in localStorage under nyxwire-flavor as auto, abyss, nocturne, twilight or lumen, and the accent under nyxwire-accent. auto follows prefers-color-scheme: a light system gets the configured light flavor (Lumen), anything else the configured dark flavor. Every package reads and writes the same keys, so a choice made on the docs carries over to an Astro site or a Vue app on the same origin.
The page runtime
Section titled “The page runtime”The Astro integration, the Astro FlavorScript component and the Starlight plugin all install the same runtime as window.nyxwire. It sets data-flavor, data-theme, data-accent, data-nw-flavor-preference and color-scheme on <html>, and updates <meta name="theme-color">:
window.nyxwire.getFlavor() // stored preference, including 'auto'window.nyxwire.resolve() // concrete flavor in use, e.g. 'nocturne'window.nyxwire.setFlavor('twilight') // persists, applies, dispatches the event
window.nyxwire.getAccent() // stored accent, or null for the palette defaultwindow.nyxwire.setAccent('matrix') // persists, applieswindow.nyxwire.setAccent(null) // removes data-accent, back to indigo
document.addEventListener('nyxwire:flavor', ({ detail }) => { console.log(detail.flavor, detail.resolved, detail.theme, detail.accent) // 'twilight' 'twilight' 'dark' 'matrix'})nyxwire:flavor fires on initialization, on every setFlavor and setAccent call and, while the preference is auto, when the system color scheme changes. setFlavor and setAccent throw a TypeError for unknown values. When storage is blocked, the choice still applies for the current page.
Vue: useFlavor
Section titled “Vue: useFlavor”<script setup lang="ts">import { useFlavor } from '@nyxwire/vue'
const { flavor, resolvedFlavor, isDark, flavors, setFlavor } = useFlavor()</script>
<template> <button v-for="item in flavors" :key="item.id" @click="setFlavor(item.id)"> {{ item.label }} </button></template>Every call inside one Vue app shares a single state; the first call supplies the app’s options. On a page with window.nyxwire, useFlavor delegates to the runtime and mirrors its events, which is how the island above stays in sync with the header. Without a runtime, it runs standalone: it persists under the same key, follows the system preference while auto, and sets data-flavor, data-theme and color-scheme on <html> or on a target element. The first call can pass options:
useFlavor({ defaults: { dark: 'abyss', light: 'lumen' }, // flavors used by 'auto' defaultFlavor: 'auto', // when nothing is stored storageKey: 'nyxwire-flavor', target: () => document.querySelector<HTMLElement>('#hud'), // null applies nothing storage: window.localStorage, // or null to keep the choice in memory matchMedia: (query) => window.matchMedia(query), runtime: window.nyxwire, // or null to force standalone mode})It is SSR-safe: nothing touches window or document until a component mounts.
No flash of the wrong flavor
Section titled “No flash of the wrong flavor”The runtime is a small inline script in <head> that runs before the first paint, so the stored flavor is already on <html> when the page draws. The Astro integration injects it into every page; on standalone Astro pages, put FlavorScript in the head slot of Layout. Without JavaScript, the CSS fallback still applies: Nocturne, or Lumen for a light system preference.