Skip to content

Color Mode

ColorMode switches a flow between light, dark and the operating system's preference, and every part of it follows - nodes, edges, the control bar, the minimap, node toolbars and the attribution - because every colour is a --bit-blow-* CSS custom property. Overriding a few of those properties is a theme of your own, and ReducedMotion stills the animation for readers who ask for less.

Node 1
Node 2
Node 3
Node 4
Arrow keys move the view, Home shows the whole flow.
Every colour here is a --bit-blow-* custom property.
bit Blow

Try it

  • Pick a Theme: Light and Dark fix the flow's colours, System follows your operating system's light or dark setting, and Site theme follows this site's own toggle in the header.
  • Click a node to select it and open its toolbar - Duplicate copies the selection, Delete removes the node - and see that the toolbar, the selection ring, the control bar and the minimap all change with the theme.
  • Tick Override the accent: the selection ring, selected edges, the line drawn while connecting and the focus rings all turn teal, in either mode.
  • Tick Warm palette: the pane, the nodes, the edges, the pattern and the minimap take warmer colours - a lighter set in light mode and a darker set in dark mode.
  • Tick Reduce motion: the animated edge from Node 1 keeps its dashes but stops marching.
  • Press the lock button at the bottom of the control bar: nodes can no longer be dragged, connected or selected until you press it again.
  • Turn on a high-contrast theme in your operating system, or emulate forced-colors: active in the browser's developer tools: edges, handles and the selection switch to the system's colours, and selection is drawn as an outline.

How it works

  • ColorMode is BlowColorMode.Light (the default), Dark or System. Dark puts bit-blow-dark on the canvas, which copies every --bit-blow-dark-* property over its light twin; system puts bit-blow-system, which does the same while prefers-color-scheme is dark.
  • Every colour in the stylesheet - pane, nodes, edges, handles, the control bar, the minimap, toolbars, labels - reads a --bit-blow-* property on the .bit-blow element, which is why the whole component changes together.
  • The accent override sets --bit-blow-node-selected, --bit-blow-edge-selected and --bit-blow-connection-stroke, and --bit-blow-dark-accent for dark mode, on a class passed through the canvas's Class.
  • The warm palette overrides --bit-blow-bg, -node-bg, -node-border, -edge-stroke, -background-pattern and -minimap-node, and their --bit-blow-dark-* twins, so it has a dark version too. The rule is wrapped in :where(), keeping it below the colour modes' two-class rules - otherwise a light override would win in dark mode as well.
  • ReducedMotion (default BlowReducedMotion.System) follows the operating system's reduce-motion setting; the box sets Always, and Never animates regardless. It also makes viewport transitions jump instead of easing.
  • Under forced colours the stylesheet maps edge, handle and selection colours onto the system palette (CanvasText, Highlight, GrayText), since the browser does not recolour SVG strokes or box shadows itself.
  • BlowControls shows the lock only with ShowInteractive, and the lock only reports its state: @bind-Interactive feeds a field the page passes to NodesDraggable, NodesConnectable and ElementsSelectable.
  • BlowNodeToolbar shows over a node while it is selected; its buttons call DuplicateSelectionAsync() and DeleteElementsAsync().
An unhandled error has occurred. Reload 🗙