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.
import { ChibiInput } from '@chibi-ui/react/input';
<ChibiInput
label="Email"
type="email"
labelVariant="floating"
description="We only send cute newsletters."
leftIcon={<MailIcon />}
/>Import
import {
ChibiInput,
} from '@chibi-ui/react/input';Examples
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
| Prop | Type | Default | Description |
|---|---|---|---|
| label | ReactNode | โ | Visible label, associated with the control. |
| description | ReactNode | โ | Helper text, linked via aria-describedby. |
| error | ReactNode | โ | Error message (e.g. errors.x?.message). Any truthy value sets aria-invalid; true marks invalid without a message. |
| containerClassName | string | โ | Class for the wrapper holding label, control and messages. |
| labelVariant | 'static' | 'floating' | 'static' | Label placement. |
| size | 'sm' | 'md' | 'lg' | 'md' | Control height. |
| leftIcon / rightIcon | ReactNode | โ | Decorative adornments. |
| โฆ | ComponentProps<'input'> | โ | All native input props, plus ref. |