XiodUI
HomeDocs
OverviewComponentsThemes & ColorsChangelog
⌘ K

Components

  • Accordion
  • Agent Steps
    New
  • Alert
  • Alert Dialog
  • Aspect Ratio
    New
  • Autocomplete
  • Avatar
  • Badge
  • Breadcrumb
  • Button
    Updated
  • Button Group
    New
  • Button Split
    New
  • Calendar
    New
  • Card
  • Carousel
    New
  • Checkbox
  • Circular Progress
    New
  • Collapsible
  • Color Picker
    New
  • Combobox
  • Command
  • Context Menu
    New
  • Copy To Clipboard
    New
  • Corner Badge
    New
  • Dashboard Grid
    New
  • Date Picker
    New
  • Dialog
  • Dot Matrix
    New
  • Draggable
    New
  • Drawer
    New
  • Empty
  • Field
  • Fieldset
  • File Upload
    New
  • Form
  • Frame
  • Gauge
    New
  • Grid
    New
  • Group
  • Input
  • Input Group
  • Input OTP
    New
  • Input Payment
    New
  • Input Phone
    New
  • Input Sensitive
    New
  • Kbd
  • Kinetic Click
    New
  • Label
  • List Box
    New
  • Loader
  • Marker
    New
  • Menu
  • Menubar
  • Message
    New
  • Meter
  • Morphic Toast
    New
  • Navigation Menu
  • Number Field
  • Option Picker
    New
  • Orb
    New
  • Pagination
  • Popover
  • Preview Card
  • Progress
  • Radio
  • Resizable
    New
  • Ruler Picker
    New
  • Scroll Area
  • Scroll Bar
    New
  • Select
  • Separator
  • Sidebar
  • Skeleton
  • Slider
    Updated
  • Sortable
    New
  • Switch
    Updated
  • Table
  • Tabs
  • Text
    New
  • Textarea
  • Timeline
    New
  • Toast
  • Toggle
  • Toggle Group
  • Toolbar
  • Tooltip
    Updated
  • Waveform
    New
  • Wheel Picker
    New
/
/

Loading...

Preview Skeleton

Installation Skeleton

Usage Skeleton

API Reference Skeleton

Sponsors

Support the development of XiodUI and help us build the best component library on Earth.

+++
Sponsor on GitHub

Field

Previous: EmptyNext: Fieldset

A form field element.

Preview

Loading Preview...

Installation

bun add xiod-ui

Usage

Imports

1import {2  Field,3  FieldControl,4  FieldDescription,5  FieldError,6  FieldItem,7  FieldLabel,8  FieldValidity9} from "xiod-ui/field";

Anatomy

1<Field>2  <FieldDescription />3  <FieldLabel />4  <FieldItem />5  <FieldControl />6  <FieldError />7  <FieldValidity />8</Field>

API Reference

Detailed documentation of properties and options.

Field

PropTypeDefaultDescription
disabled
boolean
|undefined
falseWhether the component should ignore user interaction. Takes precedence over the `disabled` prop on the `<Field.Control>` component.
name
string
|undefined
-Identifies the field when a form is submitted. Takes precedence over the `name` prop on the `<Field.Control>` component.
validate
((value: unknown, formValues: Record<string, any>) => string
|void
|string[]
|Promise<string
|void
|string[]
|null>
|null)
|undefined
-A function for custom validation. Return a string or an array of strings with the error message(s) if the value is invalid. Returning nothing, `null`, an empty string, or an empty array means the value is valid. Asynchronous functions are supported, but they do not prevent form submission when using `validationMode="onSubmit"`.
validationMode
FormValidationMode
|undefined
'onSubmit'Determines when the field should be validated. This takes precedence over the `validationMode` prop on `<Form>`. - `onSubmit`: triggers validation when the form is submitted, and re-validates on change after submission. - `onBlur`: triggers validation when the control loses focus. - `onChange`: triggers validation on every change to the control value.
validationDebounceTime
number
|undefined
0How long to wait between `validate` callbacks if `validationMode="onChange"` is used. Specified in milliseconds.
invalid
boolean
|undefined
-Whether the field is invalid. Useful when the field state is controlled by an external library.
dirty
boolean
|undefined
-Whether the field's value has been changed from its initial value. Useful when the field state is controlled by an external library.
touched
boolean
|undefined
-Whether the field has been touched. Useful when the field state is controlled by an external library.
actionsRef
RefObject<FieldRootActions
|null>
|undefined
-A ref to imperative actions. - `validate`: Validates the field when called.
className
string
|((state: FieldRootState) => string
|undefined)
|undefined
-CSS class applied to the element, or a function that returns a class based on the component's state.
render
ReactElement<unknown, string
|JSXElementConstructor<any>>
|ComponentRenderFn<HTMLProps, FieldRootState>
|undefined
-Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
style
CSSProperties
|((state: FieldRootState) => CSSProperties
|undefined)
|undefined
-Style applied to the element, or a function that returns a style object based on the component's state.

