Styling and themes
Set light or dark mode and customize the React player with CSS properties.
Version scope — v0.0.2 (historical schema 1). This page and its examples use @0xbuff/throughline@0.0.2, the version pinned by this documentation app. They do not describe the unreleased schema-2 API intended for v0.2.0. See compatibility and upgrading.
The optional React player ships its own stylesheet. It does not require Tailwind, a theme provider, or a CSS-in-JS library.
Import the stylesheet
import "@0xbuff/throughline/styles/throughline.css";Load it once, usually in your application entry or root stylesheet. The compiler does not import CSS automatically. Only the published package path is supported; do not import files from src/ or dist/.
Set the theme
<ThroughlinePlayer trace={trace} theme="auto" />
<ThroughlinePlayer trace={trace} theme="light" />
<ThroughlinePlayer trace={trace} theme="dark" />| Value | Behavior |
|---|---|
auto (default) | Uses the resolved browser color scheme |
light | Forces the player's light palette |
dark | Forces the player's dark palette |
auto does not read your app's custom theme state. If your application manages its own theme, pass light or dark based on that state.
CSS properties
Version 0.0.2 provides ten public customization properties. The values below are the shipped light and dark defaults.
| Property | Light | Dark | Role |
|---|---|---|---|
--thl-bg | #fcfcfa | #141b19 | Background |
--thl-panel | #f3f4f0 | #19231f | Panels |
--thl-surface | #ffffff | #202c26 | Node surfaces |
--thl-text | #202b28 | #ecf2eb | Primary text |
--thl-muted | #596761 | #a5b5a9 | Secondary text |
--thl-line | #d5dcd5 | #3d4e43 | Borders |
--thl-focus | #036c62 | #75e5b7 | Focus and transfers |
--thl-focus-bg | #e0f4ed | #183d31 | Focused backgrounds |
--thl-change | #8b4b08 | #ffce83 | Changed values |
--thl-change-bg | #fff0cf | #45371f | Changed-value backgrounds |
Override a player
Use className to scope your CSS. Define custom properties on the player root; a value defined on :root alone will not override a property already set on .thl.
<ThroughlinePlayer trace={trace} className="lesson-trace" theme="dark" />/* Load after the published stylesheet. */
.thl.lesson-trace {
--thl-bg: #111827;
--thl-panel: #1f2937;
--thl-surface: #273449;
--thl-text: #f9fafb;
--thl-muted: #cbd5e1;
--thl-line: #475569;
--thl-focus: #93c5fd;
--thl-focus-bg: #1e3a5f;
--thl-change: #fde68a;
--thl-change-bg: #4a3217;
}To follow a custom light/dark switch, use selectors such as .thl.lesson-trace[data-theme="dark"] and [data-theme="light"].
Layout and accessibility
The player fills its container. If it is inside a flex or grid column, allow the column to shrink:
.trace-column {
width: 100%;
min-width: 0;
max-width: 860px;
}The player measures width with ResizeObserver and adjusts the SVG layout. Avoid forcing fixed SVG dimensions or hiding captions, focus outlines, or screen-reader text. Transfer animations are disabled when the user requests reduced motion.
Advanced layout changes can target namespaced classes such as .thl-caption, .thl-controls, and .thl-scene. These internal selectors may change before v1.0; prefer the documented CSS properties for colors.
Troubleshooting
| Problem | Fix |
|---|---|
| Player is unstyled | Import the public CSS export once |
| Custom colors do not apply | Override properties on .thl.your-class and load CSS after the package styles |
auto ignores your custom theme switch | Pass light or dark explicitly |
| Diagram is clipped | Remove restrictive container widths and allow min-width: 0 |
| Custom styles reduce readability | Check contrast, focus indicators, captions, and reduced-motion behavior |
For props and playback behavior, see React player.