XDSFieldLabel@xds/core · Field
Usage
Field wraps any input control with a label, description, and validation status. Use it to build accessible forms with consistent labeling, optional/required indicators, and inline error, warning, or success feedback.Best practices
| Guidance | Practices |
|---|---|
| Do | Always provide a label for accessibility, even if visually hidden with isLabelHidden. |
| Do | Use the status prop with clear messages to provide inline validation feedback. |
| Do | Add a description when the label alone does not explain what the field expects, like format hints or constraints. |
| Don't | Set both isOptional and isRequired on the same field. |
| Don't | Use the detached status variant on bordered inputs — reserve it for checkboxes, switches, and sliders. |
| Don't | Hide the label without providing an alternative way for the user to understand the field purpose. |
Anatomy
| Element | Description | |
|---|---|---|
| Label | required | Text identifying the field. Always rendered for accessibility, optionally hidden visually. |
| Description | Helper text between the label and input explaining what to enter. | |
| Input slot | required | The input control wrapped by the field — TextInput, Select, DateInput, etc. |
| Status message | Inline validation feedback showing error, warning, or success with a message. | |
| Optional/Required indicator | Badge next to the label showing whether the field is optional or required. | |
| Label tooltip | Info icon at the end of the label with a tooltip explaining the field. |
Import
tsimport {XDSFieldLabel} from '@xds/core/Field'
Props
| Prop | Type | Description |
|---|---|---|
labelrequired | string | Label text. |
inputIDrequired | string | ID of the input this label is for. |
isLabelHidden | boolean (default: false) | Visually hide the label. |
isDisabled | boolean (default: false) | Whether the associated input is disabled. |
isOptional | boolean (default: false) | Show "Optional" indicator. |
isRequired | boolean (default: false) | Show "Required" indicator. |
labelIcon | XDSIconType | Icon before the label text. See `npx xds docs icons` for valid semantic names. |
labelTooltip | string | Tooltip text for info icon at end of label. |
Showcase source
tsx'use client';import {XDSFieldLabel} from '@xds/core/Field';import {XDSVStack} from '@xds/core/Layout';const LockIcon = (props: React.SVGProps<SVGSVGElement>) => (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round" {...props}><rect x="3" y="11" width="18" height="11" rx="2" /><path d="M7 11V7a5 5 0 0 1 10 0v4" /></svg>);export default function FieldLabelShowcase() {return (<XDSVStack gap={4}><XDSFieldLabellabel="Email address"inputID="email-input"isRequired/><XDSFieldLabellabel="Phone number"inputID="phone-input"isOptionaldescription="Include country code for international numbers"/><XDSFieldLabellabel="API key"inputID="api-input"labelTooltip="Your API key can be found in the developer settings"labelIcon={LockIcon}/><XDSFieldLabellabel="Disabled field"inputID="disabled-input"isDisabled/></XDSVStack>);}