# Globe

> React dotted globe drawn on a plain canvas without WebGL, with auto rotation, drag with inertia, keyboard control and labelled markers joined by arcs.

- Kind: Motion component (Motion)
- Docs: https://ui.minidev.pro/docs/globe
- Source (registry JSON with the full file): https://ui.minidev.pro/r/globe.json
- License: MIT. One file, yours to edit after install.

## When to use

Use it for "global reach" or "where your users are" sections. For a lighter decorative sphere of logos use IconCloud.

## Installation

### shadcn CLI (copies the source into your project)

```bash
npx shadcn@latest add @minidev/globe
```

Writes `components/ui/globe.tsx` plus the MiniDev files it is built from (button) and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/globe.json`.

### npm package

```bash
npm i minidev-ui-kit lucide-react motion
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

```tsx
import { Globe } from "@/components/ui/globe"
```

From the npm package:

```tsx
import { Globe } from "minidev-ui-kit/premium/globe"
```

## Usage

```tsx
import { Globe } from "@/components/ui/globe"

export function Example() {
  return (
    <Globe />
  )
}
```

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `markers` | `GlobeMarker[]` | `DEFAULT_MARKERS` | no | Places to mark, in degrees. Consecutive markers are joined by arcs. |
| `dots` | `number` | `2000` | no | Number of dots on the sphere. |
| `speed` | `number` | `6` | no | Idle spin in degrees per second. 0 holds still until dragged. |
| `arcs` | `boolean` | `true` | no | Join consecutive markers with arcs. |
| `align` | `"left" \| "center" \| "right"` | `"right"` | no | Where the globe sits on wide panels. The demo content takes the other side. |
| `color` | `string` | `"var(--fg-muted)"` | no | Dot colour. Any CSS colour, including var(--token). Defaults to the muted foreground. |
| `accent` | `string` | `"var(--accent)"` | no | Marker, arc and glow colour. Any CSS colour. Defaults to the accent. |
| `className` | `string` | - | no |  |
| `children` | `React.ReactNode` | - | no |  |

## Examples

### Custom markers

Markers take latitude and longitude with a label; consecutive ones are joined by arcs.

```tsx
<Globe
  markers={[
    { lat: 40.71, lng: -74.01, label: "New York" },
    { lat: 52.52, lng: 13.41, label: "Berlin" },
    { lat: 19.08, lng: 72.88, label: "Mumbai" },
    { lat: 35.68, lng: 139.69, label: "Tokyo" },
  ]}
>
  <div className="flex flex-col items-start gap-3 p-6 @lg:w-1/2 @lg:p-10">
    <p className="text-xs font-medium tracking-[0.06em] text-accent-fg uppercase">Northwind offices</p>
    <p className="max-w-[18ch] text-2xl font-medium tracking-[-0.03em] text-fg">Four offices, one ledger</p>
    <Button variant="outline" size="sm">Find your region</Button>
  </div>
</Globe>
```

### Centred without arcs

align center puts the globe behind the copy; arcs false leaves the markers on their own.

```tsx
<Globe align="center" arcs={false} speed={10} />
```

### Colours and a still globe

color and accent take any CSS colour, tokens included; speed 0 holds still until dragged.

```tsx
<Globe speed={0} color="var(--accent)" accent="var(--success)" align="left" className="h-72" />
```

## Keyboard interactions

| Key | Action |
| --- | --- |
| `Tab` | Focuses the globe canvas, which shows an inset accent ring. |
| `ArrowLeft` or `ArrowRight` | Turns the globe sideways. |
| `ArrowUp` or `ArrowDown` | Tilts the globe up or down, within a fixed limit. |

## Accessibility

- The canvas has `role="img"` and an `aria-label` built from your markers, such as "Globe with markers for London, New York. Drag or use the arrow keys to rotate."
- The canvas has `tabIndex={0}`, so keyboard users can reach it and turn it with the arrow keys.
- Under reduced motion it draws one still frame. Dragging and arrow keys still turn it, but a flick does not keep spinning.

## FAQ

### Is Globe WebGL or three.js?

Neither. It draws about 2,000 dots (`dots`) on a 2D canvas with plain trigonometry, so there is no extra dependency. It stops drawing when off screen or when the tab is hidden.

### How do I mark cities and connect them?

Pass `markers` with `lat`, `lng` and an optional `label`. With `arcs` on (the default) each marker is joined to the next one in the array, with a pulse along each arc.

### Does dragging the globe block page scroll on phones?

No. The canvas has `touch-action: pan-y`, so a vertical swipe scrolls the page and a sideways drag turns the globe. A quick flick keeps it spinning with inertia.

### Can buttons sit on top of the globe?

Yes. The content layer ignores the pointer except on its direct children, so the globe stays draggable around your text and buttons. `align` moves the globe left, centre or right on panels wider than 512px.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- npm: `lucide-react`, `motion`
- Built from: [button](https://ui.minidev.pro/docs/button/md)

## Related

- [Icon Cloud](https://ui.minidev.pro/docs/icon-cloud/md): React 3D sphere of icons that rotates on its own, spins with inertia when dragged, scales and fades items by depth and pauses when it leaves the screen.
- [Animated Feature Row](https://ui.minidev.pro/docs/animated-feature-row/md): A row of feature cards that slide up with a staggered delay when scrolled into view. Pass title and description pairs; reduced motion keeps them still.
- [Card Tilt](https://ui.minidev.pro/docs/card-tilt/md): A card that tilts in 3D toward the pointer on springs, with an accent glare that follows the cursor. It stays flat when reduced motion is preferred.
- [Cursor Spotlight Panel](https://ui.minidev.pro/docs/cursor-spotlight-panel/md): A panel whose accent radial spotlight follows the cursor, driven by Framer Motion values without re-renders. It shows a still surface for reduced motion.
- [Device Frame Stack](https://ui.minidev.pro/docs/device-frame-stack/md): Three device frames labelled mobile, app and docs that spring into a fanned, rotated stack when scrolled into view. Works as a hero or feature visual.
- [Flip Stat Board](https://ui.minidev.pro/docs/flip-stat-board/md): A stat board where each number counts up with digits that flip in on a spring once in view. Pass values and labels; reduced motion shows the final value.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
