HomeGetting StartedColor SystemTypographySpacingIconographyLayoutInstallationUsageAngularBlazorReactSvelteVueThemingTypographyCustomizationCSS-Only ComponentsFormsIconsIllustrationsAccessibilityGlobal ConfigurationTailwind CSSSass LibraryForge MCP ServerDropdown OptionsFocus Indicator ClippingAll componentsButtonButton AreaChipFloating Action ButtonIcon ButtonSplit ButtonAutocompleteButton ToggleCalendarCheckboxChip FieldColor PickerDate PickerDate Range PickerFile PickerLabelRadioSelectSliderSwitchText FieldTime PickerApp BarApp LauncherDrawerMenuPaginatorSkip LinkStepperTabsView SwitcherAccordionApp LayoutCardDividerExpansion PanelScaffoldSplit ViewStackStructured CardToolbarBadgeBannerBusy IndicatorCircular ProgressDialogInline MessageLinear ProgressPage StateSkeletonToastTooltipAvatarIconKeyLabel ValueListMeterSecretTableTimelineTimestampTreeKeyboard ShortcutPopoverIntroductionColorTypographySpacingShapeBorderElevationLayeringAnimationUsageIcon LibraryBlocksRoadmapChangelogBlog

Label

Labels attach an accessible caption and Forge typography to a specific set of label-aware Forge components, in place of a plain HTML label element.

Label

Usage

forge-label provides an accessible caption and Forge typography for a specific set of label-aware components — button, checkbox, icon button, radio, select, switch, and button toggle groups — through for (explicit ID association), legend, and non-interactive. It isn’t a general-purpose replacement for a plain <label> — it only works when paired with one of these specific elements, so reach for a native <label> (or aria-label) when labeling anything else, including text fields, which manage their own label internally.

Rules

Do
Only use forge-label with the specific components it supports — check the list above before reaching for it.Nest the associated element inside the label when you don't need it to render anywhere else, instead of wiring up for/id.Use legend when labeling a group of radios, so it reads as the group's caption rather than one option's label.
Don't
Don't use forge-label on an element it doesn't support — use a native label or aria-label instead.Don't duplicate a label both nested and via the for attribute on the same element.

ID associated

Set for to the id of the labeled element to associate them explicitly, without nesting one inside the other.

A label explicitly associated with an element via the for attribute.

Nested

Nest the labelable element directly inside forge-label for implicit association — no for/id pair needed.

A label implicitly associated with a nested element.

Legend

Set legend to use the label as a group caption instead of labeling one specific element — the standard pattern for a group of radios.

A label used as a legend for a radio group.

Aligned list

Pair a label with its associated element in a list, so a set of fields lines up consistently.

Labels aligned with their associated elements in a list.

With icon button

Label an icon button to give it a persistent, visible caption alongside its accessible name.

A label captioning an icon button.

The Label component is used to associate a text label with a compatible Forge component.

import "@tylertech/forge/label";
Properties
PropertyAttributeTypeDefaultDescription
forforstring | null | undefinednullThe id of the associated element.
forElement—HTMLElement | null | undefinednullThe associated element.
clickTarget—HTMLElement | null | undefinednullThe element that a click should be simulated on. If not defined clicks act on the associated element.
dynamicdynamicbooleanfalsePropagates changes in the label's text content to the associated element.
nonInteractivenon-interactivebooleanfalseRemoves click handling from the label.
legendlegendbooleanfalseWhether or not the label should be associated with an ancestor element.
Methods
NameReturnsDescription
update()voidUpdates the targeted element with the label's current text content.

Accessibility documentation coming soon.

Loading Forge chat…