Aa 0.14.1

Styling

aa.css draws every block as Design system 1’s prose sheet draws the same Markdown read on a page: a line a square, a square between two blocks and two before a heading. Every measure and colour is a --ds-* token with its value as the fallback, so a page without Design system 1 still gets them, and a page with it gets its theme, scale and accent. One thing changes with an --aa-* property.

Drawn as prose

Every block on Design system 1’s squares: a line a square, a square between blocks, two before a heading.

What it stores

The editor brings the sheet itself, as a Design system 1 component does: the first editor in a document, or in a shadow root, puts it first in the head or that root before it draws, with Design system 1’s context.css (the toolbar), overlay.css (the sheet on touch) and its two fonts inside it. There is nothing to import. A page that wants the rules before any script runs, or whose Content Security Policy allows no inline style or data: fonts, imports the sheet itself, and the editor then brings no second copy:

import '@0001-labs/aa/aa.css'

That sheet imports ds1/ and fonts/ from beside it; the package carries both, and so does a copy made with Sync 1. See Design system 1 for the measures it shares.

.notes .aa {  --aa-typeface: "Söhne", system-ui;  --aa-heading-gap: calc(3 * var(--ds-unit, 20px));  --aa-link: var(--ds-sharp-blue);}

The editor’s own rule, on .aa and aa-editor, weighs nothing, so any rule of the page’s for them wins. Its rules for blocks are a class and an attribute each, which a product’s rule of the same weight outweighs, since the editor puts aa.css before the page’s own sheets.

PropertyDefaultWhat it sets
--aa-typeface--ds-typeface-regular, --typeface-regular, system-uiThe text’s face.
--aa-typeface-bold--ds-typeface-medium, --typeface-medium, then the text’s faceBold words.
--aa-typeface-heading--ds-typeface-medium, --typeface-medium, then the text’s faceHeadings.
--aa-typeface-mono--typeface-mono, then Aa MonoCode.
--aa-size--ds-type-size-default, 14pxThe text’s size.
--aa-lineOne squareThe line height.
--aa-weight--ds-type-weight-default, 400The text’s weight.
--aa-weight-bold--ds-type-weight-bold, 500Bold words.
--aa-weight-heading--ds-type-weight-bold, 500Headings.
--aa-letterspacing--ds-type-letterspacing-default, −0.3pxThe text’s tracking.
--aa-font-features--ds-font-features, normalfont-feature-settings.
--aa-h1--ds-type-size-display, 20pxA title, #. It stands on two squares.
--aa-h2--ds-prose-h2-size, 17px##.
--aa-h3--ds-prose-h3-size, 15px###.
--aa-code-size--ds-code-text-size, 13pxCode, in a line and in a block.

Sizes in pixels are multiplied by the scale. Deeper headings take the text’s size.

PropertyDefaultWhat it sets
--aa-gapOne squareThe room between two blocks. Bullets in a list stand with none.
--aa-heading-gapTwo gapsThe room before a heading that follows another kind of block.
--aa-indentOne squareA bullet’s room for its marker, and each level a list is nested by.
--aa-picture-radius--ds-radius, 4pxA picture’s corners.
PropertyDefaultWhat it sets
--aa-color--ds-text-color, currentColorThe text.
--aa-linkcurrentColorA link, underlined. A link given a text colour wears that colour instead.
--aa-markercurrentColorA bullet’s dot and a list’s numbers.
--aa-done--ds-text-color-muted, the text at 55%The words of a ticked box.
--aa-placeholder--ds-input-placeholder-color, #797979 (#ababab dark)Placeholders and hints.
--aa-rule--ds-border-color, #d8d8d8 (#3d3d3d dark)Hairlines: a code block’s frame, a divider, a callout’s line, a box’s edge, a table’s rows, the find bar.
--aa-quote-rule--ds-text-color-muted, #5f5f5f (#cacaca dark)A quote’s hairline.
--aa-table-ruleThe hairlineA table’s row lines.
--aa-table-headerThe textA table’s first row.
--aa-code-fill--ds-fill, #e6e6e6 (#3c3c3c dark)Code in a line.
--aa-code-papertransparentA code block’s ground.
--aa-highlight--ds-yellow, --yellow, HighlightHighlighted words, ==…==, and find’s matches.
--aa-highlight-ink--ds-black, the textThe words on the highlight.
--aa-text-selectionThe text at 15%Selected words, drawn as one rounded shape over their lines.
--aa-selection--aa-text-selectionA selected or lifted block.
--aa-accent--ds-sharp-blue, HighlightAnother person’s caret and its avatar.
--aa-prompt--ds-focus-ring, #594dffA prompt to AI, its caret and what is asked in a comment.
--aa-shimmer-color--ds-accent-color, --accent-color, --apple-green, HighlightThe band that passes through corrected words, and through words waiting for AI.
--aa-comment-fill--ds-orange at 28%Commented words.
--aa-comment-fill-open--ds-orange at 55%The open thread’s words, and a new thread’s.

