Starlight setup
@nyxwire/starlight is a Starlight plugin. It restyles every Starlight surface (header, search, sidebar, table of contents, content, asides, badges, cards, tabs, steps, file trees, pagination, hero, banner and code blocks), replaces the theme picker with a flavor picker, and generates one code theme per flavor from the palette. This site uses it with the default options.
-
Install the plugin next to Starlight. It needs
astro7 and@astrojs/starlight0.42 or later.Terminal window pnpm add @nyxwire/starlight -
Add it to Starlight’s
plugins, not as a second Astro integration.astro.config.mjs import { defineConfig } from 'astro/config'import starlight from '@astrojs/starlight'import nyxwireStarlight from '@nyxwire/starlight'export default defineConfig({integrations: [starlight({title: 'My docs',plugins: [nyxwireStarlight()],}),],})
When Starlight sets up, the plugin:
- puts
@nyxwire/starlight/styles.cssfirst incustomCss, so your own stylesheets load after it and win; - overrides the
ThemeProvidercomponent and, unlessflavorSelectis off, theThemeSelectcomponent, keeping every other override you configured; - sets the Expressive Code themes, theme selector and style overrides;
- hands the configured flavor runtime to its
ThemeProviderthrough the Vite virtual modulevirtual:nyxwire/starlight-runtime.
If you already override ThemeProvider or ThemeSelect, your component is kept and the plugin logs a warning. Nyxwire’s ThemeSelect needs Nyxwire’s ThemeProvider runtime.
Options
Section titled “Options”nyxwireStarlight({ flavors: { dark: 'abyss', light: 'lumen' }, defaultFlavor: 'auto', accent: 'ice', flavorSelect: true, expressiveCode: true,})| Option | Values | Default |
|---|---|---|
flavors.dark |
'abyss', 'nocturne', 'twilight' |
'nocturne' |
flavors.light |
'lumen' |
'lumen' |
defaultFlavor |
'auto', 'abyss', 'nocturne', 'twilight', 'lumen' |
'auto' |
accent |
any of the 12 accents | none |
flavorSelect |
true, false |
true |
expressiveCode |
true, false |
true |
flavors.dark is the flavor Auto uses on a dark system, and the one Starlight’s “Dark” choice maps to. defaultFlavor applies when the visitor has no stored choice. accent re-points the primary color: links, the active sidebar entry, focus rings and glow. Without it the palette default, indigo, applies. Invalid values or unknown keys throw a NyxwireStarlightOptionsError when the plugin is created; the flavor and accent rules are shared with @nyxwire/astro.
Flavor runtime and picker
Section titled “Flavor runtime and picker”The ThemeProvider override inlines the flavor runtime in <head>, followed by a small Starlight bridge, so the stored flavor applies before the first paint. It sets data-flavor (which the Nyxwire tokens and the code themes read), data-theme (which Starlight reads), data-accent and color-scheme on <html>, keeps <meta name="theme-color"> on the active flavor’s base color, and exposes window.nyxwire. Astro pages and Vue islands on the same origin share the choice, stored under nyxwire-flavor.
import type {} from '@nyxwire/astro'
window.nyxwire?.setFlavor('abyss') // persists and appliesThe ThemeSelect override is Starlight’s own <select>, wrapped in <nw-starlight-flavor-select>, with Auto and the four flavors; the header and mobile-menu copies stay in sync, and the stored flavor shows before the first paint. It keeps the native keyboard behavior and grows to fit long localized labels. Its labels come from Starlight’s UI strings, so you can rename it through the i18n collection:
import { defineCollection } from 'astro:content'import { docsLoader, i18nLoader } from '@astrojs/starlight/loaders'import { docsSchema, i18nSchema } from '@astrojs/starlight/schema'
export const collections = { docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }), i18n: defineCollection({ loader: i18nLoader(), schema: i18nSchema() }),}{ "themeSelect.accessibleLabel": "Select flavor", "themeSelect.auto": "System"}With flavorSelect: false, Starlight’s dark, light and auto picker stays and keeps working: its choices map to flavors.dark, flavors.light and Auto. Either way, the plugin mirrors the flavor into Starlight’s starlight-theme storage key, adopts a visitor’s earlier Starlight dark or light choice once if no flavor was stored yet, and keeps window.StarlightThemeProvider.updatePickers() available for code that calls it.
Expressive Code
Section titled “Expressive Code”Unless expressiveCode is false on the plugin, or Expressive Code is turned off in Starlight, the plugin configures code blocks:
- Themes. One VS Code theme per flavor, the configured dark flavor first, generated from the palette’s syntax roles: keywords in flux, strings in matrix, functions in arc, types in volt, comments in italic
overlay2. Syntax ink is lifted to at least 5.5:1 on each flavor’s dimmest code surface. - Selector. Each theme applies under
[data-flavor='<flavor>'], so code blocks switch with the flavor, not just with dark and light. Starlight’s own dark-mode switch, UI theme colors and dark-mode media query are turned off accordingly. - Style overrides. Code backgrounds, borders, frames, title bars, the copy button and text markers point at CSS variables (
var(--nw-canvas-sunken),var(--nw-line),var(--nw-panel),var(--nw-font-mono),var(--nw-radius-lg)), so every block follows the active flavor and accent without a rebuild. - Contrast.
minSyntaxHighlightingColorContrastis 4.5. The generated themes already meet a stricter bar, so this WCAG AA floor only affects themes you supply.
Your own Expressive Code options win: themes replace the generated ones (and the flavor selector is then dropped), and styleOverrides merge over the plugin’s, group by group for frames and textMarkers. Everything except themeCssSelector is plain JSON; if you render <Code> components and Expressive Code asks for an ec.config.mjs, move the options there with createExpressiveCodeOptions. The themes are exported for other Expressive Code or Shiki setups:
import { createCodeThemes, createExpressiveCodeTheme, nyxwireDark, nyxwireLight,} from '@nyxwire/starlight'
const twilightTheme = createExpressiveCodeTheme('twilight') // raw palette colorsconst rendered = createCodeThemes('abyss') // contrast-adjusted, one per flavornyxwireDark is the Nocturne theme and nyxwireLight the Lumen one.
Tailwind in Starlight
Section titled “Tailwind in Starlight”To use the Tailwind theme and the Vue components on a Starlight site, add a stylesheet to customCss. The plugin’s stylesheet still loads first.
@layer base, starlight, theme, components, utilities;@import 'tailwindcss/theme.css' layer(theme);@import 'tailwindcss/utilities.css' layer(utilities);@import '@nyxwire/tailwind';@import '@nyxwire/vue/tailwind.css';
@layer base { *, ::before, ::after { border: 0 solid; }}starlight({ plugins: [nyxwireStarlight()], customCss: ['./src/styles/global.css'],})Tailwind’s preflight is left out because Starlight ships its own reset; the border reset is the one piece Tailwind’s border utilities need. Register @tailwindcss/vite in vite.plugins. @astrojs/starlight-tailwind is compatible but not required.
nw-* demos in content
Section titled “nw-* demos in content”These docs also render the framework-free CSS components inside pages. Their stylesheet imports the component and utility layers of @nyxwire/css next to the theme:
@import '@nyxwire/css/components.css';@import '@nyxwire/css/utilities.css';and wraps every live example in an element with the not-content class, which keeps Starlight’s content typography (margins, heading and link styles) out of it:
<div class="not-content"> <button class="nw-btn">Connect</button></div>Vue islands
Section titled “Vue islands”Add @astrojs/vue to the integrations and use the components as islands. Do not add the @nyxwire/astro integration to a Starlight site: the plugin’s ThemeProvider already installs the runtime.
Layers and overrides
Section titled “Layers and overrides”The plugin’s stylesheet declares the page’s layer order:
@layer base, starlight, theme, nyxwire-print, components, utilities;/* starlight: base, reset, core, content, components, utils, nyxwire */- Starlight’s variables (
--sl-color-*,--sl-shadow-*,--sl-font,--sl-font-mono, the--sl-text-*scale and line heights) are mapped to Nyxwire tokens in unlayered CSS. Override one in your own unlayered CSS, which loads later and wins. - The component restyles live in
@layer starlight.nyxwire. Any unlayered rule, or a rule in a later layer such as Tailwind’sutilities, beats them. - To recolor Starlight and the Nyxwire components together, change the tokens (
--nw-primary,--nw-canvas, …) rather than the--sl-*variables. A nesteddata-flavorordata-accentattribute restyles one region. - The theme carries Nyxwire’s motifs: a wire-gradient header edge, wire-bordered cards and link cards, cut-corner asides, glass surfaces and gradient hero titles.
- Printing uses the Lumen palette, matching Starlight’s light print stylesheet; component restyles apply to screens only.
- Transitions respect
prefers-reduced-motion. In forced-colors mode, cards and asides fall back to system borders, and the current page and the selected tab get an outline.