Skip to main content

datasette-themes

A Datasette plugin to make theming slightly easier. Lets a visitor pick one from the hamburger (navigation) menu and gives them a preview interface.

Features:

  • Off by default — Datasette looks exactly as it normally does until a visitor picks a theme.
  • Live preview — you can see which theme works best for you
  • Theme per User — the chosen theme is remembered in a cookie and injected server-side on first paint via the extra_css_urls hook.
  • Full restyles — each theme can change typography, spacing, radii, shadows, tables, facets, etc.

Bundled themes

Theme Description
Vercel Taking some hints from Vercel-like pages
Dark A modern dark theme.
Solarized Variation of Solarized Dark palette.
Sepia An "aged paper" light theme with a serif reading feel.
RollerCoaster RollerCoaster Tycoon themed. Inspired by koaning/rct-css.

Installation

datasette install datasette-themes

Usage

Open Datasette, click the hamburger menu (top right) and choose Themes. On the picker page:

  • Click a theme name to preview it — the page and the embedded table restyle, without changing your saved choice.
  • Click Use "…" to save that theme in a cookie so it applies across the whole site and future visits (in this browser).
  • Click Reset to default to clear the cookie and return to Datasette's stock look.

Configuring the preview table

By default the picker embeds the first table of the first database. To point it at a specific table, set preview_table in the plugin config:

{
  "plugins": {
    "datasette-themes": {
      "preview_table": "aom_units/units"
    }
  }
}

Try the demo locally

The repo includes a demo that loads real sample databases (Age of Mythology units with inline images, earthquakes, Everest climbs, student sleep/GPA) and runs the plugin alongside datasette-render-images:

make dev          # builds the demo databases if needed, then serves on :8123

Then open http://localhost:8123/-/themes. Inside Conductor, the Run button is wired to the same command via .conductor/settings.toml.

The demo databases are rebuilt from the public instance at datasette.exe.xyz (raw .db downloads are disabled there, so demo/build.py reconstructs them from the CSV/SQL API and re-fetches the unit icon image blobs). They are gitignored; rebuild with:

make data

Adding your own themes

You don't need to touch the plugin's internals to add a theme. Serve a CSS file from your Datasette (e.g. datasette --static static:./static) and register it under the themes plugin config — each entry maps a theme id to a label and stylesheet url:

{
  "plugins": {
    "datasette-themes": {
      "themes": {
        "corp": { "label": "Corp Brand", "url": "/static/corp.css" }
      }
    }
  }
}

Your theme then shows up in the picker (with live preview) and behaves exactly like a bundled one. Root-relative urls are resolved against Datasette's base_url; absolute https://… URLs are used as-is.

Showing only your own themes

Use bundled_themes to control which shipped themes are offered: true (default) shows all of them, false hides them all, and a list is an allowlist (e.g. ["dark", "rct"]). To show only your own, hide the bundled ones and register your own:

{
  "plugins": {
    "datasette-themes": {
      "bundled_themes": false,
      "themes": {
        "corp": { "label": "Corp Brand", "url": "/static/corp.css" }
      }
    }
  }
}

A hidden or unregistered theme can't be applied, even via an old cookie or a ?_theme_preview= link.

Editing the bundled themes from source

If you're hacking on the plugin itself, the bundled themes are plain CSS files under datasette_themes/static/, registered in the THEMES dict in datasette_themes/__init__.py. Datasette serves them with no cache headers, so on an editable install you can edit a .css file and just refresh the browser.

How it works

Hook Role
extra_css_urls Injects the active theme's CSS URL (from the ?_theme_preview= query param, else the ds_theme cookie). Returns nothing when no theme is selected.
menu_links Adds the Themes item to the hamburger menu.
register_routes /-/themes (picker page) and /-/themes/set (saves the cookie and redirects back).

CSS files are served by Datasette's built-in plugin static handling at /-/static-plugins/datasette_themes/<file>.css.

Development

make test         # uv run --with-editable '.[test]' --with pytest-asyncio pytest

Credits

The RollerCoaster theme's pixel font is Departure Mono (bundled under datasette_themes/static/, see the included license) and the aesthetic is adapted from rct-css.

Metadata

Release files for datasette-themes 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datasette-themes 0.1
File Size Uploaded Provenance Actions
datasette_themes-0.1.tar.gz 44.8 kB Without provenance Details for datasette_themes-0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for datasette-themes 0.1
File Interpreter ABI Platform Actions
datasette_themes-0.1-py3-none-any.whl Python 3 none any Details for datasette_themes-0.1-py3-none-any.whl

Total release size: 88.0 kB

Release files / datasette_themes-0.1.tar.gz

Download URL datasette_themes-0.1.tar.gz
Size 44.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c2a34590ae7616ab4d0a81911a63869b5c22788f3dfcd8af7acba9eac2e885f5
BLAKE2b-256 checksum
How to use checksums
933e33ef530ed41ba4246fd2c0951f77b469093181383814edbdb90a819f1c4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / datasette_themes-0.1-py3-none-any.whl

Download URL datasette_themes-0.1-py3-none-any.whl
Size 43.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2eeb1b1b254d9fa776e0027c08c433ffad011834199979b68380f6919a66c685
BLAKE2b-256 checksum
How to use checksums
eaab58b5265ebdc8bd3218450f32ab352545b4e5b3a5bae7a60b370b492dbef0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for datasette-themes 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page