Sina UI

Display

World map

Where your numbers come from: each country shaded by its value in five steps of ink, with a tooltip, a click to pick a country, pinch and drag to zoom, and soft pulsing dots for what's happening now.

Installation

npx sinaui add world-map

The country outlines are Natural Earth's (public domain), projected ahead of time into plain SVG paths: about 40 KB gzipped, loaded the first time a map is on screen, so pages without one don't pay for them. Countries too small to draw at this scale, such as Singapore and Bahrain, show as a dot when they have data.

Examples

Pick a country

Hover or focus a country for its name, value and share. Clicking one calls onselect; pass the code back as selected to outline it.

Readers of the House of Wisdom catalog in the last 30 days.

Library readers by country
CountryReadersShare
Iraq4,21025.7%
Egypt3,10518.9%
Spain2,38014.5%
Iran1,94011.8%
Morocco1,2107.4%
Syria9806%
Uzbekistan7604.6%
Türkiye6904.2%
Tunisia4102.5%
India3802.3%
Saudi Arabia2401.5%
Bahrain640.4%
Singapore410.2%

Pick a country to filter by it.

<script lang="ts">
	import WorldMap from '#lib/ui/WorldMap.svelte';

	const readers = [
		{ code: 'IQ', value: 4210 },
		{ code: 'EG', value: 3105 },
		{ code: 'ES', value: 2380 },
		{ code: 'IR', value: 1940 },
		{ code: 'MA', value: 1210 },
		{ code: 'SY', value: 980 },
		{ code: 'UZ', value: 760 },
		{ code: 'TR', value: 690 },
		{ code: 'TN', value: 410 },
		{ code: 'IN', value: 380 },
		{ code: 'SA', value: 240 },
		{ code: 'BH', value: 64 },
		{ code: 'SG', value: 41 }
	];
	let picked = $state<string | null>(null);
	const names = new Intl.DisplayNames(['en-US'], { type: 'region' });
</script>

<WorldMap
	data={readers}
	title="Library readers by country"
	description="Readers of the House of Wisdom catalog in the last 30 days."
	valueLabel="Readers"
	selected={picked}
	onselect={(code) => (picked = picked === code ? null : code)}
/>
<p class="note">
	{picked ? `Showing readers from ${names.of(picked)}.` : 'Pick a country to filter by it.'}
</p>

<style>
	.note {
		margin: 0.75rem 0 0;
		color: var(--ui-muted);
		font-size: 0.875rem;
	}
</style>

Happening now

Pings pulse softly over the countries where something is happening now, and new ones pop in. Reduced motion keeps them as still dots.

Readers today, and reading now
CountryReadersShare
Iraq82035.7%
Egypt61026.5%
Spain45019.6%
Morocco30013%
Uzbekistan1205.2%
<script lang="ts">
	import WorldMap from '#lib/ui/WorldMap.svelte';

	const today = [
		{ code: 'IQ', value: 820 },
		{ code: 'EG', value: 610 },
		{ code: 'ES', value: 450 },
		{ code: 'MA', value: 300 },
		{ code: 'UZ', value: 120 }
	];
	// Who is reading right now; somewhere a new reader pops in every few seconds.
	const places = ['IQ', 'EG', 'ES', 'MA', 'UZ', 'IR', 'SY', 'TR'];
	let now = $state([
		{ code: 'IQ', value: 6 },
		{ code: 'EG', value: 3 }
	]);
	$effect(() => {
		const timer = setInterval(() => {
			const code = places[Math.floor(Math.random() * places.length)];
			const rest = now.filter((p) => p.code !== code).slice(-4);
			now = [...rest, { code, value: 1 + Math.floor(Math.random() * 6) }];
		}, 3000);
		return () => clearInterval(timer);
	});
</script>

<WorldMap data={today} pings={now} title="Readers today, and reading now" valueLabel="Readers" />

A rate

For a rate or a score, format the value your way and turn share off.

