Search the documentation

Type to search page titles, component names and descriptions.

    Data Entry

    Field

    One labelled control with help and error, for any input type.

    import { Field } from 'faifo-design'

    Field renders a label, a control, help text and an error in one frame, and dispatches on type to the right control. The label always stacks above the control; help and error sit below it on the label's start edge.

    #When to use

    • Use Field when a form is described as data, as RecordForm does. Use the typed components (TextField, Select, DatePicker…) when composing JSX directly.
    • Size a control by its value with width: xs for a few characters, sm for an amount or a date, md for a short choice. A name or a note fills its column.
    • Pass the error from the server. The field shows it, marks the control invalid and keeps the value.

    #Examples

    Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.

    #Field

    Text, select, checkbox and error states without application-owned markup.

    A tenant belongs to exactly one deployment.
    Use lowercase letters, numbers and hyphens only.
    New orders can be assigned to this company.
    Show codeHide code
    import { Field, Grid, Surface } from 'faifo-design'
    
    export const Example = () => (
      <Surface
        body={
          <Grid
            columns={2}
            items={[
              <Field
                id="company-name"
                name="company"
                label="Company name"
                value="Faifo Trading"
                required
              />,
              <Field
                id="deployment"
                name="deployment"
                label="Deployment"
                type="select"
                layout="inline"
                value="commerce"
                options={[
                  { value: 'commerce', label: 'Commerce' },
                  { value: 'cosmetic', label: 'Cosmetic' },
                  { value: 'hospitality', label: 'Hospitality' },
                ]}
                help="A tenant belongs to exactly one deployment."
              />,
              <Field
                id="database-key"
                name="databaseKey"
                label="Database key"
                value="Invalid Key"
                error="Use lowercase letters, numbers and hyphens only."
              />,
              <Field
                id="active"
                name="active"
                label="Active for new orders"
                type="checkbox"
                value
                help="New orders can be assigned to this company."
              />,
            ]}
          />
        }
      />
    )

    #Field with a command

    A short entry keeps a compact width with its command right after it; Enter runs the command.

    The tag is chosen for this batch at once.
    This code ended on 31 March.
    Show codeHide code
    import { Button, Field, FormGrid, Surface } from 'faifo-design'
    
    export const Example = () => (
      <Surface
        body={
          <FormGrid
            items={[
              <Field
                id="catalogue-new-tag"
                name="newTag"
                label="New tag"
                maxLength={40}
                span="full"
                help="The tag is chosen for this batch at once."
                action={<Button label="Add" type="submit" variant="secondary" />}
              />,
              <Field
                id="catalogue-coupon"
                name="coupon"
                label="Coupon"
                value="SPRING"
                span="full"
                error="This code ended on 31 March."
                action={<Button label="Apply" type="submit" variant="secondary" />}
              />,
            ]}
          />
        }
      />
    )

    #Field width by value

    A control is as wide as its value needs: xs for a few characters, sm for an amount, a date or a reference, md for a short choice; a name or a note fills its column.

    VND
    In months.
    Show codeHide code
    import { Field, FormGrid, MoneyField, Surface } from 'faifo-design'
    
    export const Example = () => (
      <Surface
        body={
          <FormGrid
            items={[
              <Field
                id="catalogue-width-name"
                name="name"
                label="Product name"
                value="Serum B5 repair"
              />,
              <Field id="catalogue-width-code" name="code" label="Reference" value="LX-01A" width="sm" />,
              <MoneyField
                id="catalogue-width-price"
                name="price"
                label="Sales price"
                value="289000"
                currency="VND"
                precision={0}
                width="sm"
              />,
              <Field
                id="catalogue-width-unit"
                name="unit"
                label="Unit"
                type="select"
                value="bottle"
                options={[
                  { value: 'bottle', label: 'Bottle' },
                  { value: 'box', label: 'Box' },
                ]}
                width="md"
              />,
              <Field
                id="catalogue-width-shelf"
                name="shelfLife"
                label="Shelf life"
                type="number"
                value="36"
                help="In months."
                width="xs"
              />,
            ]}
          />
        }
      />
    )

    #Operational fields

    Numeric constraints, dates, options and nested validation use the same field contract.

    Settings

    Assigned when the account was created.
    Billing frequency
    Notifications
    Branches
    Delivery address
    Enter a street address.
    Check the delivery address.
    Show codeHide code
    import { RecordForm, Surface } from 'faifo-design'
    
    export const Example = () => (
      <Surface
        title="Settings"
        body={
          <RecordForm
            action="#advanced-fields"
            submitLabel="Save settings"
            fields={[
              {
                id: 'settings-reference',
                name: 'reference',
                label: 'Reference',
                value: 'CUS-0042',
                readOnly: true,
                help: 'Assigned when the account was created.',
              },
              {
                id: 'settings-locked',
                name: 'locked',
                label: 'External reference',
                value: 'Pending verification',
                disabled: true,
              },
              {
                id: 'settings-limit',
                name: 'limit',
                label: 'Credit limit',
                type: 'decimal',
                value: 80000000,
                min: 0,
                step: '1000',
              },
              {
                id: 'settings-date',
                name: 'date',
                label: 'Effective date',
                type: 'date',
                value: '2026-09-08',
              },
              { id: 'settings-time', name: 'time', label: 'Delivery time', type: 'time', value: '09:00' },
              {
                id: 'settings-color',
                name: 'color',
                label: 'Calendar colour',
                type: 'color',
                value: '#1746ff',
              },
              {
                id: 'settings-billing',
                name: 'billing',
                label: 'Billing frequency',
                type: 'radio',
                value: 'monthly',
                required: true,
                options: [
                  { value: 'monthly', label: 'Monthly' },
                  { value: 'quarterly', label: 'Quarterly' },
                ],
              },
              {
                id: 'settings-channels',
                name: 'channels',
                label: 'Notifications',
                type: 'checkbox-group',
                options: [
                  { value: 'email', label: 'Email', checked: true },
                  { value: 'sms', label: 'SMS' },
                ],
              },
              {
                id: 'settings-branches',
                name: 'branches',
                label: 'Branches',
                type: 'checkbox-group',
                optionsOrientation: 'vertical',
                span: 'full',
                options: [
                  { value: 'district-1', label: 'District 1 · Head office', checked: true },
                  { value: 'thao-dien', label: 'Thao Dien', checked: true },
                  { value: 'cau-giay', label: 'Cau Giay · North' },
                ],
              },
              {
                id: 'settings-address',
                name: 'address',
                label: 'Delivery address',
                error: 'Check the delivery address.',
                fields: [
                  {
                    id: 'settings-street',
                    name: 'street',
                    label: 'Street',
                    value: '',
                    required: true,
                    error: 'Enter a street address.',
                    span: 'full',
                  },
                  {
                    id: 'settings-city',
                    name: 'city',
                    label: 'City',
                    value: 'Hồ Chí Minh',
                    autocomplete: 'address-level2',
                  },
                ],
              },
            ]}
          />
        }
      />
    )

    #Contract

    #A short entry with its command

    A single-line entry that is acted on by itself, such as adding a tag or applying a code, passes the command as action (usually a Button). The field renders field-row in its control column: the entry keeps a compact width (at most 20rem) and the command follows it at the action gap, so it never drifts to the far edge of a wide form. The label, help and error stay the field's own. The shared runtime makes Enter in the entry run that command instead of the form's first submit button, and skips it while an input method is composing. Without the runtime a submit Button still submits the form, so the host must accept the entry on that submission too.

    <Field id="new-tag" name="newTag" label="New tag" maxLength={40}
      action={<Button label="Add" type="submit" variant="secondary" />} />

    Use it for text entries only; a select or a choice group has no command beside it.

    #A control as wide as its value

    A control fills its column by default, which suits a name, an address or a note. A value of a few characters in a wide form reads lost in an empty box, so the field states how long its value is with width; the control keeps to the start of its column at that width and never grows past the column. Label, help and error keep their own tracks, so a short control still lines up with the fields above it. Field, TextField, NumberField, MoneyField, DatePicker and Combobox accept it.

    widthControlFor
    xs7rema rate, a percentage, a count of days or months
    sm11reman amount, a quantity, a date, a reference, a barcode, a phone number
    md18rema short choice: a unit, a group, a warehouse, a tax
    nonethe columna name, a long choice (an account), an address, a description
    <MoneyField id="price" name="price" label="Sales price" currency="VND" width="sm" />
    <Field id="shelf-life" name="shelfLife" label="Shelf life" type="number" width="xs" />

    Choose it from the value's length, not from the space left on the row. Specimen: field-width.

    In an Inline row (a toolbar's search, a quantity between a minus and a plus button) there is no column to fill, so a sized field starts at its width and shrinks only when the row runs out of room, never below 4rem. Without width a field in a row takes what its control measures. A row whose fields all hide their label (labelHidden) is not a container for the label rule, so a row sized by its content, such as a quantity stepper at the end of a card, keeps its width.

    #API

    Generated from the package source. A property without a description has none in the source yet.

    #FieldComponent

    Compatibility dispatcher: all controls share FieldFrame and their own control contract.

    PropertyDescriptionTypeDefault
    readOnlyWhenIn a RecordForm, lock/hide this field while the named peer has a non-empty value.string–
    hiddenWhen–string–
    fieldsNested fields for a collapsible group inside a larger record form.readonly FieldProps[]–
    open–boolean–
    onInputNative input events, also emitted by progressively enhanced controls.(event: Event) => void–
    onChange–(event: Event) => void–
    onBlur–(event: Event) => void–
    idrequired–string–
    namerequired–string–
    labelrequired–string–
    localeForward the host locale to date/time controls; omitted keeps their existing default.'vi' | 'en' | 'ja'–
    sizeOpt-in matched input/action height: 36px desktop, 44px mobile.'default' | 'large'–
    controlA trusted, progressively enhanced control such as a relation selector.JSXChild–
    layoutKeep an enhanced control and its label in one row at narrow widths.'inline'–
    actionA command right after a short single-line entry, such as an Add or Apply Button. The entry keeps a compact width and Enter in it runs the command instead of the form's first submit button.JSXChild–
    type–| 'text' | 'search' | 'url' | 'email' | 'tel' | 'number' | 'decimal' | 'password' | 'time' | 'color' | 'date' | 'datetime-local' | 'month' | 'week' | 'select' | 'textarea' | 'checkbox' | 'checkbox-group' | 'radio' /** An on/off choice drawn as a switch (`role="switch"`); it posts `value` (default `1`) when on. */ | 'switch''text'
    value–string | number | boolean | null–
    checked–boolean | 'indeterminate'–
    submitValueLegacy checkbox value used checked state; submitValue opts into separate form data.string–
    prefix–JSXChild–
    suffix–JSXChild–
    clearable–boolean–
    clearLabel–string–
    inputMode–'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url'–
    numberLocaleA number or decimal typed and shown as this language writes it ("1.800.000" in vi). The control becomes a text input; the design-system runtime submits the plain decimal ("1800000").string–
    align–'start' | 'center' | 'end'–
    rows–number–
    resize–'vertical' | 'none'–
    maxLength–number–
    minLength–number–
    pattern–string–
    labelHiddenEmbedded controls share the frame of a compound field.boolean–
    selectionHiddenKeep the selected value accessible while showing only the select chevron.boolean–
    appearance–'default' | 'embedded'–
    placeholder–string | null–
    required–boolean–
    disabled–boolean–
    readOnly–boolean–
    min–string | number–
    max–string | number–
    help–string | null–
    error–string | null–
    options–readonly FieldOption[]–
    optionsOrientationHow checkbox-group and radio options flow. horizontal (default) wraps them on a line; vertical lists one option per line under the shared label, for choices whose labels should scan as a column.'horizontal' | 'vertical'–
    span–'half' | 'full'–
    widthHow long the value is: the control is no wider than it needs (FieldFrame).'xs' | 'sm' | 'md'–
    step–string | null–
    autocomplete–string | null–

    #Types

    #FieldOption

    PropertyDescriptionTypeDefault
    valuerequired–string–
    labelrequired–string–
    sizeOpt-in matched input/action height: 36px desktop, 44px mobile.'default' | 'large'–
    name–string–
    checked–boolean–
    disabled–boolean–

    #FieldProps

    The properties of Field, listed above.

    #Hooks

    The data-ui values these components render. Select them in tests and behaviour; their look belongs to the design system. See Contract.

    • field
    • field-label
    • field-required
    • field-control
    • field-input
    • field-affix
    • field-clear
    • field-options
    • field-option
    • field-option-input
    • field-help
    • field-error