Astro
Install @nightwire/astro in an Astro project, then register the integration:
import nightwire from '@nightwire/astro'import { defineConfig } from 'astro/config'
export default defineConfig({ integrations: [nightwire({ defaultFlavor: 'nocturne', accent: 'indigo' })],})| Option | Default | Purpose |
|---|---|---|
defaultFlavor |
nocturne |
Flavor to use if no preference is saved and the system does not prefer light. |
accent |
Unset (indigo) | Initial accent from the palette. |
persist |
true |
Store the visitor’s flavor and accent choices in local storage. |
css |
true |
Import @nightwire/css; disable it if you import styles yourself. |
The early inline script prefers a valid stored flavor, then Lumen for a light system preference, then the default flavor. It sets data-flavor on <html> before the first paint.
Layout and FlavorSelect
Section titled “Layout and FlavorSelect”---import Layout from '@nightwire/astro/components/Layout.astro'import FlavorSelect from '@nightwire/astro/components/FlavorSelect.astro'---
<Layout title="Connection guide" description="Configure a connection."> <FlavorSelect label="Theme" /> <main> <h1>Connection guide</h1> </main></Layout>Layout creates the page shell with a head slot. FlavorSelect exposes the four flavors as native buttons and supports Arrow, Home, and End keys. window.nightwire provides getFlavor(), setFlavor(), getAccent(), and setAccent() for custom controls, and nightwire:flavor reports changes.
For interactive Vue components in Astro, register @astrojs/vue, import the component, and use a hydration directive such as client:visible. See the live Vue examples.