Skip to content

Theming & CSS

Olli ships a single stylesheet for its tree view and dialog components. A developer integrating Olli into a page imports it once, then overrides CSS variables or class rules to match the host site.

Import the stylesheet

Import the stylesheet once, at the top of the entry file that mounts Olli.

js
import 'olli/styles.css';

Without this import, the tree renders unstyled: every branch stays visible and the focused node has no highlight.

What the defaults do

A user who navigates the tree with the arrow keys sees only the path from the root to the currently focused node. Siblings and the focused node's own children are hidden. The focused node gets a grey background on its label.

Override with CSS variables

The stylesheet defines four variables on .olli-vis, the wrapper class on the root tree element. Set any of them on .olli-vis or any ancestor to theme the tree.

VariableDefaultPurpose
--olli-focus-bg#eeeBackground color of the focused label
--olli-hover-bg#dddBackground color on label hover
--olli-indent1.5emLeft padding of each nested tree group
--olli-virtual-styleitalicfont-style for virtual grouping nodes

Example override, scoped to a single Olli instance:

css
.my-olli-container .olli-vis {
  --olli-focus-bg: #fff3b0;
  --olli-hover-bg: #ffe180;
}

Override a class

For anything the variables do not cover, target the class directly. Every style rule is scoped under .olli-vis, so a rule with equal or greater specificity wins.

css
.olli-vis .olli-node-label {
  font-family: 'Iowan Old Style', serif;
}

Class reference

ClassElement
.olli-visRoot <ul role="tree"> element
.olli-tree-itemEach <li role="treeitem">
.olli-tree-item.olli-focusedThe currently focused item
.olli-tree-item.olli-virtualA synthesized grouping item
.olli-tree-groupEach child <ul role="group">
.olli-node-labelThe label <span> inside each item
.olli-dialog-overlayDialog overlay backdrop
.olli-dialogDialog container

Ship your own stylesheet

If a host site wants full control, it can skip the Olli import and write its own stylesheet against these class names. The renderer does not inject any inline styles, so the class hooks above are the full contract.

Next

Released under the BSD-3-Clause License.