Park UI Logo
GitHub
Components
Field

Field

A component that groups a label, input, helper, and error text, ensuring accessibility.

Some additional Info
import { Field } from '~/components/ui/field'

export const Demo = (props: Field.RootProps) => {
  return (
    <Field.Root {...props}>
      <Field.Label>Label</Field.Label>
      <Field.Input placeholder="Placeholder" />
      <Field.HelperText>Some additional Info</Field.HelperText>
    </Field.Root>
  )
}

Usage

import { Field } from '~/components/ui/field'

Examples

Invalid

Use the invalid prop to indicate that the field is invalid.

Please enter a valid email address
<Field.Root invalid>
  <Field.Label>Email</Field.Label>
  <Field.Input asChild>
    <Input type="email" />
  </Field.Input>
  <Field.ErrorText>Please enter a valid email address</Field.ErrorText>
</Field.Root>

Disabled

Use the disabled prop to disable the field.

<Field.Root disabled>
  <Field.Label>Label</Field.Label>
  <Field.Input asChild>
    <Input type="email" />
  </Field.Input>
</Field.Root>

Textarea

You can use the Field.Textarea component to render a textarea.

Tell us about yourself
<Field.Root>
    <Field.Label>Description</Field.Label>
    <Field.Textarea asChild>
        <Textarea />
    </Field.Input>
    <Field.HelperText>Tell us about yourself</Field.HelperText>
</Field.Root>

Installation

npx @park-ui/cli components add field