Forms & Input
Label
Accessible captions for form controls — Radix/shadcn-aligned typography and disabled-state pairing. Make the expected input clear before someone interacts, and keep the current value, help text and validation feedback connected. Import it from @/components/kamod-ui/label.
Source · Design reference · API reference · Theming · Styles
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthInstallation
Import Label from @/components/kamod-ui/label.
pnpm add @kamod-ch/uiCopy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.
Usage
Associate controls with htmlFor/id. Put the control Before the label when you rely on Tailwind peer-disabled styling on the label. For full forms with legends and errors, prefer a Field pattern when your app provides it.
import { Label } from "@kamod-ch/ui";Choose a complete composition from the examples below; required child components and props vary by pattern.
Component Examples & Variants
Explore Label in Different Contexts, from the starting pattern to the compositions below. Begin with Demo, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.
Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.
Demo
Keep Visual State Tied to the Real Input. Place the checkbox before its associated Label so peer-based disabled styling can reflect the control's state. The label then serves both as visible explanation and as the named target associated with that checkbox.
Test clicking the text and reading the field name, not only whether the disabled color looks right.
Usage
Connect a Readable Name to One Control. Connect Label through htmlFor to the control's matching id. This small association makes the visible field name meaningful to the browser and assistive technology, rather than merely placing text near an input.
Repeated examples need distinct identifiers so activating one label cannot accidentally focus or toggle another field.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthLabel with Checkbox
Make the Words Activate the Choice. Pair Label with a checkbox using the same identifier, and let the control's disabled state drive its peer styling. The label remains readable while communicating that the corresponding choice cannot currently be changed.
Keep the disabled state on the actual control, preserve any explanatory text nearby, and avoid placing unrelated links inside a label when their action could conflict with toggling.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthLabel with Input
Keep the Name Visible While the Value Changes. Stack Label above Input when the field needs a persistent name independent of its placeholder. Keep htmlFor and the input's id aligned so the visual arrangement also has a programmatic association.
Use a stable identifier, add hints separately and avoid putting formatting instructions into an excessively long field name.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthLabel with Textarea
Explain What Belongs in the Longer Response. Associate Label with a textarea through its id, giving a longer answer a stable field name. The label should explain the requested content while any format or length guidance remains nearby as supporting text.
Keep both available during editing and ensure the multiline control's identifier remains unique when the pattern appears several times.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthLabel in a Form Stack
Associate Help as Well as the Name. Compose Label, Input and a muted help paragraph when building a field without the higher-level Field wrapper. Give the help text an identifier and associate it with the input where that explanation is needed.
Use Field when repeated descriptions and validation messages would otherwise require the same surrounding structure throughout a form.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthSizes
Choose a Readable Hierarchy for the Form. Use the label's size options to match its typography to the surrounding controls. Changing the visual scale should preserve the wording and identifier association that make the label useful for understanding and focusing the field.
Keep size choices consistent across related fields and avoid reducing contrast at the same time that you reduce the text size.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthProps and Data
Configure Label using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.
Props, slots and variants for this component.
Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.
Component Props
? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.Label
LabelProps
| Prop / type | Description |
|---|---|
class | Configure
|
size | Configure
|
Data Type Reference
Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.
Label Props
DeclarationLabelPropsLabel.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of LabelProps before adapting it.Accessibility
Build the Complete Interaction, Including the Parts Outside Label. The notes below distinguish the current implementation from the labels, content and behavior your application supplies. Start with the Live Preview, check the Props and Data Reference, and test the finished composition with real content rather than assuming that an unchanged visual example covers every use case.
Built-in Behavior and Defaults
Label renders the native label element. Association comes from htmlFor matching a labelable control's id, or from correctly nesting a control inside it. Color, proximity and peer-disabled styling alone do not create that relationship.
Labels and Relationships
Use a short visible name that describes the requested information. Keep instructions separate and connect them with aria-describedby. Ensure an explicit aria-label on the control does not replace the visible label with unrelated wording.
Keyboard and Focus
Clicking the label should focus or activate its control. Provide one coherent label per input and keep links or secondary buttons outside the label when they perform a separate action. A label cannot associate with an arbitrary non-labelable wrapper by ID alone.
States and Integration Details
Avoid duplicated IDs in repeated rows and dialogs. A required marker should have a visible explanation; disabled label styling should reflect the actual control state rather than merely making text look inactive.
Verify the Complete Interaction
Check Behavior as Well as Markup. Work through these scenarios in the application where the component will be used. Automated checks can help find structural problems; also review the reading experience with a screen reader, keyboard focus and the actual feedback from your application.
- Click and tap the label, including around its text edges, and confirm the expected control responds.
- Compare the visible name with the accessibility tree's computed name.
- Mount repeated instances and verify every htmlFor points to exactly one intended element.
Recheck the result after changing Theme Tokens, translations or class overrides. Include text enlargement, narrow layouts and reduced-motion settings where animation is present. Inspect the Component Source when a behavior differs from your expectation; a role or state attribute does not implement keyboard interaction by itself.
For background, read the WAI-ARIA Authoring Guidance and Keyboard Interface Guidance. These explain the patterns; verify browser and assistive-technology behavior for the implementation and audience you actually support.
You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.
Connect the Foundation
Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.
Build the Surrounding Screen
Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.
Make the Result Hold Up
Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.
Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.