---
name: style-topics
description: Stylesheets written as topics, so a user's AI can make a new look for d2. Built in proto1 v0.7.0.
tags: ai, spec
status: done
---

# Style topics

An example AI specification: the one behind the [Styles](/styles) page's "Style topics" section, kept up to date while it was built.

## Goal

Let a user change how every d2 page looks by asking their AI, for example *"the logo says YAHOO, the background is dark green and the fonts are magenta"*, with nothing to install and no code to change.

## Requirements

- A stylesheet is a topic in category `Style`, written through the ordinary topics API.
- It can change every colour and font token, and the logo text.
- A broken stylesheet must never break a page: it is listed with its errors and can't be picked.
- The AI learns the format from [[Skill:diesel2]]; the user learns the steps from [Help](/help#make-your-own-stylesheet).

## Design

- Frontmatter: `brand` (logo text, 1 to 24 characters), `base` (the built-in it starts from), `fonts` (a Google Fonts link).
- A ` ```style ` block sets tokens for light and dark mode; ` ```style dark ` overrides dark mode only. Tokens not given come from the base.
- Only the known tokens are allowed, and values are colours or font stacks: no `url(…)`, `;`, `{` or `}`.
- Saving reports problems as `style: {ok, errors}` in the `PUT` reply.
- The choice is kept in the `d2style` cookie, holding the topic id (`Style:yahoo`).

## Open questions

- None left. A per-user default will come with real login.

## Status

Done: built in proto1 v0.7.0. The decision is logged in [[Log:diesel2]].
