Themes
A theme is a CSS file that changes how the sign-in, consent, and account pages look. masks loads it after its own stylesheet.
- In development, masks reads themes on every request.
- Everywhere else, masks reads them once and keeps them until the server restarts. A new or changed file applies after a restart.
A logo and a color
Section titled “A logo and a color”You can set a logo and a color without a stylesheet. A manager who holds masks:manage sets both
in /manage, under Settings, then General, then Branding.
- The logo replaces the tenant’s initial at the top of the sign-in, consent, and account pages. It can be an image up to 4 megabytes. masks stores it at 256 pixels square.
- The Accent color tints the buttons and headings on those pages. It sets
--signaland--brass, and sets--signal-inkto black or white, whichever reads better on it.
A theme loads after both, and can override them.
Naming a theme
Section titled “Naming a theme”masks reads themes from the directory that MASKS_THEMES_PATH names. Without it, masks reads the
app’s themes directory, which is /rails/themes in the container image. A file’s name sets where
it applies.
| File | Applies to |
|---|---|
acme.css |
Every sign-in and account page of the tenant acme. |
acme/<client_id>.css |
The sign-in and consent pages of acme while the person signs in to that client. |
- A page loads the tenant’s file first and the client’s file second. The client’s rules win when the two files disagree.
- The account page names no client, so it loads only the tenant’s file.
- masks skips a file larger than 256 kilobytes, and the server logs a warning.
Adding a theme
Section titled “Adding a theme”-
Write the stylesheet. Set the custom properties below on
.auth-page. Set them once for light mode, and once inside@media (prefers-color-scheme: dark)for dark mode:.auth-page {--ground: #f4f7fb;--surface: #eaf0f7;--line: #d3dce7;--ink: #14202e;--signal: #1f5fbf;--signal-ink: #ffffff;}@media (prefers-color-scheme: dark) {.auth-page {--ground: #151c26;--surface: #1d2632;--line: #2e3a49;--ink: #e6edf5;--signal: #7fb0ff;--signal-ink: #0d1520;}}A property you leave unset keeps masks’ default.
-
Mount the directory into the container:
services:masks:volumes:- masks-storage:/rails/storage- ./themes:/rails/themes:ro -
Restart the server.
masks serves the file from /themes/<digest>.css. The digest is a value computed from the file’s
contents, so it changes whenever the file changes. Browsers cache each version for a year.
Custom properties
Section titled “Custom properties”A custom property is a CSS variable, a name that starts with --. Each one sets a color or a size
that masks uses across the pages.
| Property | |
|---|---|
--ground |
The page background. |
--surface |
Panels, cards, and fields that sit on the ground. |
--line |
Borders and dividers. |
--line-firm |
Borders of fields and of hovered or focused controls. |
--ink |
Body text. |
--ink-soft |
Secondary text, hints, and labels. |
--brass |
Structural rules, the edge of the tenant’s mark, eyebrows, status labels, and the name beside an avatar. |
--brass-lit |
Focus rings and the border of a focused field. |
--signal |
The primary button, links, and selected controls. |
--signal-ink |
Text on a solid --signal fill. |
--bad, --bad-field |
Error text and the background behind it. |
--warn, --warn-field |
Warning text and the background behind it. |
--info, --info-field |
Informational text and the background behind it. |
--glow |
The background of pills and plain notes. |
--window |
A blurred image behind the top right of the page. url("/masks-public/icon.svg") by default. none removes it. |
--window-strength |
The opacity of that image, from 0 to 1. |
--pane |
The see-through fill of panels. Panels blur what is behind them. |
--pane-rim |
The border of panels. |
--pane-shine, --pane-sheen |
The highlight along a panel’s top edge, and the gradient across its face. |
--pane-shadow |
The shadow under panels. |
--bend |
The corner radius of panels and controls. |
A theme may also style any other selector on these pages. The properties above stay the same between releases. Class names can change.
What a theme can load
Section titled “What a theme can load”A theme does not change the pages’ content security policy. This policy tells the browser where a
page may load files from. Images and fonts load only from masks itself or from data: URIs. A
data: URI holds the file’s contents inside the stylesheet.
A theme must do one of these:
- Embed each image or font as a
data:URI. - Name a font installed on the device.
The browser refuses an @import or url() that points at another host.