Skip to main content
Version: latest
Server Component

Label is best rendered on the server. Use the standard import (e.g. @prokodo/ui/label) — the library detects the runtime automatically.

Label

Label renders an accessible <label> element. It can stand alone as a visible descriptor or be composed inside other form components to reduce boilerplate.

Live demo →

Overview

import { Label } from '@prokodo/ui/label'

<Label htmlFor="email" required>
Email address
</Label>
<input id="email" type="email" />

Import

import { Label } from "@prokodo/ui/label"

CSS:

import "@prokodo/ui/label.css"

Props

PropTypeDefaultRequiredDescription
labelstringLabel text.
type"label" | "legend""label"Rendered HTML element type.
htmlForstringAssociates label with a form control (like for).
errorbooleanfalseApply error styling.
colorVariantsAccent color variant.
textPropsobjectProps forwarded to the inner text element.
contentPropsobjectProps forwarded to the content wrapper.
classNamestringCSS class on root element.

See src/components/label/Label.model.ts for the full LabelProps type.


Design Tokens

Customise Label via CSS custom properties on :root or a scoped ancestor.

TokenDefaultDescription
--pk-label-gradient-fromvar(--pk-color-brand)First-word highlight gradient start
--pk-label-gradient-tovar(--pk-color-accent)First-word highlight gradient end
--pk-label-fgvar(--pk-color-muted)Remaining words colour
--pk-label-error-fromvar(--pk-color-error)Error-state gradient start
--pk-label-error-to#ff6b6bError-state gradient end

WCAG 2.2 Status

CriterionNameStatusNote
1.3.1Info and Relationships (A)✅ FulfilledSemantic structure (headings, lists, labels, landmarks) must be conveyed programmatically via HTML or ARIA.
1.3.5Identify Input Purpose (AA)🔍 Manual reviewForm fields collecting personal data must expose their purpose via the HTML autocomplete attribute.
2.1.1Keyboard (A)✅ FulfilledAll functionality must be operable via keyboard alone, without requiring specific timing.
2.4.7Focus Visible (AA)🔍 Manual reviewA visible keyboard focus indicator must be present on every interactive element. Verify against the applied product theme.
2.4.11Focus Not Obscured (Min.) (AA)🔍 Manual reviewThe focused component must not be fully hidden by sticky headers, overlays, or other positioned page elements.
3.3.1Error Identification (A)🔍 Manual reviewInput errors must be identified and described to the user in text, not by colour alone.
3.3.2Labels or Instructions (A)✅ FulfilledEvery form input requires a programmatically associated label or a visible instruction.
4.1.2Name, Role, Value (A)✅ FulfilledName, role, and state of all interactive UI components must be programmatically determinable via native HTML semantics or ARIA.

Test coverage: 3 jest-axe assertion(s) across 1 test file(s) · 1 ARIA attribute occurrence(s) in source scan. Criteria marked 🔍 require manual verification in the final product integration and theme context.

Storybook

👉 Open Label in Storybook


Source

src/components/label/Label.model.ts