Themes

A theme is data. It sets colors, a font, rounded corners, and a page width (tokens), the parts each kind of page shows (layouts), and how each kind of block looks (sections). The website draws every page from the theme, so no account ever installs or runs code.

!The Themes screen of a website.

!The Themes screen of a website, in dark mode.

!The Themes screen of a website, on a phone.

!The Themes screen of a website, on a phone in dark mode.

What a Theme Can Hold

  • Tokens: color_bg, color_ink, color_accent, color_muted, color_card (colors like #1d5bd8), font (system, serif, mono, inter, or brand), radius (0 to 32), and max_width (480 to 1600).
  • Layouts: for page, post, and doc, a list of parts from header, menu, sidebar, main, and footer. Main is required.
  • Sections: for a kind of block, spacing (sm, md, or lg), align (left or center), and background (none, card, or accent).

Every website starts with the built in Starter theme.

Brand Colors and Fonts

Every website gets the same choices, drawn from your own Brand Kit (Settings, Brand):

  • Use my brand color: a theme's color_accent can be the word brand instead of a color code. The page uses your Brand Kit accent, moved a little if it would not be readable on the theme's background (4.5 to 1). With no accent in the kit, the Starter accent is used.
  • Use my brand ink: color_ink can be brand. The page uses your Brand Kit color for text only when it reads well on the background (7 to 1); otherwise the Starter ink stays.
  • Inter: the product's own font, built in. It is served from your website's own address.
  • My Brand Font: the font file in your Brand Kit, with its family name, served from your website's own address. A kit with no font file draws Inter instead.

No page ever loads a font from another site. A typed color still works, and a theme that holds a font address or script is refused. Changing the Brand Kit shows on the website after the next publish.

Stylesheet

A theme can also hold a stylesheet for the whole website, written in CSS. It is placed after the theme's own styles and before any Custom Section's styles, so it can restyle the page or style the HTML in your Custom Sections once for every page.

  • It is cleaned when you save, the same way as a Custom Section's CSS: @import, any file that is not on your own website, expression(), and behaviors are removed, and each removal is listed with a plain reason.
  • It is not scoped: it is the website's stylesheet, so its rules reach the whole page.
  • It can use these names from the theme: var(--bg), var(--ink), var(--muted), var(--card), var(--line), var(--accent), var(--accent-ink), var(--radius), and var(--font).
  • It is saved compact, with no added spaces or line breaks. A gradient is always kept. A small picture written in as a data: address (SVG, PNG, JPEG, GIF, WebP, or AVIF, up to 65,536 characters each) is kept; an SVG picture with a script, an event handler, a frame, or a link to anything outside itself is removed, and so is every other kind of data: address. The @view-transition rule is removed, and pages change without it.
  • It can be up to 1,000,000 characters once it is cleaned (what is saved is what counts). Over the limit, the save is refused and the message says the limit. Saving a theme without a stylesheet keeps the one it has.
  • Visitors get it as its own file. When your website is built, the stylesheet is kept as one file at its own address on your website (it looks like /_mdo/theme. and a short code, then .css), and every page links to it instead of carrying a copy. Browsers keep that file, so a long stylesheet is downloaded once, not on every page. When you change the stylesheet and publish again, the code changes, so visitors get the new file right away. The Preview in the workspace and the page builder show the same styles in the same order.
  • Your files are your own. The stylesheet file is kept in your account's own storage and is served only at your own website's address. No other account's website can ask for it.
  • A theme with no stylesheet draws exactly as before. The names above are added to a page only when it has a stylesheet or a Custom Section.
  • An AI agent saves a stylesheet like any other theme change, with the same cleaning.

See Custom Sections for what is allowed in CSS and why.

Changing Part of a Stylesheet, and Going Back

  • Find and Replace (the Find and Replace button on a theme, action sites.theme.css.patch): give the text to find and the text that replaces it. The text must be in the stylesheet once. If it is missing or in it more than once, nothing is saved and the message says how many times it was found. Switch on Replace every match to change every one.
  • History (the History button on a theme, actions sites.theme.css.versions and sites.theme.css.restore): every save of a stylesheet, from the screen or an assistant, is kept as a numbered version, with who saved it and when. View shows the text of any version. Restore makes that version the newest one. Nothing is removed. The first save of a theme that already had a stylesheet keeps the old one as version 1.
  • The change shows on the live website after the next publish, the same as any stylesheet change.

Actions

  • See the themes (action sites.theme.list).
  • Add a theme, or change one (action sites.theme.save), including its Stylesheet.
  • Remove a theme (action sites.theme.remove): hidden and kept. A theme a website uses cannot be removed.

Data Only

A theme that holds anything else, other than its stylesheet (which is cleaned, not refused), is refused with a plain message: an unknown key, a value of the wrong kind, markup, a script address, a style function, or an import. Nothing is stored when a theme is refused.

Where to Find It

Websites, then Themes. Anyone who may see websites sees it; changing a theme needs edit access.