Add this component

npx zentauri-ui add api-endpoint-card

Accessibility notes

Keyboard accessible by default with semantic markup, visible focus treatment, and tokenized states. Add descriptive labels for icon-only or decorative usage.

Dependency notes

Check Installation for shared peers. This component keeps styling in Tailwind classes and the --zui-* token contract.

API

API Endpoint Card for documenting routes

Use the API endpoint card to present an HTTP endpoint as a compact, scannable surface. A colored method badge identifies the HTTP verb, the path shows the route pattern with path parameters, an optional description explains the endpoint's purpose, and an authentication badge signals whether the endpoint requires auth.

GET/api/v1/users/:id

Retrieve a user by their unique identifier.

API endpoint card playground

Pick an HTTP method to preview the endpoint card live. Use Show output / Show code to copy the matching snippet.


GET/api/v1/users/:id

Retrieve a user by their unique identifier.

Api Endpoint Card API

Generated from the package prop types and variant definitions.

ApiEndpointCard

ApiEndpointCardProps

Variants

PropTypeDefault
appearance
contrastdefaultglasssubtle
default
size
lgmdsm
md

Behavior

PropTypeDefault
descriptionstring | undefinednone
examplesEndpointExample[] | undefinednone
labelsApiEndpointCardLabels | undefinednone
method*ApiEndpointMethodnone
path*stringnone
showExamplesboolean | undefinednone
showTagsboolean | undefinednone
tagsstring[] | undefinednone
Inherited HTML props
PropTypeDefault
classNamestring | undefinednone
idstring | undefinednone
onClickMouseEventHandler<HTMLDivElement> | undefinednone
styleCSSProperties | undefinednone
titlestring | undefinednone

ApiEndpointCardVariant

ApiEndpointCardVariantProps

Behavior

PropTypeDefault
appearance'default' | 'subtle' | 'contrast' | 'glass' | null | undefinednone
size'md' | 'sm' | 'lg' | null | undefinednone

ApiEndpointCardAnimated

ApiEndpointCardAnimatedProps

animated

Behavior

PropTypeDefault
animationApiEndpointCardAnimation | undefinednone
appearance'default' | 'subtle' | 'contrast' | 'glass' | null | undefinednone
descriptionstring | undefinednone
examplesEndpointExample[] | undefinednone
labelsApiEndpointCardLabels | undefinednone
method*ApiEndpointMethodnone
path*stringnone
refAllows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).Ref<HTMLDivElement> | undefinednone
showExamplesboolean | undefinednone
showTagsboolean | undefinednone
sizeNonNullable<'md' | 'sm' | 'lg' | null | undefined> | undefinednone
tagsstring[] | undefinednone
Inherited HTML props
PropTypeDefault
classNamestring | undefinednone
idstring | undefinednone
onClickMouseEventHandler<HTMLDivElement> | undefinednone
styleCSSProperties | undefinednone
titlestring | undefinednone
CSS variable overrides

API Endpoint Card CSS variables

Override these API endpoint card variables on :root, a theme selector, or a component wrapper. Tokens are grouped by section (card chrome, method badges, text).

46 variables

Pattern: --zui-<component>-<slot?>-<variant?>-<property>-<state?>-dark?

:root {
  --zui-api-endpoint-card-border: #0000001a;
  --zui-api-endpoint-card-bg: oklch(98.4% 0.003 247.858);
  --zui-api-endpoint-card-fg: oklch(20.8% 0.042 265.755);
  --zui-api-endpoint-card-path-fg: #334155;
  --zui-api-endpoint-card-description-fg: #64748b;
  --zui-api-endpoint-card-auth-fg: #16a34a;
  --zui-api-endpoint-card-auth-bg: #dcfce7;
  --zui-api-endpoint-card-noauth-fg: #94a3b8;
  --zui-api-endpoint-card-noauth-bg: #f1f5f9;
  --zui-api-endpoint-card-method-get-fg: #15803d;
  --zui-api-endpoint-card-method-get-bg: #dcfce7;
  --zui-api-endpoint-card-method-post-fg: #1d4ed8;
  --zui-api-endpoint-card-method-post-bg: #dbeafe;
  --zui-api-endpoint-card-method-put-fg: #c2410c;
  --zui-api-endpoint-card-method-put-bg: #ffedd5;
  --zui-api-endpoint-card-method-patch-fg: #7c3aed;
  --zui-api-endpoint-card-method-patch-bg: #f3e8ff;
  --zui-api-endpoint-card-method-delete-fg: #b91c1c;
  --zui-api-endpoint-card-method-delete-bg: #fee2e2;
  --zui-api-endpoint-card-method-head-fg: #0891b2;
  --zui-api-endpoint-card-method-head-bg: #cffafe;
  --zui-api-endpoint-card-method-options-fg: #475569;
  --zui-api-endpoint-card-method-options-bg: #f1f5f9;
}

/* Dark theme variables follow the same names with -dark appended. */
.dark {
  --zui-api-endpoint-card-border-dark: #ffffff1a;
  --zui-api-endpoint-card-bg-dark: oklch(12.9% 0.042 264.695);
}

Composition and API

Pass the endpoint details as props: method drives the HTTP method badge color, path displays the route pattern, description provides context, and authenticated toggles an authentication badge. The method prop accepts GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS.

Accessibility

The card renders with semantic markup and data-slot attributes for styling and testing. The method badge carries a data-method attribute reflecting the HTTP verb, and the authentication badge uses a data-authenticated attribute. Color is never the only signal — text labels accompany every visual indicator.

Next.js integration notes

The static ApiEndpointCard entry ships no framer-motion and is safe in any Server or Client Component tree. It renders deterministically from the given props, so server and client output match and there is no hydration mismatch. Import it from @zentauri-ui/zentauri-components/ui/api-endpoint-card.

FAQ

How is the method badge color chosen?

Each HTTP method maps to a distinct semantic color: GET is green, POST is blue, PUT is orange, PATCH is purple, DELETE is red, HEAD is cyan, and OPTIONS is slate. These colors route through the --zui-api-endpoint-card-* tokens with light and dark values.

Can I add an authentication indicator?

The component does not include a built-in authenticated prop. Add a description or tags to indicate auth requirements, or wrap the card with your own authentication badge.

Can I customize the path and description styles?

Yes. Override the --zui-api-endpoint-card-* CSS variables (path-fg, description-fg, and the per-method badge colors) on :root, a theme selector, or a wrapper. Each variable ships a light fallback and a paired -dark variant for dark mode.

Does it need framer-motion?

No. The API endpoint card is static and presentational with no animated entry, so it ships zero framer-motion and adds no motion dependency to your bundle.