---
name: style-topics
description: Stylesheets written as topics, so a user's AI can make a new look for d2. The same spec as AiSpec:style-topics, in OpenSpec's format.
tags: ai, spec, openspec
---

# style-topics Specification

## Purpose

Let a user change how every d2 page looks by asking their AI (the colours, the fonts and the logo text) with nothing to install and no code to change. This is [[AiSpec:style-topics]] in OpenSpec's requirement-and-scenario format.

## Requirements

### Requirement: Stylesheets as topics
The system SHALL accept a stylesheet written as a topic in category `Style`, through the ordinary topics API.

#### Scenario: AI makes a stylesheet
- **WHEN** the user's AI saves `Style:yahoo` with valid tokens and `brand: YAHOO`
- **THEN** the save reply has `style: {ok: true}`
- **AND** the stylesheet is listed under Style topics on the Styles page

### Requirement: Logo text
The system SHALL show a Style topic's `brand` as the logo text on every page while that stylesheet is in use.

#### Scenario: Picking a branded stylesheet
- **WHEN** the user picks `Style:yahoo` on the Styles page
- **THEN** every page shows YAHOO next to the logo

### Requirement: Broken stylesheets are harmless
The system MUST NOT apply a Style topic that has errors; it SHALL list it with its errors instead.

#### Scenario: Unknown token
- **WHEN** a Style topic sets a token that doesn't exist
- **THEN** the save reply lists the error
- **AND** the Styles page shows the topic as "Has errors" with no button to use it

#### Scenario: A broken stylesheet in the cookie
- **WHEN** the browser's cookie names a Style topic that has errors
- **THEN** pages use the default stylesheet
