Skip to content

Astro components

@nyxwire/astro ships three framework-free components. Import them by path:

---
import Layout from '@nyxwire/astro/components/Layout.astro'
import FlavorSelect from '@nyxwire/astro/components/FlavorSelect.astro'
import FlavorScript from '@nyxwire/astro/components/FlavorScript.astro'
---

A complete HTML document for pages outside Starlight. The body gets the canvas background, the body text color, the sans font and the base line height; it adds no grid and no landmarks, so your page owns its structure.

<Layout title="Settings" description="Choose your appearance." class="settings">
<link slot="head" rel="icon" href="/favicon.svg" />
<main class="nw-container nw-stack">…</main>
</Layout>
Prop Default Effect
title 'Nyxwire' The <title>
description none A <meta name="description">
lang 'en' lang on <html>
flavor none Initial data-flavor and data-theme in the server HTML
accent none Initial data-accent in the server HTML
class none Classes on <body>

The default slot is the page; the head slot adds elements to <head>. The document also declares color-scheme: dark light and a responsive viewport.

Without flavor, the server HTML carries no flavor attribute, so the CSS fallback applies without JavaScript (Nocturne, or Lumen for a light system), and two theme-color metas follow the system color scheme. With flavor, the HTML starts in that flavor and the single theme-color uses its base color. Either way, once a flavor runtime runs it owns the attributes and the meta. For a fixed starting flavor, also set defaultFlavor on the integration or on FlavorScript; a visitor’s stored choice still wins. The accent prop is likewise only the initial attribute: configure the integration’s accent to keep it at runtime.

Layout renders no flavor script and imports no CSS. The integration provides both; without it, add FlavorScript and import the stylesheet yourself. It does not preload fonts either: the stylesheet loads the three bundled variable families (Space Grotesk, Inter and Martian Mono) when they are first used.

A segmented control of native buttons (Auto, Abyss, Nocturne, Twilight and Lumen) inside a labelled role="group", wrapped in an <nw-flavor-select> custom element. It reads and sets the page runtime, and every instance on the page stays in sync through nyxwire:flavor. This one controls the site, like the selector in the header:

<FlavorSelect label="Color flavor" class="settings-flavor" />
Prop Default Effect
label 'Color flavor' Accessible name of the group
class none Classes on the <nw-flavor-select> element
Key Action
Tab Moves focus to the active option, then out of the group
→ ↓ Selects and focuses the next option, wrapping around
← ↑ Selects and focuses the previous option, wrapping around
Home End Selects and focuses the first or last option
Enter Space Selects the focused option
  • Each button reports its state with aria-pressed, and the group uses a roving tabindex, so it is one tab stop.
  • Each button’s title carries the flavor’s mood from the palette.
  • The active option is highlighted from the data-nw-flavor-preference attribute on <html>, which the runtime sets before the first paint, so it is correct before the element upgrades.
  • The buttons stay disabled until a runtime is available, including when JavaScript is off.
  • Focus rings, hover states, prefers-reduced-motion and forced-colors mode are handled with Nyxwire tokens. The control styles itself from tokens alone, so it needs no component stylesheet.
  • Listeners are removed when the element disconnects.

The flavor runtime as an inline <script>, for pages that do not use the integration. It accepts the integration’s options as props:

src/pages/standalone.astro
---
import '@nyxwire/css'
import Layout from '@nyxwire/astro/components/Layout.astro'
import FlavorScript from '@nyxwire/astro/components/FlavorScript.astro'
---
<Layout title="Standalone page">
<FlavorScript slot="head" flavors={{ dark: 'twilight' }} accent="ice" />
<main class="nw-container">…</main>
</Layout>

Put it once per page, in the head, so it runs before the first paint. Its styles and css props are validated but import nothing: import the CSS in the page or layout.