Skip to main content
LibreChat is joining ClickHouse to power the open-source Agentic Data Stack 🎉 Learn more
LibreChat

Input

Single-line text fields, with labels and validation states.

Input is the text field used in LibreChat's forms. Pair it with Label, and give every field an id from React's useId() so the label still points at the right field when the component renders more than once.

Default

import { useId } from 'react'
import { Input, Label } from '@librechat/client'

export default function InputDefault() {
  const id = useId()
  return (
    <div className="grid w-full max-w-sm gap-2">
      <Label htmlFor={id}>Display name</Label>
      <Input id={id} placeholder="Ada Lovelace" />
    </div>
  )
}

Invalid

Mark a field that failed validation with aria-invalid, and tie the message to it with aria-describedby. The field draws its border in the theme's destructive color.

import { useId } from 'react'
import { Input, Label } from '@librechat/client'

export default function InputInvalid() {
  const id = useId()
  return (
    <div className="grid w-full max-w-sm gap-2">
      <Label htmlFor={id}>Email</Label>
      <Input id={id} defaultValue="ada@" aria-invalid aria-describedby={`${id}-error`} />
      <span id={`${id}-error`} role="alert" className="text-text-destructive text-sm">
        Enter a complete email address.
      </span>
    </div>
  )
}

Props

Input accepts every native input attribute. The ones it styles:

PropTypeDescription
aria-invalidbooleanDraws the destructive border and tells assistive technology the value is invalid.
disabledbooleanDims the field and blocks editing.
placeholderstringExample text shown while the field is empty. It is not a label.

Accessibility

  • Every field needs a visible label: Label with htmlFor, or aria-labelledby.
  • Ids come from useId(), never a literal string.
  • Error text uses the text-text-destructive token and role="alert" so it is announced when it appears.

How is this guide?