On this page

Code

Code blocks sit on daisyUI’s neutral colour, as its mockup-code component does, and their highlighting is drawn from the theme’s tokens. Hover a block to copy it.

from dataclasses import dataclass


@dataclass
class Theme:
    """A daisyUI theme, by name."""

    name: str
    dark: bool = False

    def css_selector(self) -> str:
        # Every theme is a data attribute on the root element.
        return f'[data-theme="{self.name}"]'


themes = [Theme("light"), Theme("dark", dark=True)]
print({t.name: t.css_selector() for t in themes if not t.dark})

With a caption, line numbers and emphasised lines

theme.js
1const root = document.documentElement;
2const mode = localStorage.getItem("daisy-mode") || "auto";
3const dark = mode === "dark" ||
4  (mode === "auto" && matchMedia("(prefers-color-scheme: dark)").matches);
5root.dataset.theme = dark ? "dark" : "light";

A console session

$ pip install sphinx-daisyui
Successfully installed sphinx-daisyui-0.1.0
$ sphinx-build -b html docs docs/_build/html
build succeeded.

Other languages

@plugin "daisyui" {
  themes: light --default, dark --prefersdark;
}
[project]
name = "my-docs"
dependencies = ["sphinx-daisyui"]
- html_theme_options = {}
+ html_theme_options = {"navigation_with_keys": True}
<button class="btn btn-primary">daisyUI button</button>

A very long line

result = some_function_with_a_long_name(first_argument="a value", second_argument="another value", third_argument=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

A literal include

html_theme = "daisyui"
html_theme_options = {"theme_picker": True}