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

Text Field

An input field used to capture user text input, with an optional label, helper text, and validation state.

Overview

Text fields allow users to enter and edit text within forms, dialogs, and other interfaces. They provide a structured way to collect user input with clear labeling, validation, and formatting support to ensure data quality and usability.

Usage

forge-text-field wraps a child <input> or <textarea> and an optional <label>, handling layout and state through variant, theme, shape, density, label-position, invalid, required, optional, and disabled. For a fixed set of choices, reach for a select or autocomplete instead; for freeform, removable entries like tags or recipients, use a chip field.

Rules

Do
Always show a visible label — don't rely on placeholder text alone.Put extra guidance in helper text below the field instead of placeholder text.Replace helper text with error text during validation to avoid content shifting.Write error text as an actionable fix, and validate once the user leaves the field, not on every keystroke.Match field length to expected input or use consistent lengths that accommodate typical responses.
Don't
Don't truncate long label text or allow labels to wrap to multiple lines.Don't use placeholder text as a substitute for a label — it disappears the moment the user types. The one exception is a search or filter field.Don't show error text and helper text in the same space — the error replaces the helper text, it doesn't stack with it.Don't disable a field just to display a fixed value — use a label-value pair instead.Don't validate before users enter information — wait until they leave the field.

Variant

Set variant to outlined (the default), plain, tonal, filled, or raised to match the field to its surrounding context.

All five field variants.

Label position

Set label-position to control where the label sits relative to the input: inset (the default) floats it inside the field, block-start places it above, inline-start and inline-end place it beside the field, and none hides it. Only use none for a search or filter field, and give the <input> an aria-label so it still has an accessible name.

Label positioned above the field.

Label positioned inline, beside the field.

Helper text and validation

Slot support text in the helper-text slot, set required for a required field, and set invalid to swap in error text describing the fix.

Set required on both elements

required on forge-text-field only shows the required-field indicator — it’s presentational. Native form validation and accessibility come from required on the nested <input>. Set both, or validation silently breaks.

<forge-text-field required>
  <input required />
</forge-text-field>

Helper text, a required field, and an invalid field with error text.

Multiline

Slot a <textarea> instead of an <input> for longer, multi-line responses. Prefer it over letting a single-line input grow, and size it to fit within mobile screen heights.

A textarea slotted in place of an input.

Clear button

Set show-clear to add a button that clears the field’s value, appearing once the field has a value.

A clear button appears once the field has a value.

Leading and trailing content

Slot an icon or short text in the start slot to render it before the input, or in the end slot to render it after, like a unit suffix.

Search and filter fields

A search or filter field is the one place a field may go without a visible label. Set label-position="none", put a search icon in the start slot, set show-clear, and use a short placeholder like “Search” or “Filter by name” in place of the label. Give the <input> an aria-label, since the placeholder isn’t an accessible name.

<forge-text-field label-position="none" show-clear>
  <forge-icon slot="start" name="search"></forge-icon>
  <input type="search" placeholder="Search" aria-label="Search" />
</forge-text-field>

Every other form field keeps a visible label and doesn’t use a placeholder.

Disabled and readonly

Set disabled to exclude the field from the form.

A disabled field.

The Forge Text Field component is an input field used to capture user text input. It requires a child `<input>` or `<textarea>` element to function properly, and an optional `<label>` element can be used to provide a label for the `<input>`.

