Y2K UI

Form

A form wrapper with native HTML5 validation, powered by Radix.

form-demo.app
Email is required

Installation

terminal.sh
npx y2kui@latest add form

Usage

import {
  Form,
  FormField,
  FormLabel,
  FormControl,
  FormMessage,
  FormSubmit,
} from "@/components/ui/form";

<Form>
  <FormField name="email" serverInvalid>
    <FormLabel>Email</FormLabel>
    <FormControl>
      <Input type="email" required />
    </FormControl>
    <FormMessage>Please enter a valid email.</FormMessage>
  </FormField>
  <FormSubmit asChild>
    <Button type="submit">Submit</Button>
  </FormSubmit>
</Form>;

Props

PropTypeDefaultDescription
FormField{ name: string }Wraps a single form field.
FormLabelReactNodeStyled label (uses Label component).
FormControlReactNodeWraps the input as a child.
FormMessagestringValidation error message.
FormSubmitReactNodeSubmit button.

On this page