Put the compass on a map host with position: relative. Drag the plate, turn it by the handle, and twist the bezel to set a bearing.
route-compass.tsx
Compass
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| bearing | number | — | The bearing set on the bezel, in degrees (read at the red index), controlled. |
| default | number | 0 | The first bearing, uncontrolled. Default 0. |
| on | — | Each new bearing: a twist, a flick, a key. | |
| on | — | The end of a change: a release, the end of a flick, a key. Not on Escape. | |
| heading | number | null | — | Where the plate faces, in degrees from north: the needle points to north from it. No value: the compass lies on a north-up map, so the needle points up the screen as the plate turns. null: no heading (a sensor with no reading); the needle parks. |
| tolerance | number | COMPASS_TOLERANCE | The half width of "boxed", in degrees. Default 3. |
| position | — | The plate place on its host in px, controlled. | |
| default | ORIGIN | ||
| on | — | The end of a move: a release or a key. | |
| rotation | number | — | The plate turn on its host, in degrees, controlled. |
| default | number | 0 | |
| on | — | The end of a turn of the plate: a release or a key. | |
| disabled | boolean | false | |
| read | boolean | false | The compass shows and can be focused, but a drag or a key changes nothing. |
| name | string | — | The form name of the bearing input. |
| form | string | — | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
CompassBaseplate
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
CompassBezel
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
CompassNeedle
<svg>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <svg> attributes | — | Every other attribute goes to the <svg>, with a ref. |
CompassHandle
<button>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| glass | "clear""dark""light" | — | |||||
| rounded | "default""full" | — | |||||
| size | "default""icon""icon-lg""icon-sm""icon-xs""lg""sm""xl""xs" | — | |||||
| variant | "dashed""default""destructive""destructive-outline""ghost""link""media""outline""secondary" | — | |||||
| class | string | — | |||||
| busy | boolean | — | The button waits for the app (busy words): a spinner, aria-busy, and no clicks. Focus stays on the button. The style hook stays data-loading. | ||||
| spinner | "center""start" | — | center (default): the spinner covers the label. start: it takes the leading icon slot. The icon sizes always use center, because their one icon is the label. | ||||
From Base UIButtonBase UI docs | |||||||
| focusable | boolean | false | Whether the button should be focusable when disabled. | ||||
| render | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. | |||||
| style | — | Style applied to the element, or a function that returns a style object based on the component's state. | |||||
| |||||||
| ...props | <button> attributes | — | Every other attribute goes to the <button>, with a ref. | ||||
| Right ArroworUp Arrow | On the bezel: turns the bearing 1° up. |
|---|---|
| Left ArroworDown Arrow | On the bezel: turns the bearing 1° down. |
| Shiftarrow keys | On the bezel: turns the bearing to the next 15°. |
| Page UporPage Down | On the bezel: turns the bearing 45°. |
| Home | On the bezel: sets the bearing to north. |
| Escape | Stops a twist, a move, or a turn and puts the compass back. |
| Arrow keys on the handle | Moves the compass 8 px (Shift: 40 px). |
| [ and ] on the handle | Turns the compass 1° (Shift: 10°). |
- Compass DialPick Compass Dial for a heading-up phone compass that shows which way to turn to a target.
- Angle DialPick Angle Dial to set any angle in degrees with a plain round dial.
- SliderPick a value or a range: drag a thumb along a thin track, or use the arrow keys. It has a label, a value, and one thumb for each value.
Built with
Installs with Compass





