Skip to content
Neon UI
Esc
navigateopen⌘Jpreview
On this page

RegionCard

Floating server-info chip — region name, mono id, and a color-coded ping line.

RegionCard is the server-info chip that floats over region visualizations: an uppercase kicker, the region name, and a mono line with the region id plus a color-coded ping: x ms (green under 80 ms, amber under 180, red past that — the same pingTone helper the whole region family shares). It ships unpositioned; anchor it with className over a RegionSelect map, a RegionGlobe, or the CreateProject block — all three use this exact component.

Region

AWS US East 1 (N. Virginia)

aws-us-east-1 · ping: 12 ms

Region

AWS Europe Central 1 (Frankfurt)

aws-eu-central-1 · ping: 92 ms

Region

AWS Asia Pacific 1 (Singapore)

aws-ap-southeast-1 · ping: 231 ms

Install

npx shadcn@latest add https://ui.neon.com/r/region-card.json

Usage

import { RegionCard } from "@/components/neon-ui/region-card";

<RegionCard
  className="absolute bottom-3 left-3"
  title="AWS Europe Central 1 (Frankfurt)"
  regionId="aws-eu-central-1"
/>;

ping is optional; add it to get the color-coded latency line. It is a browser measurement rather than API data, so it comes from the standalone useRegionPing hook.

Wiring to Neon

The card is one region’s readout, so it takes a single entry off the active-regions list:

import { createNeonClient } from "@/lib/neon-client";

const neon = createNeonClient(process.env.NEON_API_KEY);
const { data } = await neon.regions.list();
const region = data?.find((item) => item.region_id === regionId);

<RegionCard title={region.name} regionId={region.region_id} />;

Showing a ping

Latency is measured in the browser, not reported by the API. The hook that measures it is its own registry item, so the card does not drag another component in:

npx shadcn@latest add https://ui.neon.com/r/use-region-ping.json
"use client";

import { useRegionPing } from "@/hooks/use-region-ping";

const { pings } = useRegionPing({
  "aws-us-east-1": "https://us-east-1.aws.example.com/health",
});

<RegionCard
  title="AWS US East 1 (N. Virginia)"
  regionId="aws-us-east-1"
  ping={pings["aws-us-east-1"] ?? null}
/>;

The hook takes a URL per region and times an opaque no-cors HEAD request against each. Until the first round-trip lands the entry is undefined, so pass null and the card leaves the line out rather than showing a placeholder number.

Props

PropType
title?string

Display name, e.g. "AWS Europe Central 1 (Frankfurt)".

Typestring
regionId?string

Mono region id shown on the detail line.

Typestring
ping?number | null

Round-trip in ms; renders color-coded when present.

Typenumber | null
label?string

Uppercase kicker above the title.

Typestring
Default"Region"
icon?ReactNode

Leading icon; defaults to the CPU mark.

TypeReactNode
children?ReactNode

Trailing content, e.g. a status badge.

TypeReactNode

Notes

  • Exports pingTone(ping) — the shared green/amber/red class mapping — for readouts outside the card.
  • The entrance fade is motion-reduce guarded; pair with an aria-live="polite" wrapper when the card announces selection changes.