• CMSnpm version

    • Overview
    • ContentBuilder
    • InviteUserForm
    • LoginForm
    • RenewPasswordForm
    • WysiwygInput
  • UInpm version

    • Overview
    • Accordion
    • AlertBubble
    • AnnouncementBar
    • Avatar
    • AvatarFileInput
    • Badge
    • Button
    • ButtonGroup
    • ButtonList
    • Calendar
    • Checkbox
    • CheckboxButton
    • CheckboxInput
    • CheckboxList
    • Chip
    • ColorRadio
    • ColorRadioGroup
    • Combobox
    • DatePicker
    • DatePickerInput
    • DateRangePicker
    • DateRangePickerInput
    • DatetimePicker
    • DatetimePickerInput
    • Dialog
    • Dropdown
    • Dropzone
    • ErrorMessage
    • FileInput
    • FlashMessages
    • FormComponent
    • Icon
    • IconButton
    • ImageGallery
    • InfoBox
    • Input
    • Label
    • Layout
    • Lightbox
    • ListItem
    • Loader
    • Lozenge
    • Menu
    • Message
    • Modal
    • ✅ ModalDialog
    • ✅ ModalHeader
    • MultiCombobox
    • MultiSelect
    • Pagination
    • Paper
    • Popover
    • Radio
    • RadioGroup
    • RasterImage
    • Select
    • Switch
    • ✅ Tabs
    • TextInput
    • TextLink
    • Textarea
    • TimePicker
    • TimePickerInput
    • Toggle
    • Tooltip
    • Typography
  • Formnpm version

    • Overview
    • AvatarFileInput
    • CheckboxButton
    • CheckboxInput
    • CheckboxList
    • ColorRadioGroup
    • Combobox
    • DatePickerInput
    • DateRangePickerInput
    • DatetimePickerInput
    • Dropzone
    • FileInput
    • Form
    • FormRenderer
    • GpsInput
    • MoneyInput
    • MultiCombobox
    • MultiSelect
    • NumberInput
    • PasswordInput
    • RadioGroup
    • Select
    • TextInput
    • Textarea
    • TimePickerInput
    • Toggle
  • DataGridnpm version

    • Overview
    • DataGrid
    • DataGridCustomExample
    • ExportButton
    • FilterList
    • Filters
    • FiltersButton
    • FulltextInput
    • HiddenColumns
    • HiddenColumnsButton
    • Pagination
    • RowCounts
    • RowsPerPageSelect
    • SelectedRowsToolbar
    • TableV2
    • ToolbarControl
    • ToolbarCustoms
    • ToolbarTabs
  • Wysiwygnpm version

    • Overview
  • Resizernpm version

    • Overview
  • Routernpm version

    • Overview
  • Corenpm version

    • Overview
  • Core-Reactnpm version

    • Overview
  • DnDnpm version

    • Overview
  • Stylesnpm version

    • Overview
  • Localizenpm version

    • Overview
  • Analyticsnpm version

    • Overview
  • Datepickernpm version

    • Overview
  • Icons-generatornpm version

    • Overview
  • Smart-addressnpm version

    • Overview
  • E2Enpm version

    • Overview
  • E2E-Playwrightnpm version

    • Overview
View source on GitLab

FormComponent

Field layout wrapper: renders a Label above a control, plus an optional helper/error line below it.

When to use

Use FormComponent to give any control the standard label + helper/error layout. It is presentational only — it does not register a field, hold a value, or wire up react-hook-form. The @uxf/ui field components (text-input, textarea, file-input, combobox, multi-select, …) render it internally; reach for it directly when building a custom labelled field.

There is no @uxf/form/form-component twin.

Usage

import { FormComponent } from "@uxf/ui/form-component";

// label + helper text
<FormComponent helperText="We'll never share it." inputId="email" label="Email" name="email">
    <input id="email" />
</FormComponent>

// error state: errorId marks the helper text invalid
<FormComponent errorId="email--error" helperText="Required" inputId="email" isRequired label="Email" name="email">
    <input id="email" />
</FormComponent>

The wrapped control's id should match inputId so the label's htmlFor targets it.

Props

PropTypeDefaultDescription
inputIdstring—Required. htmlFor of the label; match the wrapped control's id.
namestring—Required. Field name; rendered as data-name on the root.
labelReactNode—Label content.
childrenReactElement—The control to wrap.
helperTextReactNode—Helper or error text shown below the control (only rendered when set).
errorIdstring—When set, renders the helper text with the invalid style and gives it this id, so the control can reference it (e.g. aria-describedby).
isRequiredbooleanfalseMarks the label as required.
hiddenLabelbooleanfalseVisually hides the label (still accessible).
formstring—Associates the label with a form by id.
data-componentstring—Sets data-component on the root.
classNamestring—Extra class on the root <div>.

FormComponent forwards its ref to the root HTMLDivElement.

Variants & states

  • Invalid: set errorId together with helperText — the helper line gets the is-invalid class (error color).
  • Required: set isRequired to mark the label.
  • Hidden label: set hiddenLabel to hide the label visually while keeping it for assistive tech.

Requirements

Import the component stylesheet and the label stylesheet once in your global CSS:

@import url("@uxf/ui/css/form-component.css");
@import url("@uxf/ui/css/label.css");

Also requires the global @uxf/ui token layer, set up once per app — see @uxf/ui setup.

Default
Open in new tab