Words written in a colour, <span color="red">, are drawn in a dark ink of Design system 1’s palette on light paper and a light one on dark, so they stay readable. --aa-color-<name> changes one.

PropertyLightDark
--aa-color-gray--ds-darker-grey, #797979the same
--aa-color-red--ds-danger-color, #de0331#ff5f5f
--aa-color-orange--ds-warning-color, #4c3f1a#fec20d
--aa-color-green#026d5b#99ff73
--aa-color-blue#0275fa#69d8fb
--aa-color-purple#e63aaf#f5aad1

The colours are TEXT_COLORS; see Formatting.

The toolbar, the menus, the find bar and a prompt stand outside the editor, at the end of the page’s body, or in the dialog the editor is in. Properties for them are set on :root, or on .aa-controls itself.

PropertyDefaultWhat it sets
--aa-menu-fill--ds-black, #2a2a2a (--ds-slate, #1e1e1e dark)The block and slash menu’s rows, and the toolbar’s field for AI. Set on .aa-controls.
--aa-menu-ink--ds-white, #ffffffTheir words. Set on .aa-controls.
--aa-menu-hoverThe fill mixed 22% toward the inkThe row the pointer or the arrows are on. Set on .aa-controls.
--aa-menu-radius--ds-radius, 4pxThe menu’s outer corners.
--aa-controls-layer1000The z-index they stand on.

The toolbar itself is Design system 1’s context bar, drawn by its context.css with its own --ds-context-* properties.

Aa writes these itself. Read them in a product’s rules; do not set them.

PropertyWhat it is
--aa-sfThe scale: --ds-sf, else --sf, else 1.
--aa-unit, --aa-squareThe square: --ds-unit, else --1, else 20px multiplied by --sf.
--aa-rule-colorThe hairline, from --aa-rule.
--aa-depthHow deep a list item is nested.
--aa-columnsHow many columns a table row or a set of columns has.
--aa-callout-iconA callout’s icon.
--aa-personA person’s colour, in comments.
--aa-mutedThe muted ink, in comments.
--aa-selection-mask, --aa-selection-box, --aa-selection-width, --aa-selection-heightThe shape of selected words.
--aa-glisten-delayWhere a block’s glisten starts.
--aa-safe-bottomThe home indicator’s inset under a docked bar.

Two fonts come with the editor’s styles, with their licence in fonts/LICENSE.md:

  • Arrows are always Inter. “Inter Arrows” is Inter’s arrows alone, limited by unicode-range to the arrow blocks. It stands first in every font Aa sets, code included, so → and ⇧ are Inter’s whatever the face. A product’s own font stack on Aa’s elements starts with it too.
  • Code is Aa Mono, Iosevka cut down to what code uses. It comes after --aa-typeface-mono or --typeface-mono, then a system monospace, so code never falls back to a serif when the product’s font has not loaded.
.aa { --aa-typeface: "Inter Arrows", "Söhne", system-ui; }

The fallbacks are light-dark() pairs, so the editor follows the page’s color-scheme. Declare one, or load Design system 1’s theme, which declares it:

:root { color-scheme: light dark; }

With no color-scheme, light-dark() takes its light colour on every page, a dark one too.

A build that lowers light-dark() for older browsers needs a color-scheme declared in that same build, or Design system 1’s theme script. Without one, the lowered colours, the toolbar’s black fill among them, draw nothing.

With forced colours, the selection, the shimmer and the comments’ tints give way to the system’s own colours. With reduced motion, nothing moves: the shimmer and the glisten only fade.

Every measure is multiplied by the page’s scale, Design system 1’s --ds-sf, or --sf. On a phone the page sets it with Design system 1’s scaling module, and the square, the type, the rows and the menus grow together:

import { startScaling } from '@0001-labs/design-system-1/ds1/1-root/scaling'startScaling()

Set the scale on the page rather than --aa-sf on the editor: the toolbar and menus stand outside the editor and read it from the page. Hairlines stay one pixel. See Scaling and On a phone.

The editor’s element and its blocks carry what a product’s rules can reach:

SelectorWhat it is
.aa, aa-editorThe editor.
.aa-blockA block, one a child.
[data-kind]Its kind: paragraph, heading, bullet, quote, code, divider, callout, table, equation or columns.
[data-level], [data-checked], [data-number]A heading’s level, a box’s state, a numbered item’s number.
[data-callout], [data-folded]A callout’s kind, and whether it is folded.
[data-selected]A selected block.
.aa-b, .aa-i, .aa-u, .aa-s, .aa-c, .aa-highlight, a.aa-link, [data-color]Bold, italic, underlined, struck, code, highlighted, linked and coloured words.
.aa-atom[data-atom]An atom, by its name.
.aa-controls, .aa-toolbar, .aa-menu, .aa-findThe controls, the toolbar, a menu, the find bar.