Skip to main content

Common Examples

The FieldLabel component is typically used internally by form components, but can also be used directly when building custom form fields.

You might not need FieldLabel

The FieldLabel component is used to display a label for a form component. Please look to our Form Patterns page for guidance on how to use labels for your use case.However, many form components in Anvil2 already have FieldLabel built into them, such as Checkbox.Group, DateFieldYearless, DaysOfTheWeek, NumberField, and ProgressBar. For all of these components, you do NOT need to use the FieldLabel component, just use the existing props such as label on your Anvil2 form components.

Required Fields

Add a visual required indicator (red asterisk) and screen reader announcement.

With More Info Tooltip

Add additional context with a help tooltip.

Polymorphic Element

The FieldLabel component can render as different HTML elements using the el prop. Choose the element based on whether you are labeling a single control or a group of related controls.Use el="legend" when building a custom fieldset (for example a group of native inputs or third-party controls that share one accessible name). Prefer the built-in legend prop on Checkbox.Group and Radio.Group instead of composing FieldLabel yourself for those components.

Controlled Tooltip State

Control the tooltip’s open state programmatically.

Markdown in labels

The children prop supports limited inline Markdown: bold (**text**), italic (*text*), bold and italic (***text***), highlight (==text==), and code (`text`). This markdown is stripped from the accessible text so screen readers receive a plain string.

React Accessibility

  • Uses semantic HTML (<label> by default, or <legend> when el="legend")
  • Required fields include both a visual asterisk and “Required” text for screen readers
  • The moreInfo content is available to screen readers via SrOnly
  • Associates with a single control via htmlFor when el="label"; as a <legend>, associates with the enclosing <fieldset> group instead
For more guidance on form field labels and context, see input field context association best practices.
Last modified on October 12, 2026