Interactive Answers

Match Field

A fit field — candidates, bots or options placed by score around a centre, grouped into sectors, with threshold rings.

3 variantsMIT

Preview

Installation

Copies the component into components/ui and installs its dependencies and theme tokens.

pnpm dlx shadcn@latest add https://uilab.tmih06.com/r/match-field.json

Usage

Pass your own data and wire the callbacks to your agent runtime.

import { MatchField } from "@/components/ui/match-field";

export function Shortlist({ role, matches }: { role: Role; matches: Match[] }) {
  return (
    <MatchField
      title={role.title}
      subtitle={`${matches.length} applicants · ranked by fit`}
      sectors={["Design systems", "Fintech", "Consumer apps", "Agency"]}
      items={matches.map((m) => ({
        id: m.id,
        name: m.name,
        sector: m.backgroundIndex,
        score: m.fit, // 0–1 from your ranking model
      }))}
      threshold={0.85}
      onSelect={(item) => openProfile(item.id)}
    />
  );
}

// Pass null while the matching request is in flight; keep stale data and set
// loading when refetching.
export function MatchState({ query }: { query: MatchQuery }) {
  return (
    <MatchField
      title="Best fits"
      sectors={query.data?.sectors ?? null}
      items={query.data?.items ?? null}
      loading={query.isRefetching}
      skeleton={{ count: query.data?.sectors.length ?? 4 }}
    />
  );
}

Props

PropTypeDefaultDescription
sectors*string[] | null—Categories around the edge, clockwise from the top.
items*MatchItem[] | null—Placed in their sector, closer to the middle the higher they score. Items at or above the threshold get a label.
loadingbooleanfalseForce the fixed-footprint skeleton while refetching, even when stale matches are available.
skeleton{ count?: number }—Loading footprint hint for the number of sectors. Falls back to stale sectors, then 4.
title*string—Header title.
subtitlestring—Secondary line under the title.
ringsnumber[][0.5, 0.7, 0.85]Scores drawn as dashed, labeled rings.
thresholdnumberhighest ringStrong-fit score. Its ring and the dots inside it are tinted brand.
minnumberlowest ring − 0.15Score on the outer edge. Lower scores are clamped to it.
iconIconBriefcasePhosphor icon in the middle: the role or request being matched.
onSelect(item: MatchItem) => void—Called when an item is hovered, clicked or reached with the arrow keys.
localestring"en-US"BCP 47 locale for scores shown as percentages.
labelsPartial<MatchFieldLabels>—Your own UI strings (loading announcement, the "above 85%" badge and screen-reader text), for translating. Right-to-left works under `dir="rtl"`; the plot itself keeps its clockwise layout.
classNamestring—Extra classes for the root element.
type MatchItem = {
  id: string;
  name: string;
  initials?: string; // defaults to the first letters of the name
  sector: number;    // index into sectors
  score: number;     // 0–1, higher sits closer to the middle
  color?: string;    // avatar color, defaults to a categorical palette
};