Books read to the end, by country
CountryRead to the end
Spain71%
Iran66%
Iraq62%
Egypt55%
Morocco48%
Uzbekistan39%
<script lang="ts">
	import WorldMap from '#lib/ui/WorldMap.svelte';

	// A rate, not a count: no share of the total, and values shown as percentages.
	const finished = [
		{ code: 'IQ', value: 0.62 },
		{ code: 'EG', value: 0.55 },
		{ code: 'ES', value: 0.71 },
		{ code: 'MA', value: 0.48 },
		{ code: 'IR', value: 0.66 },
		{ code: 'UZ', value: 0.39 }
	];
	const percent = new Intl.NumberFormat('en-US', { style: 'percent' }).format;
</script>

<WorldMap
	data={finished}
	title="Books read to the end, by country"
	valueLabel="Read to the end"
	format={percent}
	share={false}
/>

Props

PropTypeDefault
data{ code, value, label? }[] (required); code is ISO 3166-1 alpha-2, and anything else (an "Other" row) is left out
titlestring (required): read as the map's name
descriptionstring
valueLabelstring: the value column in the table screen readers get'Value'
format(value: number) => stringwhole numbers, en-US
shareboolean: each country's share of the totaltrue
onselect(code: string) => void
selectedstring | null: outlinednull
pings{ code, value? }[]: pulsing dots, sized by value[]
emptystring: shown when there's no data'Nothing to show yet.'

Interaction

  • Mouse: hover for a tooltip, click to select, double-click to zoom in (Shift to zoom out), drag to pan once zoomed, and Ctrl or ⌘ with the wheel (or a trackpad pinch) to zoom.
  • Touch: tap to select, pinch to zoom, and drag to pan once zoomed; until then a finger scrolls the page as usual.
  • The buttons in the corner zoom in and out, and show the whole map again.

Accessibility

  • Countries with data are one tab stop: arrow keys move between them from the largest value down, Home and End jump to either end, Enter or Space selects, plus and minus zoom, and 0 shows the whole map. Focus shows the tooltip, and a country off screen slides into view.
  • Each country is named with its value and share, and a visually hidden table lists them all for screen readers.
  • Shading is never the only cue: the tooltip and the table carry every number. Reduced motion turns off the fill-in, the pulses and the zoom glide.
Introduction
Theming
Changelog
Button
Action button
Confirm button
Copy button
Hold to confirm
Split button
Theme toggle
Calendar
Checkbox
Color picker
Combobox
Date picker
Date range picker
File drop
Form
Input
Mention input
Multi select
Number field
OTP input
Password input
Phone input
Radio cards
Radio group
Rich text editor
Search field
Segmented control
Select
Signature pad
Slider
Switch
Tag input
Upload
Wheel picker
Textarea
Time field
Toggle group
Toolbar
Alert dialog
Command palette
Context menu
Dialog
Drawer
Account menu
Dropdown
Hover card
Popover
Tooltip
Announcement bar
Alert
Empty state
Meter
Progress
Rolling number
Skeleton
Spinner
Toast
Avatar
Avatar group
Badge
Card
Carousel
Chart
Sparkline
World map
Chat
Code block
Data table
Folder
Kbd
Mind map
Resizable panels
Scroll area
Separator
Sortable
Table
Tag group
Virtual list
Audio player
Image
Image compare
Video
Visualizer
Breadcrumb
File tree
Docs navigation
Menubar
Navigation menu
Pagination
Sidebar layout
Stat tabs
Stepper
Tabs
Table of contents
Alarm clock
Clock
Dynamic island
Fluid orb
Hourglass
Stopwatch
Timer
AI chat
AI media
Auth
Board
Booking
Dashboard
Docs
File explorer
Messaging
Notifications
Settings
Studio
Team
Overview
Pricing
Agent chat
Calendar
Voice agent
Mail inbox
CMS
Blog
Marketing site
E-commerce
AI agents
SaaS landing page
SaaS app
Accordion
Dark theme
Light theme