Form
Building forms with validation and accessible field markup.
Form — helpers de layout pour composer un formulaire avec labels, descriptions et messages d'erreur cohérents. Ne fait pas la validation (à faire côté serveur / côté client selon votre stack).
Structure : Form (wrapper) > FormItem (une ligne) > FormLabel + FormControl (wrapper du champ) + FormDescription (aide) + FormMessage (erreur ou hint).
Installation
$ bext ui add form
Copy and paste the following into src/components/ui/form.tsx.
Usage
Anatomy
<Form action="/submit" method="post">
<FormItem>
├── <FormLabel>Email</FormLabel>
├── <FormControl><Input /></FormControl>
├── <FormDescription>We'll never share it.</FormDescription>
└── <FormMessage>Invalid email format</FormMessage>
</FormItem>
</Form>API Reference
Form
| Prop | Type | Default | Description |
|---|---|---|---|
| action | string | — | undefined |
| method | "get" | "post" | — | undefined |
| children | ReactNode | — | undefined |
FormItem
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | Container flex-col gap-2. |
FormLabel
| Prop | Type | Default | Description |
|---|---|---|---|
| htmlFor | string | — | undefined |
| children | ReactNode | — | undefined |
FormControl
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | Wrapper direct du / |
FormDescription
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | text-sm text-muted-foreground. |
FormMessage
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | text-sm text-destructive quand une erreur est rendue. |
Accessibility
Chaque champ doit avoir un <label htmlFor="id"> qui pointe l'input. Les erreurs doivent porter aria-describedby pointant vers le FormMessage.
Edit this component live in the bext playground. The PRISM + signals version is the bext-native idiom — fine-grained reactivity, no virtual DOM.
On This Page