This library is not production-ready yet. Developers should use it with caution and expect breaking changes.

Compass

57.02% covered

Interactive compass with drag-to-rotate functionality.

Installation

First, make sure you have the base map component installed:

npx shadcn@latest add https://www.terrae.dev/map.json

Then install the compass component:

npx shadcn@latest add https://www.terrae.dev/compass.json

Sizes

The compass supports t-shirt sizes (sm, md, lg, xl) or custom numeric pixel values. Each size is optimized for different use cases.

Minimal Mode

For a cleaner look, disable the outer ring and cardinal labels.

Bearing Display

Enable showBearing to display the current rotation angle in degrees below the compass.

Auto Rotate

Enable automatic rotation with the autoRotate prop. Control the speed with autoRotateSpeed (degrees per frame).

Properties

PropTypeDescription
size"sm" | "md" | "lg" | "xl" | numberCompass size. T-shirt sizes map to 48, 64, 80, 96 pixels respectively.
position"top-left" | "top-right" | "bottom-left" | "bottom-right"Position of the compass on the map.
showCardinalsbooleanShow N, S, E, W cardinal direction labels.
showRingbooleanShow outer ring with degree tick marks.
showBearingbooleanDisplay current bearing in degrees below the compass.
autoRotatebooleanEnable automatic rotation of the compass.
autoRotateSpeednumberSpeed of auto rotation in degrees per frame.
classNamestringAdditional CSS classes for the wrapper element.