Theme
better-auth-ui/themeFreeComponent
Theme plugin: theme-library agnostic theme selection. Registers an Appearance card in account settings and a theme toggle in the user button. Pass `useTheme` from your theme library (e.g. next-themes) or static `setTheme`.
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/theme.jsonSource
1"use client"23import {4 ThemePreviewDark,5 ThemePreviewLight,6 ThemePreviewSystem,7 useAuthPlugin8} from "@better-auth-ui/react"9import { Monitor, Moon, Sun } from "lucide-react"10import { useEffect, useState } from "react"1112import { Card, CardContent } from "@/components/ui/card"13import {14 Field,15 FieldContent,16 FieldLabel,17 FieldTitle18} from "@/components/ui/field"19import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"20import { themePlugin } from "@/lib/auth/theme-plugin"21import { cn } from "@/lib/utils"2223export type AppearanceProps = {24 className?: string25}2627/**28 * Renders a theme selector card with visual theme previews.29 *30 * Displays a card containing radio buttons for selecting between system, light,31 * and dark themes. Each option shows a visual preview of the theme.32 *33 * @param className - Optional additional CSS class names for the card container.34 * @returns A JSX element containing the theme selector card.35 */36export function Appearance({ className }: AppearanceProps) {37 const { useTheme, localization } = useAuthPlugin(themePlugin)38 const { theme, setTheme, themes = [] } = useTheme()3940 const [isMounted, setIsMounted] = useState(false)41 useEffect(() => setIsMounted(true), [])4243 return (44 <div>45 <h2 className="text-sm font-semibold mb-3">{localization.appearance}</h2>4647 <Card className={cn(className)}>48 <CardContent>49 <Field>50 <FieldLabel>{localization.theme}</FieldLabel>5152 <RadioGroup53 value={isMounted ? theme : ""}54 onValueChange={setTheme}55 className="grid gap-3 grid-cols-2 sm:grid-cols-3"56 disabled={!isMounted || !theme}57 >58 {themes.includes("system") && (59 <FieldLabel htmlFor="system">60 <Field orientation="horizontal">61 <FieldContent className="gap-2">62 <div className="flex items-center gap-2 justify-between">63 <FieldTitle>64 <Monitor className="size-4 text-muted-foreground" />6566 {localization.system}67 </FieldTitle>6869 <RadioGroupItem value="system" id="system" />70 </div>7172 <ThemePreviewSystem className="w-full" />73 </FieldContent>74 </Field>75 </FieldLabel>76 )}7778// … 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 | |
| Additional Fieldadditional-field | better-auth-ui | Components | Free | 5 deps | |
| 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 |
