BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/@nordaun/ui/map

Map

nordaun-ui/map
FreeBlock

A modular context-based map with built in controls such as projection, zoom, rotation and fullscreen.

Live preview

live · rendered by the registry
Rendered by @nordaun/ui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://ui.nordaun.com/r/map.json

Source

src/components/ui/map.tsxui.nordaun.com/r/map.json · first 6 KB
1"use client";
2
3import {
4 MapLibreMap,
5 MapOptions,
6 Marker,
7 MarkerOptions,
8 Popup,
9 PopupOptions,
10 StyleSpecification,
11} from "maplibre-gl";
12import "maplibre-gl/dist/maplibre-gl.css";
13import * as React from "react";
14import { createPortal } from "react-dom";
15
16import { Button } from "@/components/ui/button";
17import { ButtonGroup } from "@/components/ui/button-group";
18import { Loading } from "@/components/ui/loading";
19import { cn } from "@/lib/utils";
20import {
21 ChevronDown,
22 ChevronUp,
23 Globe,
24 Loader2,
25 Locate,
26 Map as MapIcon,
27 MapPin,
28 Maximize,
29 Minimize,
30 Minus,
31 Plus,
32} from "lucide-react";
33
34type Theme = "light" | "dark";
35type Coordinate = { latitude: number; longitude: number };
36type Projection = "mercator" | "globe";
37type Style = string | StyleSpecification;
38
39const defaultStyles: Record<Theme, Style> = {
40 light: "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",
41 dark: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
42};
43
44function getDocumentTheme(): Theme | null {
45 if (typeof document === "undefined") return null;
46 if (document.documentElement.classList.contains("dark")) return "dark";
47 if (document.documentElement.classList.contains("light")) return "light";
48 return null;
49}
50
51function getSystemTheme(): Theme {
52 if (typeof window === "undefined") return "light";
53 return window.matchMedia("(prefers-color-scheme: dark)").matches
54 ? "dark"
55 : "light";
56}
57
58function useTheme(defaultTheme?: Theme): Theme {
59 const [theme, setTheme] = React.useState<Theme>(
60 () => getDocumentTheme() ?? getSystemTheme(),
61 );
62
63 React.useEffect(() => {
64 if (defaultTheme) return;
65
66 const observer = new MutationObserver(() => {
67 const docTheme = getDocumentTheme();
68 if (docTheme) setTheme(docTheme);
69 });
70
71 observer.observe(document.documentElement, {
72 attributes: true,
73 attributeFilter: ["class"],
74 });
75
76 const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
77 const handleSystemChange = (e: MediaQueryListEvent) => {
78 if (!getDocumentTheme()) setTheme(e.matches ? "dark" : "light");
79 };
80 mediaQuery.addEventListener("change", handleSystemChange);
81
82 return () => {
83 observer.disconnect();
84 mediaQuery.removeEventListener("change", handleSystemChange);
85 };
86 }, [defaultTheme]);
87
88 return defaultTheme ?? theme;
89}
90
91type MapContext = {
92// … truncated

What it pulls in

npm packages

  • lucide-react
  • maplibre-gl

Other registry items

  • button
  • button-group

Files it writes

  • src/components/ui/loading.tsx
  • src/components/ui/map.tsx

Facts

Registry
@nordaun/ui
Type
registry:block
Access
Free
Files written
2
Licence
MIT
First indexed
2026-08-01
Last confirmed
2 days ago

Go to the source

Docs on @nordaun/ui ui.nordaun.com nordaun/ui on GitHub Raw registry item This item as JSON

More from @nordaun/ui

All 8 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Audioaudio@nordaun/uiBlocksFree1 dep
Filefile@nordaun/uiBlocksFree1 dep · 3 files
Flagflag@nordaun/uiBlocksFreeno deps · 2 files
Loadingloading@nordaun/uiBlocksFreeno deps
Passwordpassword@nordaun/uiBlocksFree1 dep
Phonephone@nordaun/uiBlocksFree2 deps · 3 files
Videovideo@nordaun/uiBlocksFree1 dep · 2 files
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex