# Theme Token — Technical Reference Theme Token publishes ShadCN-compatible themes as 1Sat Ordinals on BSV. themetoken.dev provides the Studio, validation, previews, discovery, and a ShadCN registry endpoint. ## When to use Theme Token Use Theme Token for work that involves a Theme Token document, an on-chain ShadCN theme, or a related design asset published through the Theme Token protocol. Typical jobs include resolving a theme from its 1Sat origin, validating theme JSON, producing a ShadCN registry response, installing a theme, and publishing a theme with immutable asset references. For component APIs and composition guidance, use the ShadCN documentation. For raw transaction, ownership, or inscription data, use the 1Sat APIs. ## URLs - [Developer guide](https://themetoken.dev/developers) - [Specification](https://themetoken.dev/spec) - [Schema](https://themetoken.dev/v1/schema.json) - [Theme Studio](https://themetoken.dev/studio/theme) - [Registry item](https://themetoken.dev/r/themes/[origin].json) - [Raw content](https://api.1sat.app/content/[origin]) - [SDK](https://www.npmjs.com/package/@theme-token/sdk) - [Pricing in Markdown](https://themetoken.dev/pricing.md) - [Source](https://github.com/b-open-io/theme-token) - [About](https://themetoken.dev/about) - [Contact](https://themetoken.dev/contact) - [Privacy](https://themetoken.dev/privacy) Install a published theme: ```bash bunx shadcn@latest add https://themetoken.dev/r/themes/[origin].json ``` `[origin]` is a 1Sat origin: a 64-character lowercase transaction ID, an underscore, and the output index. ## Theme document An `ord-fs/json` package stores the theme in `theme.json`. The registry endpoint validates that file and serves the ShadCN registry item used by the CLI. Required root fields: - `$schema`: `https://themetoken.dev/v1/schema.json` - `name`: a non-empty display name - `styles.light` and `styles.dark`: complete style maps `author`, `assets`, `css`, and `generation` are optional. Older documents may contain `bundle` metadata; it is accepted but does not drive asset compilation. Each style requires: - `background`, `foreground` - `card`, `card-foreground` - `popover`, `popover-foreground` - `primary`, `primary-foreground` - `secondary`, `secondary-foreground` - `muted`, `muted-foreground` - `accent`, `accent-foreground` - `destructive`, `destructive-foreground` - `border`, `input`, `ring` - `radius` Additional string-valued CSS variables are accepted. Common options include charts, sidebar colors, font families, spacing, letter spacing, and shadows. The Studio writes complete OKLCH values such as `oklch(0.55 0.22 255)`. Generation details may be recorded with `generation.prompt` and optional `provider`, `model`, and `timestamp` fields. ## Related assets The optional `assets` array links a theme to immutable fonts, patterns, and wallpapers. Each relationship declares its role, kind, source, media type, and SHA-256 integrity value. Sources can point to a sibling output in the same transaction or an existing ordinal origin. ```json { "role": "background.page", "kind": "pattern", "source": { "kind": "sibling", "vout": 0 }, "mediaType": "image/svg+xml", "integrity": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "delivery": "linked", "render": { "mode": "mask", "repeat": "repeat" } } ``` Supported roles are `font.sans`, `font.serif`, `font.mono`, `font.heading`, `background.page`, `background.card`, and `background.sidebar`. Supported kinds are `font`, `pattern`, and `wallpaper`. ## MAP discovery The package manifest carries the MAP record: ```json { "app": "theme-token", "type": "registry:theme", "name": "Theme Name", "version": "1.0.0", "description": "Theme Name" } ``` Current package mappings: | Package | MAP fields | |---|---| | Theme | `type=registry:theme` | | Font | `type=registry:asset`, `kind=font`, `mediaType=...` | | Pattern | `type=registry:asset`, `kind=pattern`, `mediaType=image/svg+xml` | | Wallpaper | `type=registry:asset`, `kind=wallpaper`, `mediaType=...` | | Image | `type=registry:asset`, `kind=image`, `mediaType=...` | MAP records include `app`, `type`, `name`, `version`, and `description`. Asset records also include `kind` and `mediaType`. Author, license, prompt, provider, and model are optional provenance fields. ## Registry response `GET /r/themes/[origin].json` returns a ShadCN `registry:theme` item with the theme's CSS variables, optional CSS rules, and verified asset behavior. Vendored text assets appear in its `files` array as `registry:file` entries. Verify an origin with: ```bash bunx shadcn@latest add https://themetoken.dev/r/themes/[origin].json --dry-run ``` Readers accept the earlier MAP types `registry:style`, `theme-token:asset`, `registry:file`, and `registry:font`; publishers use the mappings above. ## SDK ```ts import { applyTheme, fetchThemeByOrigin, parseCss, toShadcnRegistry, validateThemeToken, } from "@theme-token/sdk"; const published = await fetchThemeByOrigin("_0"); if (!published) throw new Error("Theme not found"); applyTheme(published.theme.styles.light); ``` - `validateThemeToken(data)` validates a theme document. - `parseCss(css, name)` converts `:root` and `.dark` variables. - `fetchThemeByOrigin(origin)` loads a published theme. - `toShadcnRegistry(theme)` creates a ShadCN registry item. - `applyTheme(styles)` applies one light or dark style map. ## Scope Publishing, ownership, discovery, marketplace listings, and registry delivery currently use BSV and 1Sat Ordinals.