Form Wire
Integrations

shadcn/ui

Use Form Wire with shadcn/ui components

The @form-wire/shadcn package provides createShadcnMapper — a plug-and-play adapter that bridges your shadcn/ui components to Form Wire's mapper interface.

Installation

bun add @form-wire/shadcn

Usage

Pass your shadcn/ui components to createShadcnMapper and get back a FormWireMapper:

import { createShadcnMapper } from "@form-wire/shadcn";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { Checkbox } from "@/components/ui/checkbox";
import { Button } from "@/components/ui/button";
import { Label } from "@/components/ui/label";
import {
  Select,
  SelectTrigger,
  SelectValue,
  SelectContent,
  SelectItem,
} from "@/components/ui/select";
import {
  FormItem,
  FormLabel,
  FormControl,
  FormDescription,
  FormMessage,
} from "@/components/ui/form";

export const shadcnMapper = createShadcnMapper({
  Input,
  Textarea,
  Checkbox,
  Select,
  SelectTrigger,
  SelectValue,
  SelectContent,
  SelectItem,
  Button,
  Label,
  FormItem,
  FormLabel,
  FormControl,
  FormDescription,
  FormMessage,
});

Then use it with FormWireProvider:

<FormWireProvider mapper={shadcnMapper}>
  <Contact.Form action={submitContact} />
</FormWireProvider>

Required Components

Only Input is required — it renders text, email, number, date, and file inputs.

Optional Components

ComponentAffectsFallback
TextareaMultiline string fieldsUses Input
CheckboxBoolean fieldsNative <input type="checkbox">
Select + sub-componentsSelect fieldsNative <select>
ButtonSubmit buttonNative <button>
LabelField labelsNative <label>
FormItem + FormLabel + FormControl + FormDescription + FormMessageField wrapper layoutBasic div layout
AlertForm messagesNative <p>
SkeletonLoading statesHidden (no display)
FieldsetGroup wrapperNative <fieldset>

How It Works

  • createShadcnMapper returns a FormWireMapper that maps Form Wire's field props to shadcn/ui component props
  • For Radix Select: synthesizes a change event from onValueChange to bridge to Form Wire's onChange
  • For Checkbox: uses onCheckedChange with boolean values
  • The FormItem pattern uses shadcn's form layout (label, control, description, error message)

Partial Setup

You don't need all components. Only pass what you have:

const mapper = createShadcnMapper({
  Input,
  Button,
  Label,
});

Missing components fall back to native HTML elements. Mapper keys that have no corresponding component are simply omitted (Form Wire uses its own fallbacks).

On this page