Dotted Map
Install: npx shadcn@latest add https://jiguang132.com/r/magic-ui/dotted-map.json
Use case
Plot supplied markers over a dotted SVG world map.
Native props used by the examples
Extracted from all local examples for this entry, grouped by imported module and native owner, including other Magic components used by compound demos. This is not an exhaustive API or a universal host variant. Inspect spread object declarations and the source types/defaults below.
| Owning component prop | Explanation | Example source |
|---|---|---|
DottedMap.markers (dotted-map) | Map marker latitude/longitude data with optional size/pulse. | examples/dotted-map-demo.tsx、examples/dotted-map-demo-3.tsx |
DottedMap.renderMarkerOverlay (dotted-map) | Render marker overlays from projected coordinates. | examples/dotted-map-demo.tsx |
DottedMap.dotRadius (dotted-map) | SVG map dot radius. | examples/dotted-map-demo-2.tsx |
DottedMap.pulse (dotted-map) | Enable marker pulse animation. | examples/dotted-map-demo-3.tsx |
Interaction and state checks
- Dotted Map Demo —
dotted-map-demo - Dotted Map Demo 2 —
dotted-map-demo-2 - Dotted Map Demo 3 —
dotted-map-demo-3
These names identify real example entries, not new component props or extra components. Check pointer/keyboard behavior, themes, small screens and failures for the selected example. Decorative effects must not invent disabled/error/submission states. Complete example installation includes the actual dependency closure.
Business integration boundary
markers uses latitude/longitude; renderMarkerOverlay receives projected coordinates. No geolocation or live map service is provided.
Host and motion setup
Initialize Tailwind CSS v4, semantic CSS variables and the dark variant; import the independent local Registry namespace. Reuse an existing next-themes Provider without substituting JGuang UI/Base UI/HeroUI APIs. Mount effects in view and unmount offscreen; provide static alternatives for unavailable Canvas/WebGL or failed remote media. Respect prefers-reduced-motion and verify timer/RAF/observer/listener cleanup: stopping CSS alone does not prove the engine stopped. Examples provide no backend, login, payment or real AI stream. This practical guide is bilingual; detailed upstream references and demo text retain their original language.
Available examples
dotted-map-demo, dotted-map-demo-2, dotted-map-demo-3
Demo state and mock data do not provide a backend service. Inspect the component props before wiring real data.
Installation
<Tabs defaultValue="cli"> <TabsList> <TabsTrigger value="cli">CLI</TabsTrigger> <TabsTrigger value="manual">Manual</TabsTrigger> </TabsList> <TabsContent value="cli">npx shadcn@latest add @magicui/dotted-map
</TabsContent>
<TabsContent value="manual">
<Steps>
<Step>Copy and paste the following code into your project.</Step>
<Step>Update the import paths to match your project setup.</Step>
</Steps> </TabsContent> </Tabs>Examples
Smaller Dots
PulseMarker
Usage
import { DottedMap, type Marker } from "@/components/ui/dotted-map"
<div className="relative h-[400px] w-full overflow-hidden rounded-xl border">
<DottedMap />
</div>
With Custom Markers
import { DottedMap, type Marker } from "@/components/ui/dotted-map"
import type { TCountryCode } from "countries-list"
type CountryCode = Lowercase<TCountryCode>
type MyMarker = Marker & {
overlay: {
countryCode: CountryCode
label: string
}
}
const markers: MyMarker[] = [
{
lat: 37.5665,
lng: 126.978,
size: 2.8,
overlay: { countryCode: "kr", label: "Seoul" },
},
]
<DottedMap<MyMarker>
markers={markers}
renderMarkerOverlay={({ marker, x, y, r }) => {
// Custom overlay rendering
return <text x={x} y={y}>{marker.overlay.label}</text>
}}
/>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
width | number | 150 | Width of the SVG map. |
height | number | 75 | Height of the SVG map. |
mapSamples | number | 5000 | Number of sample points for map generation. |
markers | Marker[] | [] | Array of markers to display on the map. |
dotColor | string | undefined | Color of the map dots (uses currentColor if not set). |
markerColor | string | "#FF6900" | Color of the markers. |
dotRadius | number | 0.2 | Radius of the map dots. |
stagger | boolean | true | Whether to stagger dots in alternating rows for visual effect. |
pulse | boolean | false | Enables built-in pulse animation for markers. |
renderMarkerOverlay | (args) => ReactNode | undefined | Custom render function for marker overlays. |
className | string | undefined | Additional class names applied to the SVG. |
style | React.CSSProperties | undefined | Inline styles merged into the SVG. |
Types
Marker
export interface Marker {
lat: number
lng: number
size?: number
pulse?: boolean
}
Set pulse on DottedMap to animate all markers (and use marker.pulse = false to opt out per marker). Without the pulse prop, only markers with marker.pulse = true will pulse.
The DottedMap component supports generic types, allowing you to extend the Marker interface with custom properties:
import type { TCountryCode } from "countries-list"
type CountryCode = Lowercase<TCountryCode>
type MyMarker = Marker & {
overlay: {
countryCode: CountryCode
label: string
}
}
;<DottedMap<MyMarker> markers={markers} />
Complete example installation
The component command installs the component. Each example command also includes its actual imported components, native support UI, utilities and pinned dependencies. Helpers are not additional catalog components.
Dotted Map Demo
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/dotted-map/dotted-map-demo.json
Default import: @/components/magicui/examples/dotted-map-demo
Dependencies: clsx@2.1.1, countries-list@3.4.1, svg-dotted-map@2.0.1, tailwind-merge@3.6.0
Dotted Map Demo 2
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/dotted-map/dotted-map-demo-2.json
Default import: @/components/magicui/examples/dotted-map-demo-2
Dependencies: clsx@2.1.1, svg-dotted-map@2.0.1, tailwind-merge@3.6.0
Dotted Map Demo 3
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/dotted-map/dotted-map-demo-3.json
Default import: @/components/magicui/examples/dotted-map-demo-3
Dependencies: clsx@2.1.1, svg-dotted-map@2.0.1, tailwind-merge@3.6.0
Minimal usage and theme
import Demo from '@/components/magicui/examples/dotted-map-demo';
import { ThemeProvider } from 'next-themes';
export default function Example() {
return <ThemeProvider attribute="class" defaultTheme="system" enableSystem><Demo /></ThemeProvider>;
}
Initialize Tailwind CSS v4, semantic color variables and the dark variant first. Reuse an existing next-themes provider rather than nesting another. Next Link examples require a Next.js environment; in static Vite projects adapt the demo links to your router without changing the native component API. Some media and tweets require network access. Examples do not supply authentication or backend services.
Source-backed parameter reference
Implementation signatures and types are generated from the pinned local source. Optional props, native inherited types, union branches and never exclusions are preserved. A forwardRef implementation's ref is a React reference, not an additional business prop.
DottedMap({
width = 150,
height = 75,
mapSamples = 5000,
markers = [],
dotColor = "currentColor",
markerColor = "#FF6900",
dotRadius = 0.2,
stagger = true,
pulse = false,
renderMarkerOverlay,
className,
style,
...svgProps
}: DottedMapProps<M>)
export interface Marker {
lat: number
lng: number
size?: number
pulse?: boolean
}
type MapMarker<M extends Marker> = Omit<M, "lat" | "lng"> & {
x: number
y: number
}
export interface DottedMapProps<
M extends Marker = Marker,
> extends React.SVGProps<SVGSVGElement> {
width?: number
height?: number
mapSamples?: number
markers?: M[]
dotColor?: string
markerColor?: string
dotRadius?: number
stagger?: boolean
pulse?: boolean
renderMarkerOverlay?: (args: {
marker: MapMarker<M>
index: number
x: number
y: number
r: number
}) => React.ReactNode
}
Destructuring defaults in source
Only defaults written directly in parameter/props destructuring are listed. Conditional expressions, runtime theme and computed values require source inspection; this is not an exhaustive behavior-default list.
// DottedMap
width = 150
// DottedMap
height = 75
// DottedMap
mapSamples = 5000
// DottedMap
markers = []
// DottedMap
dotColor = "currentColor"
// DottedMap
markerColor = "#FF6900"
// DottedMap
dotRadius = 0.2
// DottedMap
stagger = true
// DottedMap
pulse = false
Native and external types
External types remain defined by React or native dependencies, not manually expanded into guessed props. The installed version's TypeScript definitions are authoritative.
React.SVGProps<SVGSVGElement>
SVGSVGElement
M
Omit<M, "lat" | "lng">
React.ReactNode