Additional Field
better-auth-ui/additional-fieldFreeComponent
Renders a configured additional user field on the sign-up form and user profile, with support for string, number, boolean, date, datetime, select, combobox, slider, and hidden types.
Live preview
live · rendered by the registry
Rendered by better-auth-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://better-auth-ui.com/r/additional-field.jsonSource
1"use client"23import {4 type AdditionalField as AdditionalFieldConfig,5 resolveInputType6} from "@better-auth-ui/core"7import { useAuth } from "@better-auth-ui/react"8import { format } from "date-fns"9import { CalendarIcon, Check, ChevronDownIcon, Copy } from "lucide-react"10import { type ComponentType, useRef, useState } from "react"11import { toast } from "sonner"1213import { buttonVariants } from "@/components/ui/button"14import { Calendar } from "@/components/ui/calendar"15import { Checkbox } from "@/components/ui/checkbox"16import {17 Combobox,18 ComboboxContent,19 ComboboxEmpty,20 ComboboxInput,21 ComboboxItem,22 ComboboxList23} from "@/components/ui/combobox"24import {25 Field,26 FieldContent,27 FieldError,28 FieldLabel29} from "@/components/ui/field"30import { Input } from "@/components/ui/input"31import {32 InputGroup,33 InputGroupAddon,34 InputGroupButton,35 InputGroupInput36} from "@/components/ui/input-group"37import {38 Popover,39 PopoverContent,40 PopoverTrigger41} from "@/components/ui/popover"42import {43 Select,44 SelectContent,45 SelectItem,46 SelectTrigger,47 SelectValue48} from "@/components/ui/select"49import { Slider } from "@/components/ui/slider"50import { Switch } from "@/components/ui/switch"51import { Textarea } from "@/components/ui/textarea"52import { cn } from "@/lib/utils"5354export type AdditionalFieldProps = {55 name: string56 field: AdditionalFieldConfig57 isPending?: boolean58 /** Complete suffix appended to labels for fields that are not required. */59 optionalLabel?: string60}6162/** Convert a `defaultValue` into a `Date` for the calendar. */63function toDate(value: unknown): Date | undefined {64 if (value instanceof Date) return value65 if (typeof value === "string") {66 const parsed = new Date(value)67 return Number.isNaN(parsed.getTime()) ? undefined : parsed68 }69 return undefined70}7172/** Format a Date as `HH:mm:ss` for an `<input type="time">`. */73function formatTime(date: Date) {74 const pad = (n: number) => n.toString().padStart(2, "0")75 return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`76}7778/**79 * Icon-only copy button used as an `InputGroupAddon`. `getValue` is invoked80 * lazily on click so the button copies the input's *live* value rather than a81 * stale snapshot — important when paired with editable inputs.82 */83function CopyButton({84 getValue,85 isDisabled86}: {87 getValue: () => string | undefined88 isDisabled?: boolean89}) {90 const { localization } = useAuth()91// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from better-auth-ui
All 49 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Account Settingsaccount-settings | better-auth-ui | Components | Free | 2 deps | |
| Active Sessionsactive-sessions | better-auth-ui | Components | Free | 5 deps · 2 files | |
| Adminadmin | better-auth-ui | Components | Free | 4 deps · 3 files | |
| Anonymousanonymous | better-auth-ui | Components | Free | 4 deps · 3 files | |
| API Keyapi-key | better-auth-ui | Components | Free | 4 deps · 10 files | |
| Authauth | better-auth-ui | Components | Free | 2 deps | |
| Auth Providerauth-provider | better-auth-ui | Components | Free | 4 deps · 2 files | |
| Auth Redirectauth-redirect | better-auth-ui | Components | Free | 3 deps |
