Start here
  • InstallationAdd Nelumbo to a shadcn project
  • ThemingBrand accent, neutrals, dynamic color
  • Biology componentsSequences, maps, plates and trees
  • katalyx.bio

    Form

    react-hook-form wiring for Nelumbo, with the same parts as shadcn's Form. Nelumbo's text fields keep one floating label, errors open with a spring and are announced, and a failed submit shakes what needs fixing.

      Install

      npx shadcn@latest add @nelumbo/form @nelumbo/label

      Sign-up form

      Press Create account with nothing filled in: every problem shows at once, the invalid fields shake once and the first one takes focus. Fix a field and its message closes. Validation is a zod schema; the button shows its loading state while the (pretend) request runs.

      We send the receipt here.

      8 characters, missingA number, missingA capital letter, missing

      MM/DD/YYYY

      0 / 200

      Optional. Shown on your profile, 160 characters at most.

      How many people will use the workspace. You can change it later.

      Email me when something new ships.

      One label, not two

      Input, Textarea, Select, Combobox, Date Picker and Time Picker draw their own floating label. Inside a FormItem the FormLabel text feeds that label instead of being drawn a second time, so shadcn forms port over without doubled labels. A FormLabel next to Checkbox, Switch, Radio Group or Slider is a normal label.

      <FormItem>  <FormLabel>Email</FormLabel>                 {/* becomes the field's floating label */}  <FormControl><Input type="email" {...field} /></FormControl>  <FormDescription>We send the receipt here.</FormDescription>  <FormMessage /></FormItem>​{/* keep a separate label above a field: */}<FormItem field={false}>...</FormItem>{/* the control is a Nelumbo field inside your own component: */}<FormItem field>...</FormItem>

      Accessibility

      FormControl gives the control its id, aria-invalid and an aria-describedby that lists the description and, while there is an error, the message. FormMessage is a polite live region, so a screen reader reads the error as it opens. A radio group is named through aria-labelledby and a slider through aria-label. Fields that expose a ref get focus from react-hook-form after a failed submit; the date and time pickers are focused by Nelumbo.

      <input id="…-form-item" aria-invalid="true" aria-describedby="…-form-item-description …-form-item-message"><div id="…-form-item-message" aria-live="polite">Enter your email.</div>

      Label

      The plain label for controls that have no floating label of their own. It follows its control: put it after a peer control and it dims when that control is disabled and turns red when it is invalid.

      With a checkbox, switch and radio

      Disabled and invalid, from the control

      Usage

      import { Form, FormField, FormItem, FormLabel, FormControl, FormDescription, FormMessage } from "@/components/ui/form"import { Label } from "@/components/ui/label"​const form = useForm<z.infer<typeof schema>>({ resolver: zodResolver(schema) })​<Form {...form}>  <form onSubmit={form.handleSubmit(onSubmit)} noValidate>    <FormField control={form.control} name="role" render={({ field }) => (      <FormItem>        <FormLabel>Role</FormLabel>        <Select value={field.value} onValueChange={field.onChange}>          <FormControl><SelectTrigger ref={field.ref}><SelectValue /></SelectTrigger></FormControl>          <SelectContent>...</SelectContent>        </Select>        <FormMessage />      </FormItem>    )} />    <Button type="submit" loading={form.formState.isSubmitting}>Save</Button>  </form></Form>

      Props

      PropTypeDefaultEverything else matches shadcn's Form
      FormItem fieldbooleanautotrue: treat the control as a Nelumbo field; false: keep a separate FormLabel
      FormLabelLabel propsHidden when a Nelumbo field shows its text as the floating label
      FormControlSlot propsAdds id, aria-invalid, aria-describedby (and aria-labelledby or aria-label where needed)
      FormMessagediv propsError text or children. Always mounted, polite live region, spring open and close
      FormDescriptionp propsHelp text, linked through aria-describedby
      LabelRadix Label propstype-label-lg; follows peer disabled and aria-invalid, group data-disabled, data-error