Style your qwik-docs site with custom CSS files, the design tokens ported from Astro Starlight, or the qwik-docs Tailwind plugin.
For a quick way to change the default style of your site, check out community themes.
Custom CSS styles
Customize the styles applied to your qwik-docs site by providing additional CSS files to modify or extend the framework's default styles. qwik-docs loads its own design tokens and component styles first, then injects your files after them in source order, so your CSS wins.
-
Add a CSS file to your
src/directory. For example, you can set a wider default column width and larger text size for page titles:/* src/styles/custom.css */ :root { --sl-content-width: 50rem; --sl-text-5xl: 3.5rem; } -
Add the path to your CSS file to the
customCssarray inqwik-docs.config.ts:// qwik-docs.config.ts import { defineConfig } from '@qwik-docs/framework'; export default defineConfig({ title: 'Docs With Custom CSS', + customCss: [ + // Project-relative path to your custom CSS file + './src/styles/custom.css', + ], });
customCss takes an array of project-relative CSS paths.
The framework injects each file on every page, after its own styles, in the order they are listed.
The CSS custom properties you can set live in the framework's design tokens.
See design-tokens/props.css for the full list.
These are the same --sl-* variables Astro Starlight uses.
Per-page CSS
To scope styles to one page, use the head frontmatter field.
It accepts link and style tags:
---
title: A page with its own styles
head:
- tag: link
attrs:
rel: stylesheet
href: /page-specific.css
---
Cascade layers
qwik-docs uses cascade layers internally to manage the order of its styles, ported from Astro Starlight. This gives a predictable CSS order and allows simpler overrides. Any custom unlayered CSS will override the default qwik-docs styles.
The framework declares its layer order first:
/* packages/framework/design-tokens/layers.css */
@layer starlight.base, starlight.reset, starlight.core, starlight.content, starlight.components, starlight.utils;
If you use cascade layers, you can use @layer in your custom CSS to define the order of precedence for your own layers relative to the framework layers:
/* src/styles/custom.css */
@layer my-reset, starlight.base, my-overrides;
The example above defines a custom layer named my-reset, applied before the framework layers, and another named my-overrides, applied after them.
Styles in my-overrides take precedence over the framework's styles.
Tailwind CSS
Tailwind CSS v4 support comes from the Tailwind Vite plugin.
qwik-docs ships @qwik-docs/tailwind, a compatibility stylesheet that configures Tailwind to work with the framework's styles.
@qwik-docs/tailwind applies the following configuration:
- Configures Tailwind's
dark:variants to work with the framework's dark mode. - Uses Tailwind theme colors and fonts in the framework's UI.
- Restores essential parts of Tailwind's Preflight reset styles.
Add Tailwind to a project
-
Install the Tailwind Vite plugin and the qwik-docs compatibility package:
npm install @tailwindcss/vite @qwik-docs/tailwind -
Add the Tailwind Vite plugin to your app's
vite.config.ts:// vite.config.ts import { defineConfig } from 'vite'; +import tailwindcss from '@tailwindcss/vite'; export default defineConfig({ + plugins: [tailwindcss()], }); -
Create a Tailwind base stylesheet that imports the compatibility layer:
/* src/styles/tailwind.css */ @layer base, starlight.base, theme, components, utilities; @import '@qwik-docs/tailwind'; @import 'tailwindcss/theme.css' layer(theme); @import 'tailwindcss/utilities.css' layer(utilities);This declares the framework's cascade layers order, imports the qwik-docs Tailwind compatibility CSS, and imports Tailwind's theme and utility styles.
-
Add the Tailwind stylesheet as the first item in the
customCssarray inqwik-docs.config.ts:// qwik-docs.config.ts import { defineConfig } from '@qwik-docs/framework'; export default defineConfig({ title: 'Docs with Tailwind', customCss: [ // Path to your Tailwind base styles: './src/styles/tailwind.css', ], });
Styling qwik-docs with Tailwind
qwik-docs uses values from your Tailwind theme config in src/styles/tailwind.css to style its UI.
When set, the following CSS custom properties override the framework's default styles:
--color-accent-*— links and current-item highlighting--color-gray-*— background colors and borders--font-sans— UI and content text--font-mono— code examples
/* src/styles/tailwind.css */
@layer base, starlight.base, theme, components, utilities;
@import '@qwik-docs/tailwind';
@import 'tailwindcss/theme.css' layer(theme);
@import 'tailwindcss/utilities.css' layer(utilities);
@theme {
/* Your preferred text font. qwik-docs uses a system font stack by default. */
--font-sans: 'Atkinson Hyperlegible';
/* Your preferred code font. qwik-docs uses system monospace fonts by default. */
--font-mono: 'IBM Plex Mono';
/* Your preferred accent color. Indigo is closest to the qwik-docs defaults. */
--color-accent-50: var(--color-indigo-50);
--color-accent-100: var(--color-indigo-100);
--color-accent-200: var(--color-indigo-200);
--color-accent-300: var(--color-indigo-300);
--color-accent-400: var(--color-indigo-400);
--color-accent-500: var(--color-indigo-500);
--color-accent-600: var(--color-indigo-600);
--color-accent-700: var(--color-indigo-700);
--color-accent-800: var(--color-indigo-800);
--color-accent-900: var(--color-indigo-900);
--color-accent-950: var(--color-indigo-950);
/* Your preferred gray scale. Zinc is closest to the qwik-docs defaults. */
--color-gray-50: var(--color-zinc-50);
--color-gray-100: var(--color-zinc-100);
--color-gray-200: var(--color-zinc-200);
--color-gray-300: var(--color-zinc-300);
--color-gray-400: var(--color-zinc-400);
--color-gray-500: var(--color-zinc-500);
--color-gray-600: var(--color-zinc-600);
--color-gray-700: var(--color-zinc-700);
--color-gray-800: var(--color-zinc-800);
--color-gray-900: var(--color-zinc-900);
--color-gray-950: var(--color-zinc-950);
}
To learn more about Tailwind theme configuration, check out the Tailwind CSS documentation.
Theming
qwik-docs's color theme is controlled by overriding its custom properties, the same as Astro Starlight. These variables run through the UI: a range of gray shades for text and background colors, and an accent color for links and current-item highlighting.
Set them in your global stylesheet under :root for dark mode and :root[data-theme='light'] for light mode:
/* src/styles/custom.css */
:root {
/* Accent color used for links and current-item highlighting. */
--sl-color-accent-low: hsl(280, 54%, 20%);
--sl-color-accent: hsl(280, 100%, 60%);
--sl-color-accent-high: hsl(280, 100%, 85%);
}
:root[data-theme='light'] {
--sl-color-accent-high: hsl(280, 80%, 30%);
--sl-color-accent: hsl(280, 90%, 60%);
--sl-color-accent-low: hsl(280, 88%, 90%);
}
The gray scale runs --sl-color-gray-1 through --sl-color-gray-6, with --sl-color-white and --sl-color-black at the ends.
Light mode adds --sl-color-gray-7.
See design-tokens/props.css for the complete set of color, shadow, type-scale, and layout tokens.
Color theme editor
Use the sliders below to modify the accent and gray color palettes. The dark and light preview areas show the resulting colors, and the whole page updates to preview your changes.
Use the Contrast Level option to choose which of the Web Content Accessibility Guideline color contrast standards to meet.
When your changes look right, copy the generated CSS or Tailwind code and use it in your project.
The CSS variant sets --sl-color-accent-* and --sl-color-gray-* — paste it into a custom CSS file.
The Tailwind variant sets --color-accent-* and --color-gray-* — paste it into the @theme block of your Tailwind CSS file.