Styling

tangle.css is small and built on custom properties and plain selectors, so it's easy to fit to your blog's look.

Custom properties

PropertyDefaultUsed for
--tangle-accent#246bce (dark: #75a7ff)Color of numbers, choices and formula parameters without their own color.
--tangle-soft14%Strength of the hover and drag highlight.
--tangle-tint8%Strength of the resting tint behind numbers, choices and text the reader can change. 0% turns it off.
--tangle-surface#fff (dark: #22201d)Background of the typing field and text of the "drag" hint.
--tangle-error#c9382bBroken outputs and formula errors.
--tangle-muted55%Strength of the punctuation in a <t-call> or <t-tag>.
--tangle-code-tag, --tangle-code-attr, --tangle-code-string#6f5cbd, #b45b1b, #147a68 (dark: #b9a8ff, #ffad66, #5ed5bd)Syntax highlighting in <t-call> and <t-tag>: tag names, attribute and argument names, and strings. Values the reader can change use the accent color.
--tangle-colorSet per element from a variable's color attribute.
--tangle-dag-1 … --tangle-dag-8, --tangle-dag-noteblue, orange, teal, magenta, violet, ochre, green, red; gray (each with a dark variant)The colors a <t-formula-dag> gives the formulas others use, in order, and its notes. See Formula DAGs.
--tangle-chart-grid, --tangle-chart-text, --tangle-chart-font12%, 60%, 12px system fontStrength of chart gridlines and labels, and their font. See <t-vega> and <t-obsplot>.

Set them on :root to restyle the whole site, or on any container to restyle part of a page:

Brew 2 cups with g of coffee.

The stylesheet behind that example:

Selectors and states

SelectorMatches
t-num, t-choice, t-select, t-text, t-out, t-call, t-tagThe elements themselves. t-select[aria-expanded="true"] while its menu is open.
.t-call-key, .t-call-sep, .t-call-open, .t-call-closeThe parts a <t-call> adds: name=, the commas, fn( and ). t-call.is-multiline while it wraps one argument per line. <t-tag> has the same parts as .t-tag-*.
.t-code-punct, .t-code-tag, .t-code-attr, .t-code-string, .t-code-fnThe syntax-highlighting tokens inside those parts.
.t-tag-flagA boolean attribute in a <t-tag>, which toggles it. .is-off while the attribute is off.
.t-tag-previewThe live element below a <t-tag>'s code.
t-math [data-tangle-param]A \tangle{} inside a formula.
[data-tangle-param]Anything draggable: a <t-num>, a \tangle{}, or your own element.
t-math .tangle-valA \val{} inside a formula. Unstyled by default.
.is-hotEvery number bound to the variable under the pointer.
.is-activeEvery number bound to the variable being dragged or edited.
t-num::afterThe "drag" hint shown on hover.
html.tangle-draggingThe page, during a drag.
.tangle-editorThe typing field. .is-invalid while it holds something unparseable.
.tangle-menuThe menu of a <t-select>: an input over a ul of options. li.is-highlighted is the one Enter picks, li[aria-selected="true"] the current one.
t-out.is-errorAn output whose expression threw.
.tangle-math-errorThe message shown in place of a formula that doesn't parse.
.tangle-dag-card, .tangle-dag-caption, .tangle-dag-note, .tangle-dag-chip, .tangle-dag-resetThe parts of a <t-formula-dag>. See Formula DAGs.
t-panel::part(header), ::part(label), ::part(toggle), ::part(body)The pieces of a floating panel. t-panel[collapsed] while it's minimized. See <t-panel>.
t-paint::part(toolbar), ::part(button), ::part(paper), ::part(canvas)The pieces of a drawing canvas. See <t-paint>.
t-sketch::part(board), ::part(palette), ::part(button), ::part(swatch), ::part(menu), …The pieces of a whiteboard. See <t-sketch>.
.tangle-vegaA Vega chart. .is-loading until Vega has loaded; .tangle-vega-error replaces it on failure. See <t-vega>.
.tangle-graph, .tangle-graph-node, .tangle-graph-edge, .tangle-graph-label, .tangle-graph-tooltipThe parts of a <t-graph>. .is-picked on the picked node; --node and --edge hold each one's color. See <t-graph>.
.tangle-obsplotAn Observable Plot chart. .is-loading until Plot has loaded; .tangle-obsplot-error replaces it when loading fails or the expression throws. See <t-obsplot>.

Recipes

/* No "drag" hint */
t-num::after { display: none; }

/* Make computed results in formulas stand out */
t-math .tangle-val { color: var(--tangle-accent); }

/* A dotted underline instead of the tint */
t-num, t-choice, t-select, t-text {
  --tangle-tint: 0%;
  padding-inline: 0;
  border-bottom: 1px dotted currentColor;
}

/* Style a scope as a card (scopes have display: contents by default) */
t-scope.card { display: block; padding: 1rem; border: 1px solid #ddd; border-radius: 8px; }

Formula DAGs

A <t-formula-dag> draws each formula as a .tangle-dag-card, holding the rendered TeX and a .tangle-dag-caption. The SVG .tangle-dag-edge and .tangle-dag-head are its arrows. Each colored part, from a formula's output and its uses to its arrows and notes, sets --tangle-dag-c to its color. States:

SelectorMatches
.tangle-dag-card.is-selectedThe formula picked with name.
.is-dimCards and arrows outside what the hovered formula uses and is used by.
[data-fdag-out], [data-fdag-use]A formula's output symbol, and each place it's used. .is-hot while its chip or a use is under the pointer.
.tangle-dag-note, .tangle-dag-tint, .tangle-dag-note-arrowA note's label, the tint behind what it marks, and its arrow. .is-hovered on the lifted one.
.tangle-dag-chipA legend chip: [data-tangle-param] for a number, .is-output for a value, .is-error when it threw.
.tangle-dag-reset.is-changedThe Reset button, once a number moved.

To use your own palette, set the colors on :root, or on the element:

t-formula-dag {
  --tangle-dag-1: #0f766e;
  --tangle-dag-2: #9333ea;
}

Dark mode

The defaults follow prefers-color-scheme. If your site switches themes with a class or attribute, the dark values also apply under html.dark and html[data-theme="dark"], and html[data-theme="light"] forces the light ones.

Variables can have a color per theme: color="#246bce #75a7ff" means blue on light backgrounds and light blue on dark ones. This uses CSS light-dark(), which only picks the dark color when the page declares support for it:

:root { color-scheme: light dark; }