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

GuidancePractices
DoAlways provide a label for accessibility, even if visually hidden with isLabelHidden.
DoUse the status prop with clear messages to provide inline validation feedback.
DoAdd a description when the label alone does not explain what the field expects, like format hints or constraints.
Don'tSet both isOptional and isRequired on the same field.
Don'tUse the detached status variant on bordered inputs — reserve it for checkboxes, switches, and sliders.
Don'tHide the label without providing an alternative way for the user to understand the field purpose.

Anatomy

ElementDescription
LabelrequiredText identifying the field. Always rendered for accessibility, optionally hidden visually.
DescriptionHelper text between the label and input explaining what to enter.
Input slotrequiredThe input control wrapped by the field — TextInput, Select, DateInput, etc.
Status messageInline validation feedback showing error, warning, or success with a message.
Optional/Required indicatorBadge next to the label showing whether the field is optional or required.
Label tooltipInfo icon at the end of the label with a tooltip explaining the field.

Import

ts
import {XDSFieldLabel} from '@xds/core/Field'

Props

PropTypeDescription
labelrequired
stringLabel text.
inputIDrequired
stringID 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
XDSIconTypeIcon before the label text. See `npx xds docs icons` for valid semantic names.
labelTooltip
stringTooltip 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}>
<XDSFieldLabel
label="Email address"
inputID="email-input"
isRequired
/>
<XDSFieldLabel
label="Phone number"
inputID="phone-input"
isOptional
description="Include country code for international numbers"
/>
<XDSFieldLabel
label="API key"
inputID="api-input"
labelTooltip="Your API key can be found in the developer settings"
labelIcon={LockIcon}
/>
<XDSFieldLabel
label="Disabled field"
inputID="disabled-input"
isDisabled
/>
</XDSVStack>
);
}