Tailwind setup
@nyxwire/tailwind is a CSS-first theme for Tailwind CSS 4.3: an @theme inline block, custom variants and custom utilities. There is no JavaScript config. A typed merge helper ships alongside (Class merging).
-
Install Tailwind 4 with its Vite plugin (or the CLI) and the theme.
Terminal window pnpm add -D tailwindcss @tailwindcss/vitepnpm add @nyxwire/tailwind @nyxwire/css -
Register the Vite plugin.
vite.config.ts import { defineConfig } from 'vite'import tailwindcss from '@tailwindcss/vite'export default defineConfig({ plugins: [tailwindcss()] }) -
Import the theme after Tailwind.
src/style.css @import 'tailwindcss';@import '@nyxwire/tailwind';@import '@nyxwire/vue/tailwind.css'; /* only with @nyxwire/vue */ -
Set the flavor on the document (or let a flavor runtime do it) and use the utilities.
<html data-flavor="nocturne" data-accent="indigo"><body class="bg-canvas font-sans text-fg"><button class="rounded-md bg-primary px-4 py-2 text-on-primary glow-sm">Connect</button></body></html>
What each line does
Section titled “What each line does”| Import | Brings |
|---|---|
@nyxwire/tailwind |
@nyxwire/css tokens, the locally bundled fonts, the base styles (with the nw-* keyframes), then the theme |
@nyxwire/tailwind/theme.css |
The theme only: colors, fonts, type scale, spacing, radius, shadows, easings, animations, motif utilities, variants |
@nyxwire/vue/tailwind.css |
An @source for the Vue package’s dist, so Tailwind generates the classes its components use |
The entry does not import the nw-* component classes. Use theme.css when another stylesheet already loads @nyxwire/css (or at least its tokens, fonts and base): the animate-* utilities run the nw-* keyframes defined in @nyxwire/css/base.css, so the theme-only form expects that base to be present.
Runtime theming
Section titled “Runtime theming”Every mapping uses @theme inline, so generated CSS points at the --nw-* variables directly. Switching data-flavor or data-accent restyles every utility without a rebuild, nested scopes included, and opacity modifiers mix the variable: bg-primary/20 compiles to color-mix(in oklab, var(--nw-primary) 20%, transparent).
In your own CSS, write var(--nw-primary) rather than var(--color-primary) when a value must follow a nested flavor scope.
Opt out of Tailwind’s default colors
Section titled “Opt out of Tailwind’s default colors”Tailwind’s own palette stays available next to Nyxwire’s. To remove it, reset the color namespace before the theme, so the Nyxwire mappings are declared after the reset:
@import 'tailwindcss';@import './palette-reset.css';@import '@nyxwire/tailwind';@theme { --color-*: initial;}Font files with the Tailwind CLI
Section titled “Font files with the Tailwind CLI”Vite and other bundlers rewrite the relative font URLs in @nyxwire/css/fonts.css. The standalone Tailwind CLI leaves url('./fonts/…') as written, so copy the font directory next to the stylesheet it emits. The package’s own demo does this with demo/copy-fonts.ts, which resolves the files through the @nyxwire/css/fonts.css export.
Starlight and other layered setups
Section titled “Starlight and other layered setups”Starlight ships its own reset, so a Starlight site imports Tailwind’s theme and utilities into explicit layers instead of tailwindcss, and uses theme.css. The full stylesheet is on Starlight setup.