# Settings form with validation

> Settings form with validation

A shadcn/ui block from the [@reui](https://reui.io) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/reui/c-field-7).

- Page, with a live preview: https://shadcn.exchange/r/reui/c-field-7
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/reui/c-field-7-light-585cd2853194d98e.png
- Registry item: https://reui.io/r/new-york-v4/c-field-7.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://reui.io/r/new-york-v4/c-field-7.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `button`, `checkbox`, `field`, `input`, `switch`, `textarea`

## Files

### `c-field-7.tsx`

```tsx
import { Button } from "@/components/ui/button"
import { Checkbox } from "@/components/ui/checkbox"
import {
  Field,
  FieldContent,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLabel,
  FieldSeparator,
  FieldTitle,
} from "@/components/ui/field"
import { Input } from "@/components/ui/input"
import { Switch } from "@/components/ui/switch"
import { Textarea } from "@/components/ui/textarea"

export function Pattern() {
  return (
    <div className="mx-auto w-full max-w-xs">
      <FieldGroup>
        <Field>
          <FieldLabel htmlFor="settings-name">
            Display Name <span className="text-destructive">*</span>
          </FieldLabel>
          <Input id="settings-name" defaultValue="Alex Johnson" />
          <FieldDescription>This is your public display name.</FieldDescription>
        </Field>
        <Field data-invalid>
          <FieldLabel htmlFor="settings-slug">URL Slug</FieldLabel>
          <Input id="settings-slug" defaultValue="alex johnson" />
          <FieldError>
            Slug can only contain lowercase letters, numbers, and hyphens.
          </FieldError>
        </Field>
        <Field>
          <div className="flex items-center justify-between">
            <FieldLabel htmlFor="settings-bio">Bio</FieldLabel>
            <span className="text-muted-foreground text-xs">24/160</span>
          </div>
          <Textarea
            id="settings-bio"
            defaultValue="Software engineer & open source contributor."
            className="min-h-[80px]"
          />
          <FieldDescription>
            Brief description for your profile.
          </FieldDescription>
        </Field>
        <FieldSeparator />
        <Field orientation="horizontal">
          <FieldContent>
            <FieldTitle>Email Notifications</FieldTitle>
            <FieldDescription>
              Receive emails about account activity.
            </FieldDescription>
          </FieldContent>
          <Switch id="settings-email-notif" defaultChecked />
        </Field>
        <Field orientation="horizontal">
          <FieldContent>
            <FieldTitle>Marketing Emails</FieldTitle>
            <FieldDescription>
              Receive emails about new features and tips.
            </FieldDescription>
          </FieldContent>
          <Switch id="settings-marketing" />
        </Field>
        <FieldSeparator />
        <Field orientation="horizontal">
          <Checkbox id="settings-terms" />
          <FieldContent>
            <FieldTitle>Terms of Service</FieldTitle>
            <FieldDescription>
              I agree to the <a href="#">Terms of Service</a> and{" "}
              <a href="#">Privacy Policy</a>.
            </FieldDescription>
          </FieldContent>
        </Field>
        <Button className="w-full">Save Changes</Button>
      </FieldGroup>
    </div>
  )
}
```
