Skip to content
ChibiUI

Component

Input

A text field with a static or floating label, helper text, error state and adornments. It works with react-hook-form register() out of the box.

Playground

We only send cute newsletters.

Generated code
import { ChibiInput } from '@chibi-ui/react/input';

<ChibiInput
  label="Email"
  type="email"
  labelVariant="floating"
  description="We only send cute newsletters."
  leftIcon={<MailIcon />}
/>

Import

TSX
import {
  ChibiInput,
} from '@chibi-ui/react/input';

Examples

react-hook-form + Zod
import { zodResolver } from '@hookform/resolvers/zod';
import { useForm } from 'react-hook-form';
import { z } from 'zod';
import { ChibiInput } from '@chibi-ui/react/input';

const schema = z.object({ email: z.email('Please enter a valid email') });

function Newsletter() {
  const { register, handleSubmit, formState: { errors } } = useForm({
    resolver: zodResolver(schema),
  });

  return (
    <form onSubmit={handleSubmit(subscribe)} noValidate>
      <ChibiInput
        label="Email"
        type="email"
        autoComplete="email"
        error={errors.email?.message}
        {...register('email')}
      />
    </form>
  );
}

Accessibility

  • The label is always a real <label> linked to the input. A floating label stays visible and is never a placeholder.
  • Description and error are linked with aria-describedby. Errors set aria-invalid and sit in a polite live region, so an error shown on blur is still announced.
  • Errors show an icon and text, not colour alone. The invalid border meets 3:1 non-text contrast.
  • The required attribute is set natively. The visual asterisk is aria-hidden.

API reference

ChibiInput

PropTypeDefaultDescription
labelReactNodeโ€”Visible label, associated with the control.
descriptionReactNodeโ€”Helper text, linked via aria-describedby.
errorReactNodeโ€”Error message (e.g. errors.x?.message). Any truthy value sets aria-invalid; true marks invalid without a message.
containerClassNamestringโ€”Class for the wrapper holding label, control and messages.
labelVariant'static' | 'floating''static'Label placement.
size'sm' | 'md' | 'lg''md'Control height.
leftIcon / rightIconReactNodeโ€”Decorative adornments.
โ€ฆComponentProps<'input'>โ€”All native input props, plus ref.