Compass

<o-compass> is a heading indicator: the card turns so the heading sits under the index at the top.

The card is two rings, ticks and cardinal letters, turned by their own --o-from. The letters stay upright because capsules do by default. A new heading only changes that angle.

Attributes

AttributeDefaultWhat it does
heading0Heading in degrees, clockwise from north.
labelsN,E,S,WCard letters, comma-separated and spread evenly. The first one is colored.
accent#ef4444Index and first letter. fill still works too.
unit°Suffix of the readout.
size220pxWidth of the widget.
glowoffA glow on the index.
format, decimals, currency, localeNumber format of the heading readout, through Intl.NumberFormat. See Shared options.
themedark, light or glass. Also inherited from an ok-theme-* class on a container. See Shared options.

Styling

PropertyFalls back toWhat it does
--ok-cmp-accent--ok-accentIndex and the first letter.
--ok-cmp-face--ok-faceDial background.
--ok-cmp-bezel--ok-bezelDial rim.
--ok-cmp-tick--ok-tickSmall ticks.
--ok-cmp-tick-MTicks at the four cardinal points.
--ok-cmp-text--ok-textLetters and readout.
--ok-font-sizeBase text size, 7cqmin by default.

More examples

Eight points

Following the pointer

Move the pointer over the frame.

A light dial

Accessibility

The compass has role="img" and a name like “Heading 45°, NE”, kept in sync with heading. Set aria-label to replace it.