Components
The shared controls Moat pages are built from. Everything on this page is the real stylesheet, so what you see here is what ships.
Tokens#
Load assets/moat/tokens.css, then assets/moat/components.css. Every colour, size, radius, layer and duration comes from a --twc-* custom property, and every rule carries the light value as a fallback, so the controls also render on a page without tokens.css. On a partner page, set any token on :root or an ancestor and your value wins; tokens that carry text (-fill, -text, --twc-secondary-text) take only values that reach 4.5:1.
<link rel="stylesheet" href="https://moat.page/assets/moat/tokens.css"> <link rel="stylesheet" href="https://moat.page/assets/moat/components.css">
| Token | Use | Contrast |
|---|---|---|
--twc-text | Body text, headings, labels | 16.95:1 on the page |
--twc-secondary-text | Secondary and meta text at any size (widgets read this name, so a host pastel cannot replace it) | 6.15:1 |
--twc-text-muted | Tertiary text, 16px and larger, on the page or a card only | 4.63:1 |
--twc-accent-fill, --twc-on-accent | Button fills and links (text-carrying, so only AA values) | 5.80:1 with white text |
--twc-accent | Borders, rings and tints, the decorative accent a host may set to a pastel | 3:1 or better for borders |
--twc-error-fill, --twc-success-fill, --twc-warning-fill | Status fills with white text | 4.83, 5.02 and 5.02:1 |
--twc-z-dropdown, --twc-z-overlay, --twc-z-modal, --twc-z-toast | Layers: menus under a host's fixed nav, a modal's scrim and dialog above it, toasts on top | 1000, 1050, 1055, 1090 |
Button#
Label text (14px, weight 500), 40px tall, pill shaped. Name the action: "Save changes", not "Submit". Use one primary button per view.
| State | How to set it | What changes |
|---|---|---|
| Hover | Pointer over the button | Darker fill, or a tinted ground for secondary and ghost |
| Focus | Keyboard focus (:focus-visible) | 2px accent ring, 2px clear of the edge |
| Disabled | disabled, or aria-disabled="true" on a link | Faded, no hover, not-allowed cursor |
| Working | aria-busy="true" while a request runs | Spinner after the label, further clicks ignored |
<button type="submit" class="moat-btn moat-btn--primary">Save changes</button> <button type="button" class="moat-btn moat-btn--secondary">Preview</button> <a class="moat-btn moat-btn--ghost" href="../../">Cancel</a>
Field#
The class goes on the input, select or textarea. Text is 16px so phones do not zoom on focus. The label sits above, help and error text below, never inside as a placeholder.
| State | How to set it | What changes |
|---|---|---|
| Hover | Pointer over the field | Darker border |
| Focus | Focus (:focus-visible) | Accent border and 2px ring |
| Invalid | aria-invalid="true", plus a .moat-field-error linked by aria-describedby | Error border and ring; the message says how to fix it |
| Working | aria-busy="true" while a check runs | A slow shimmer, still editable |
| Disabled | disabled | Tinted ground, secondary text |
<label class="moat-field-label" for="email">Work email</label> <input class="moat-field" id="email" type="email" aria-invalid="true" aria-describedby="email-err"> <span class="moat-field-error" id="email-err">Enter an email address like [email protected].</span>
Toast#
One short line about something that just happened. Use role="status" for news and role="alert" for errors, and keep the words clear on their own, because colour is not the message.
<div class="moat-toast moat-toast--success" role="status">Profile saved. <a href="/profile/">View page</a></div>
Dialog#
A native <dialog> opened with showModal(), so focus stays inside and Escape closes it. Title, a short body, then actions with the main one last.
<dialog class="moat-dialog" id="confirm" aria-labelledby="confirm-title">
<form method="dialog">
<h3 class="moat-dialog__title" id="confirm-title">Delete your page?</h3>
<p class="moat-dialog__body">Partner apps that show your page are told it is gone.</p>
<div class="moat-dialog__actions">
<button class="moat-btn moat-btn--secondary" value="cancel">Keep page</button>
<button class="moat-btn moat-btn--danger" value="delete">Delete page</button>
</div>
</form>
</dialog>Set aria-busy="true" on the dialog while its action runs: the actions fade and stop taking clicks until you clear it.
Panel#
A card: one bordered surface that groups a record or a set of facts. Use it only where the grouping matters; spacing alone separates most content. The class is .moat-panel because .moat-card already names the profile page's sections.
Record
A static panel: border, card radius, the small shadow step.
Linked panel
The whole panel is the link: hover lifts it, keyboard focus rings it.
Loading
| State | How to set it | What changes |
|---|---|---|
| Hover, focus, pressed | Render it as an <a> or <button> | Stronger border and the default shadow; 2px accent ring; a 1px press |
| Disabled | aria-disabled="true" | Faded, no pointer events |
| Loading | aria-busy="true" | Content hidden behind a shimmer of the same size |
| Flush | .moat-panel--flush | No padding, for a table or list that runs edge to edge |
<section class="moat-panel"> <div class="moat-panel__head"><h3 class="moat-panel__title">Record</h3><span class="moat-panel__meta">Updated today</span></div> <p>…</p> </section>
Badge#
A short status word. The word carries the meaning and the colour repeats it, so each tone reads the same in grayscale.
Every tone reaches 4.5:1 (AA) or better on its tint in both schemes. A badge rendered as a link or button also gets the hover border and the focus ring.
<span class="moat-badge moat-badge--success">Active</span>
Tabs#
Use role="tablist" with role="tab" and aria-selected when the tabs switch panels on one page; use a <nav> of links with aria-current="page" when each tab is its own address. The segmented variant is for two to four filters.
<div class="moat-tabs" role="tablist" aria-label="Profile sections"> <button class="moat-tab" role="tab" aria-selected="true" aria-controls="p-about" id="t-about">About</button> <button class="moat-tab" role="tab" aria-selected="false" aria-controls="p-work" id="t-work" tabindex="-1">Work</button> </div>
Pager#
Page links in a <nav>. The current page carries aria-current="page"; a step that does not exist (no previous page) is a <span aria-disabled="true">, not a dead link. Set aria-busy="true" on the nav while the next page loads.
<nav class="moat-pager" aria-label="Pages"> <span class="moat-pager__item" aria-disabled="true">Previous</span> <a class="moat-pager__item" href="?page=1" aria-current="page">1</a> <a class="moat-pager__item" href="?page=2">2</a> <a class="moat-pager__item" href="?page=2">Next</a> </nav>
Empty, loading and error#
One block in place of the content: say what happened and give the next step. Loading keeps the block's size with skeleton lines, so nothing jumps when the content arrives. An error uses role="alert".
No connected sites yet
Sign in to a partner app with this email and it shows up here.
The list did not load
Check your connection and try again.
<div class="moat-state moat-state--error" role="alert"> <p class="moat-state__title">The list did not load</p> <p class="moat-state__text">Check your connection and try again.</p> <div class="moat-state__actions"><button class="moat-btn moat-btn--secondary moat-btn--sm">Try again</button></div> </div>
Scales and dark mode#
Corners use four steps: --twc-radius-sm 6px (small controls), --twc-radius-control 10px (fields, panels inside cards), --twc-radius-card 16px (cards) and --twc-radius-pill (buttons, badges). Elevation uses three: --twc-shadow-sm, --twc-shadow and --twc-shadow-lg. Space uses the 4px ladder --twc-space-1 to --twc-space-32 (the number times 0.25rem).
Moat's own pages follow the visitor's system setting, and <html data-theme="light"> or "dark" overrides it. Every control above reads its colours from the tokens, so it switches with them. On a partner page nothing switches by itself: the widgets and components follow your page's --twc-* values, so a dark page sets its own dark tokens.