Skip to content

EndpointBadge

Hero example

POST/v1/entities

When to use

Reach for <EndpointBadge> when documenting or labelling an HTTP endpoint — in code samples, recipe diagrams, API reference pages. The method takes the canonical method-palette colour (--method-{get,post,put,patch,delete}) so consumers can scan a list of endpoints by colour alone — but the text label is always present, so colour is supplemental, not the sole differentiator.

Omit the path prop to render verb-only mode — a stand-alone method chip suitable wherever V1 <VerbPill> was used. The chip's background tints to the method's --method-*-bg. The current V2 migration uses verb-only EndpointBadge as the canonical replacement for <VerbPill>.

Don't reach for EndpointBadge for non-HTTP labels — that's Pill or MonoChip. Don't use it as a button either; it's a label. Wrap the surrounding row in an anchor for navigation.

Do — pair <EndpointBadge> with a request body or response example in code-heavy contexts.
Don't — use it as a button. It's a label; wrap the surrounding row in an anchor if you need navigation.

Anatomy

Two inline spans inside a .endpoint chip: a .method span (colour-coded by verb) followed by the path. In verb-only mode (path omitted), only the method span renders and the chip applies .endpoint-verb-only for the method-tinted background.

Props

PropTypeDefaultDescription
methodrequiredHttpMethod
pathstring

Also accepts Omit<React.HTMLAttributes<HTMLSpanElement>, "children">.

Verb-only mode

<EndpointBadge method="GET" path="/v1/entities" />   {/* standard */}
<EndpointBadge method="POST" />                       {/* verb-only — replaces <VerbPill verb="POST"> */}
Method.method colourVerb-only background
GET--method-get--method-get-bg
POST--method-post--method-post-bg
PUT--method-put--method-put-bg
PATCH--method-patch--method-patch-bg
DELETE--method-delete--method-delete-bg

States

EndpointBadge has no states. Verb-only vs full-mode is configuration, not state.

Density

POST/v1/entities
POST/v1/entities

In compact, the chip height drops from 22 to 18px. Verb and path font sizes stay constant — legibility floor.

Themes

POST/v1/entities
POST/v1/entities
POST/v1/entities

In dark, method colors shift to their dark-theme variants and the chip surface inverts. In forced-colors, method color collapses to HighlightText and the chip surface to Highlight — the text label preserves the semantic.

Tokens consumed

colors15 tokensv2.3.0
#2A6FDB
matter
src ↗
#1F8A5B
matter
src ↗
#7A4FB8
matter
src ↗
#B45A1A
matter
src ↗
#B0322B
matter
src ↗
#2a6fdb
brand
src ↗
rgba(42, 111, 219, 0.1)
brand
src ↗
#1f8a5b
brand
src ↗
rgba(31, 138, 91, 0.1)
brand
src ↗
#b45a1a
brand
src ↗
rgba(180, 90, 26, 0.1)
brand
src ↗
#b45a1a
brand
src ↗
rgba(180, 90, 26, 0.1)
brand
src ↗
#b0322b
brand
src ↗
rgba(176, 50, 43, 0.1)
brand
src ↗

Method foreground reads --method-{verb}. Verb-only chip background reads --method-{verb}-bg. Chip surface (full mode) reads --code-surface.

Accessibility

  • Keyboard interactions. None — the badge is non-interactive.
  • ARIA roles and properties. Generic span. No role override. Method and path text supply the accessible name.
  • Focus order. N/A.
  • Screen-reader expectations. Announces verbatim — "POST /v1/entities" or "POST" (verb-only).
  • Reduced motion. N/A.
  • Forced colors. Method foreground → HighlightText; surface → Highlight. The text label remains intact.
  • WIG rules. Color is supplemental, not sole. Mono caps via 0.04em letter-spacing on the method. Touch-action manipulation on the chip when wrapped in a link.

Do / Don't

Do — render <EndpointBadge method="POST" path="/v1/entities" /> for full-endpoint labelling.
Don't — render a verb without a method-color match. The five canonical verbs are the only supported values.
Do — use verb-only mode for inline action labels in tables, lists, and chat replies — same shape as V1 VerbPill.
Don't — emulate a button with EndpointBadge. Use a real <button> or <a> wrapping the badge.
Do — pair with a CodeBlock or CodeCard for endpoint demos. The badge labels what the code below is doing.
Don't — pass query strings or body fragments in path. The path is the route shape only.

Recipes

This component appears in:

Code example

import { EndpointBadge, CodeBlock } from "@matter/components";

export function CreateEntityEndpoint() {
  return (
    <CodeBlock
      header={
        <>
          <EndpointBadge method="POST" path="/v1/entities" />
          <span className="code-time">142ms</span>
        </>
      }
    >
      {/* request body */}
    </CodeBlock>
  );
}

Source

packages/components/src/EndpointBadge

On this page