import "@tylertech/forge/text-field";
Properties
PropertyAttributeTypeDefaultDescription
popoverTargetElement—HTMLElement—Gets a reference to the element that the popover should target for best alignment.
showClearshow-clearbooleanfalseWhether the clear button appears when text has been entered.
labelPositionlabel-positionFieldLabelPosition"inset"The position of the label relative to the field.
labelAlignmentlabel-alignmentFieldLabelAlignment"start"The alignment of the label relative to the field.
invalidinvalidbooleanfalseWhether the field is in an invalid state.
requiredrequiredbooleanfalseWhether the field is required.
optionaloptionalbooleanfalseWhether the field is optional.
disableddisabledbooleanfalseWhether the field is disabled.
floatLabelfloat-labelbooleanfalseWhether the label should float above the field. Only applies when the label is inset.
variantvariantFieldVariant"outlined"The variant of the field.
themethemeFieldTheme"default"The theme of the field.
shapeshapeFieldShape"default"The shape of the field.
densitydensityFieldDensity"default"The density of the field.
densedensebooleanfalseWhether the field is dense.
popoverIconpopover-iconbooleanfalseWhether the field has a popover icon.
popoverExpandedpopover-expandedbooleanfalseWhether the field's popover is expanded.
supportTextInsetsupport-text-insetFieldSupportTextInset"none"The inset of the support text.
Events
NameTypeDescription
forge-text-field-clearCustomEvent<void>Dispatched when the clear button is clicked.
forge-field-popover-icon-clickCustomEvent<void>Dispatches when the user clicks the popover icon.
Slots
NameDescription
(default)The default/unnamed slot for the field's input.
labelRenders its content as a positioned label.
startTypically reserved for content/icons that render logically before the default slot content.
endTypically reserved content/icons that render logically after the default slot content.
clear-buttonContent slotted here replaces the default clear button.
clear-button-tooltipSets the text content of the clear button's tooltip and accessible label.
accessoryUsed for content such as a button that is logically connected to the field but should appear distinct from the input.
support-textUsed for content that provides additional information about the field. Aligns to the inline start of the field.
support-text-endUsed for content that provides additional information about the field. Aligns to the inline end of the field.
CSS Parts
NameDescription
::part(root)The root container element.
::part(label)The label element.
::part(container)The container element surrounding the input.
::part(input)The element containing te input slot.
::part(start)The element containing the start slot.
::part(end)The element containing the end slot.
::part(popover-icon)The popover icon element.
::part(accessory)The element containing the accessory slot.
::part(support-text)The support text element.
::part(support-text)The support text element.
::part(support-text-end)The element containing the support text end slot.
::part(outline)The element containing the forge-focus-indicator element.
::part(focus-indicator)The focus indicator element.
CSS Custom Properties
NameDescription
--forge-field-backgroundThe background of the field surface.
--forge-field-tonal-backgroundThe background of the field surface in the tonal variant.
--forge-field-tonal-background-hoverThe background of the field surface in the tonal variant on hover.
--forge-field-filled-backgroundThe background of the field surface in the filled and raised variants.
--forge-field-outline-styleThe style of the field outline.
--forge-field-outline-widthThe width of the field outline.
--forge-field-shapeThe border radius of the field's corners.
--forge-field-heightThe height of the field in its default density.
--forge-field-inset-heightThe height of the field in its default density when the label is inset.
--forge-field-padding-inlineThe inline padding of the field.
--forge-field-padding-inline-startThe inline start padding of the field.
--forge-field-padding-inline-endThe inline end padding of the field.
--forge-field-inner-padding-inlineThe padding between elements slotted into the field.
--forge-field-support-text-margin-blockThe margin between the support text and the field.
--forge-field-support-text-gapThe minimum gap between the support text and the support text end.
--forge-field-support-text-padding-inlineThe inline padding of the support text.
--forge-field-support-text-padding-inline-startThe inline start padding of the support text.
--forge-field-support-text-padding-inline-endThe inline end padding of the support text.
--forge-field-label-margin-inlineThe margin between the label and the field when the label is in an inline position.
--forge-field-label-margin-blockThe margin between the label and the field when the label is in the block start position.
--forge-field-required-paddingThe padding between the required indicator and the label.
--forge-field-required-contentThe content of the required indicator.
--forge-field-optional-paddingThe padding between the optional indicator and the label.
--forge-field-optional-contentThe content of the optional indicator.
--forge-field-multiline-resizeThe direction the field can be resized when multiline.
--forge-field-multiline-min-inline-sizeThe minimum inline size the field can be resized to when multiline.
--forge-field-multiline-max-inline-sizeThe maximum inline size the field can be resized to when multiline.
--forge-field-multiline-min-block-sizeThe minimum block size the field can be resized to when multiline.
--forge-field-multiline-max-block-sizeThe maximum block size the field can be resized to when multiline.
--forge-field-popover-icon-transition-durationThe duration of the popover icon animation.
--forge-field-popover-icon-transition-timingThe timing function of the popover icon animation.
--forge-field-popover-icon-open-rotationThe rotation of the popover icon when open.
--forge-field-surface-animation-durationThe duration of background and outline animations.
--forge-field-surface-animation-timingThe timing function of background and outline animations.
--forge-field-surface-floating-animation-durationThe duration of the floating label animation.
--forge-field-surface-floating-animation-timingThe timing function of the floating label animation.
--forge-field-focus-indicator-widthThe width of the focus indicator.
--forge-field-disabled-opacityThe opacity of the field when disabled.
--forge-field-disabled-backgroundThe background of the field when disabled.
Methods
NameReturnsDescription
floatLabelWithoutAnimation(value)voidFloats the label immediately. Only applies when the label is inset.

Labeling

If you’re not using a <label> element, provide an aria-label or aria-labelledby attribute on the <input> directly.

Loading Forge chat…