---
title: "Compass Dial"
description: "A heading-up compass dial: the rose turns with the heading, and a target on the ring shows which way to turn and how far."
url: https://gelatinui.com/components/compass-dial
markdown_url: https://gelatinui.com/components/compass-dial.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/compass-dial"
version: "2026-11-22"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Compass Dial

> A heading-up compass dial: the rose turns with the heading, and a target on the ring shows which way to turn and how far.

Page: https://gelatinui.com/components/compass-dial

## When to use it

Best for: Show a live heading on a heading-up dial and guide the user to a target bearing.

- Use it on a phone with `useDeviceHeading`: pass its `heading`, and show its `status` and `requestAccess` in your own UI.
- Use `heading` from a GPS course or a data feed for a vehicle, a boat, or a drone.
- Use `target` and `onTargetChange` to keep the target with a saved place; `null` is no target.
- Use `name` to send the target with a form.

## When not to use it

- To set a bearing on a map with a baseplate that people move and turn, use a [Compass](https://gelatinui.com/components/compass.md).
- For a plain angle in degrees, such as a rotation, use an [Angle Dial](https://gelatinui.com/components/angle-dial.md).

## Notes for agents

- Compose it from `CompassDialRose`, `CompassDialTarget`, `CompassDialLubber`, and `CompassDialCenter` with `CompassDialValue` and `CompassDialHint`. With no children it renders all of them.
- It only draws its props. For a live phone compass, call `useDeviceHeading()` and pass `heading`; iOS asks for motion access on a press of `requestAccess`.
- `heading={null}` shows the waiting state; with no target the hint says to tap the ring.
- The rose turns with the heading, so the line at the top is where the user faces. The arc shows the short way to the target.
- `onTargetChange` runs on each step of a drag and with `null` on Delete. `onTargetCommitted` runs on release and on a key, not on Escape.
- `data-on-course` is on the root when the heading is within `tolerance` (3° by default) of the target. Set the size with a width class (`w-56`): the dial stays round.
- `labels` changes the words it writes (the turn hint, the empty states). Keep the object at module level.

## Anatomy

```text
CompassDial
├─ CompassDialRose (0..n)
├─ CompassDialTarget (0..n)
├─ CompassDialLubber (0..n)
├─ CompassDialCenter (0..n)
├─ CompassDialValue (0..n)
└─ CompassDialHint (0..n)
```

## API reference

### CompassDial

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `heading` | `number \| null` |  | The heading in degrees: where the device faces (0 is north, clockwise). Feed it from `useDeviceHeading`, a GPS course, or any source. `null` or no value: no heading yet. |
| `target` | `number \| null` |  | The target bearing in degrees, controlled. `null`: no target. |
| `defaultTarget` | `number \| null` | null | The first target, uncontrolled. Default `null`. |
| `onTargetChange` | `function` |  | Each new target: a press or drag on the ring, a key. `null` when Delete clears it. |
| `onTargetCommitted` | `function` |  | The end of a change: a release or a key. Not on Escape. |
| `tolerance` | `number` | COMPASS_TOLERANCE | The half width of "on course", in degrees. Default 3. |
| `disabled` | `boolean` | false |  |
| `readOnly` | `boolean` | false | The target shows and can be focused, but a press or a key does not change it. |
| `name` | `string` |  | The form name of the hidden range input (the target). |
| `form` | `string` |  |  |
| `labels` | `Partial<CompassLabels>` |  |  |

### CompassDialRose

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### CompassDialTarget

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### CompassDialLubber

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### CompassDialCenter

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### CompassDialValue

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### CompassDialHint

No props of its own: `className`, `children`, and every other prop go to the element it renders.

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| CompassDial | `compass-dial` | `data-disabled`, `data-dragging`, `data-focus-visible`, `data-on-course`, `data-readonly`, `data-tone` | `--compass-dial-turn` | `motion-timing`, `status-colors` |
| CompassDialRose | `compass-dial-rose` | `data-disabled`, `data-dragging`, `data-focus-visible`, `data-on-course`, `data-readonly`, `data-tone` | `--compass-dial-turn` | `motion-timing`, `status-colors` |
| CompassDialTarget | `compass-dial-target` | `data-disabled`, `data-dragging`, `data-focus-visible`, `data-on-course`, `data-readonly`, `data-tone` | `--compass-dial-turn` | `motion-timing`, `status-colors` |
| CompassDialLubber | `compass-dial-lubber` | `data-disabled`, `data-dragging`, `data-focus-visible`, `data-on-course`, `data-readonly`, `data-tone` | `--compass-dial-turn` | `motion-timing`, `status-colors` |
| CompassDialCenter | `compass-dial-center` | `data-disabled`, `data-dragging`, `data-focus-visible`, `data-on-course`, `data-readonly`, `data-tone` | `--compass-dial-turn` | `motion-timing`, `status-colors` |
| CompassDialValue | `compass-dial-value` | `data-disabled`, `data-dragging`, `data-focus-visible`, `data-on-course`, `data-readonly`, `data-tone` | `--compass-dial-turn` | `motion-timing`, `status-colors` |
| CompassDialHint | `compass-dial-hint` | `data-disabled`, `data-dragging`, `data-focus-visible`, `data-on-course`, `data-readonly`, `data-tone` | `--compass-dial-turn` | `motion-timing`, `status-colors` |

## Usage

Pass the heading and a target. Pair it with `useDeviceHeading` for a live phone compass.

```tsx title="heading-dial.tsx"
import {
  CompassDial,
  CompassDialCenter,
  CompassDialHint,
  CompassDialLubber,
  CompassDialRose,
  CompassDialTarget,
  CompassDialValue,
} from "@/components/pro/controls/compass-dial";

export function HeadingDial() {
  return (
    <CompassDial
      aria-label="Bearing to Aiguille du Midi"
      heading={312}
      defaultTarget={48}
      className="w-72"
    >
      <CompassDialRose />
      <CompassDialTarget />
      <CompassDialLubber />
      <CompassDialCenter>
        <CompassDialValue />
        <CompassDialHint />
      </CompassDialCenter>
    </CompassDial>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui-pro/compass-dial
```

It adds 30 registry items: 27 files, 5287 lines, and the npm packages `@base-ui/react`, `@xstate/react`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## Built on

- [Input](https://gelatinui.com/components/input.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Compass](https://gelatinui.com/components/compass.md): Pick Compass to set a bearing on a map with a baseplate that people move and turn.
- [Angle Dial](https://gelatinui.com/components/angle-dial.md): Pick Angle Dial to set any angle in degrees with a plain round dial.
- [Thermostat Dial](https://gelatinui.com/components/thermostat-dial.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Right Arrow, Up Arrow | Turns the target 1° clockwise. |
| Left Arrow, Down Arrow | Turns the target 1° back. |
| Shift + arrow keys | Turns the target to the next 15°. |
| Page Up, Page Down | Turns the target 45°. |
| Home | Sets the target to north. |
| Delete, Backspace | Clears the target. |
| Escape | Stops a drag and keeps the target from before. |

## Motion

| Part | Motion |
| --- | --- |
| Rose | drift · the rose turns with the heading on a calm spring with no bounce |
| Arc | panel · a new target draws its arc out from the line |
| Ring | hover · a faint marker shows where a press sets the target |
