Skip to content

DocsDataRing and legend

PT

Data

Ring and legend

Segmented ring that draws itself on entry, a number in the center and a legend that highlights the segment.

data-u="ring"

Example

Build health
Stable.
Tests: 1,180 passing
Lint: no new warnings
Types: 2 pending

Installation

Ring and legend ships in the full package, in unslop.css and unslop.js:

curl -fsSL unslop.leallabs.dev/i | sh

A ready-made block that uses ring and legend:

curl -fsSL unslop.leallabs.dev/i | sh -s add wall-sleep

No build Name-based add is for charts and blocks. Components with JS live in unslop.js, which mounts every data-u on the page by itself.

Props

They go in data-u-props, as JSON.

PropTypeDefaultWhat it does
segmentsarray[]List of {v, color}. v is the segment weight; color is optional and falls back to --c1, --c2...
valuenumber0Number in the center, counting up from 0.
gapnumber20Gap between segments, in circumference units (314).

Classes and variants

ClassWhat it does
u-legendThe legend.
u-legend__row[data-seg="i"]Row tied to segment i: hover highlights the segment and fades the rest.
u-legend__sqColor swatch.

Accessibility and keyboard

State and roles

WhereAttributeWhat it says
svgaria-hidden="true"The ring is decoration. The text legend carries the information.

The highlight is pointer-driven. With the keyboard, the legend is read as text.

Type to search. Arrows pick, Enter opens.