FieldControl

PropTypeDefaultDescription
style
CSSProperties
|((state: FieldControlState) => CSSProperties
|undefined)
|undefined
-Style applied to the element, or a function that returns a style object based on the component's state.
className
string
|((state: FieldControlState) => string
|undefined)
|undefined
-CSS class applied to the element, or a function that returns a class based on the component's state.
defaultValue
string
|number
|readonly string[]
|undefined
-
render
ReactElement<unknown, string
|JSXElementConstructor<any>>
|ComponentRenderFn<HTMLProps, FieldControlState>
|undefined
-Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
onValueChange
((value: string, eventDetails: { reason: "none"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element
|undefined; }) => void)
|undefined
-Callback fired when the `value` changes. Use when controlled.

FieldDescription

PropTypeDefaultDescription
className
string
|((state: FieldDescriptionState) => string
|undefined)
|undefined
-CSS class applied to the element, or a function that returns a class based on the component's state.
render
ReactElement<unknown, string
|JSXElementConstructor<any>>
|ComponentRenderFn<HTMLProps, FieldDescriptionState>
|undefined
-Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
style
CSSProperties
|((state: FieldDescriptionState) => CSSProperties
|undefined)
|undefined
-Style applied to the element, or a function that returns a style object based on the component's state.

FieldError

PropTypeDefaultDescription
match
boolean
|keyof ValidityState
|undefined
-Determines whether to show the error message according to the field's [ValidityState](https://developer.mozilla.org/en-US/docs/Web/API/ValidityState). Specifying `true` will always show the error message, and lets external libraries control the visibility.
className
string
|((state: FieldErrorState) => string
|undefined)
|undefined
-CSS class applied to the element, or a function that returns a class based on the component's state.
render
ReactElement<unknown, string
|JSXElementConstructor<any>>
|ComponentRenderFn<HTMLProps, FieldErrorState>
|undefined
-Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
style
CSSProperties
|((state: FieldErrorState) => CSSProperties
|undefined)
|undefined
-Style applied to the element, or a function that returns a style object based on the component's state.

FieldItem

PropTypeDefaultDescription
disabled
boolean
|undefined
falseWhether the wrapped control should ignore user interaction. The `disabled` prop on `<Field.Root>` takes precedence over this.
className
string
|((state: FieldItemState) => string
|undefined)
|undefined
-CSS class applied to the element, or a function that returns a class based on the component's state.
render
ReactElement<unknown, string
|JSXElementConstructor<any>>
|ComponentRenderFn<HTMLProps, FieldItemState>
|undefined
-Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
style
CSSProperties
|((state: FieldItemState) => CSSProperties
|undefined)
|undefined
-Style applied to the element, or a function that returns a style object based on the component's state.

FieldLabel

PropTypeDefaultDescription
nativeLabel
boolean
|undefined
trueWhether the component renders a native `<label>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a label (for example, `<div>`). This is useful to avoid inheriting label behaviors on `<button>` controls (such as `<Select.Trigger>` and `<Combobox.Trigger>`), including avoiding `:hover` on the button when hovering the label, and preventing clicks on the label from firing on the button.
className
string
|((state: FieldLabelState) => string
|undefined)
|undefined
-CSS class applied to the element, or a function that returns a class based on the component's state.
render
ReactElement<unknown, string
|JSXElementConstructor<any>>
|ComponentRenderFn<HTMLProps, FieldLabelState>
|undefined
-Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
style
CSSProperties
|((state: FieldLabelState) => CSSProperties
|undefined)
|undefined
-Style applied to the element, or a function that returns a style object based on the component's state.

FieldValidity

PropTypeDefaultDescription
childrenReq
(state: FieldValidityState) => ReactNode
-A function that accepts the field validity state as an argument. ```jsx <Field.Validity> {(validity) => { return <div>...</div> }} </Field.Validity> ```
EmptyFieldset