IP lookup
A field that looks up where an IP address is located and shows the result on a small map.
Installation
pnpm dlx shadcn@latest add @lumesec/geo-ipFirst timeRegister the @lumesec registry once, or install by URL+
Adds @lumesec to your components.json:
pnpm dlx shadcn@latest registry add @lumesec=https://elements.lumesec.ai/r/{name}.jsonOr skip the setup and install by URL:
npx shadcn@latest add https://elements.lumesec.ai/r/geo-ip.jsonUsage
"use client";
import { GeoIp, type GeoIpResult } from "@/components/lumesec/geo-ip";
async function resolve(address: string): Promise<GeoIpResult | null> {
const response = await fetch(`/api/ip/${encodeURIComponent(address)}`);
if (!response.ok) return null;
const result: GeoIpResult = await response.json();
return result;
}
export function Example() {
return <GeoIp defaultValue="203.0.113.42" resolve={resolve} />;
}Behaviour
A field that looks up where an IP address is located and shows the result on a small map. While the lookup runs, a crosshair hops from land dot to land dot and slows down like a slot machine before it locks onto the result.
The coordinates roll into place, and the place, network and accuracy appear below. Private and reserved addresses are answered at once without a lookup. Bring your own resolve function; the built-in one invents a location and is only for demos.
API reference
Ref
ref points at the root HTMLDivElement.
Theming
Styled with Tailwind classes on your shadcn theme tokens, so light and dark follow your theme. The accent comes from --lumesec. See Theming.
Related
Was this page helpful?