C
Cassa UI

Input

Text input primitive from @cassa/ui-forms. Handles label, helper text, and error state. Label linked via useId(), errors announced via aria-invalid + aria-describedby.

Import

import { Input } from '@cassa/ui-forms'

Default

With helper text

Letters, numbers, and underscores only.

Error state

Please enter a valid email address.

Sizes

With React Hook Form

Use FormField for zero-boilerplate RHF integration:

import { useForm } from 'react-hook-form'
import { zodResolver } from '@hookform/resolvers/zod'
import { Input, FormField } from '@cassa/ui-forms'
import { z } from 'zod'

const schema = z.object({ email: z.string().email() })

export const MyForm = () => {
  const { control, handleSubmit } = useForm({
    resolver: zodResolver(schema),
  })

  return (
    <form onSubmit={handleSubmit(console.log)}>
      <FormField
        name="email"
        control={control}
        render={({ field, error }) => (
          <Input {...field} label="Email" type="email" error={error} />
        )}
      />
    </form>
  )
}

Props

PropTypeDefaultDescription
labelstringRenders an accessible <label> linked via useId().
helperTextstringShown below the input when there is no error.
errorstringSwitches border to error color, sets aria-invalid, and shows an error message.
size"sm" | "md" | "lg""md"Controls height and font size.
idstringOverrides the auto-generated ID from useId().
...propsOmit<InputHTMLAttributes, "size">All native input attributes. The native size attribute is omitted.