Text3 checks

FormTextarea

Multi-line text with a character counter.

Example

0 / 280

Installation
bunx --bun shadcn@latest add @fieldkit/form-textarea

Needs the @fieldkit registry. Add it once

Usage
  1. 1

    Add the field to your schema

    schema.ts
    import { z } from "zod"import { textField } from "@/lib/field-schemas"
    export const schema = z.object({  message: textField({ min: 10, max: 1000 }),})
  2. 2

    Render it inside a Form

    The name prop matches the schema key.

    example-form.tsx
    import { Form } from "@/components/form/form"import { FormTextarea } from "@/components/form/form-textarea"import { FormSubmit } from "@/components/form/form-submit"import { FieldGroup } from "@/components/ui/field"import { schema } from "./schema"
    export function ExampleForm() {  return (    <Form      schema={schema}      defaultValues={{ message: "" }}      onSubmit={save}    >      <FieldGroup>        <FormTextarea name="message" rows={4} />        <FormSubmit>Save</FormSubmit>      </FieldGroup>    </Form>  )}
Checks
Lengthmin, maxEnter at least 10 characters
Live countermaxNone
Trims spacesdefaultNone
Best practices
  • Announce the counter only near the limit
Try these values
Terminal
textField({ min: 10, max: 280 })
InputResultOutput
"Call me after 5 pm."Valid"Call me after 5 pm."
"Hi"Invalid
Enter at least 10 characters
""Invalid
Enter at least 10 characters
API reference

FormTextarea

rowsnumberVisible lines. The counter shows when the schema sets max.

Field frame

namestringKey in the schema. Also picks the preset label and autocomplete.
labelReact.ReactNodeOverrides the preset label. Pass null to hide it.
descriptionReact.ReactNodeHint under the control.
requiredbooleanOverrides the asterisk read from the schema.
fieldPropsFormFieldPropsProps for the wrapping Field, such as className.

Search docs

Find a component, input or example