mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-23 20:55:47 +00:00
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
"use client"
|
|
|
|
import { THEMES } from "@/lib/themes"
|
|
import { cn } from "@/lib/utils"
|
|
import { useThemeConfig } from "@/components/active-theme"
|
|
import { Label } from "@/registry/new-york-v4/ui/label"
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from "@/registry/new-york-v4/ui/select"
|
|
|
|
import { CopyCodeButton } from "./theme-customizer"
|
|
|
|
export function ThemeSelector({ className }: React.ComponentProps<"div">) {
|
|
const { activeTheme, setActiveTheme } = useThemeConfig()
|
|
|
|
const value = activeTheme === "default" ? "neutral" : activeTheme
|
|
|
|
return (
|
|
<div className={cn("flex items-center gap-2", className)}>
|
|
<Label htmlFor="theme-selector" className="sr-only">
|
|
Theme
|
|
</Label>
|
|
<Select value={value} onValueChange={setActiveTheme}>
|
|
<SelectTrigger
|
|
id="theme-selector"
|
|
size="sm"
|
|
className="bg-secondary text-secondary-foreground border-secondary justify-start shadow-none *:data-[slot=select-value]:w-12"
|
|
>
|
|
<span className="font-medium">Theme:</span>
|
|
<SelectValue placeholder="Select a theme" />
|
|
</SelectTrigger>
|
|
<SelectContent align="end">
|
|
{THEMES.map((theme) => (
|
|
<SelectItem
|
|
key={theme.name}
|
|
value={theme.name}
|
|
className="data-[state=checked]:opacity-50"
|
|
>
|
|
{theme.label}
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
<CopyCodeButton variant="secondary" size="icon-sm" />
|
|
</div>
|
|
)
|
|
}
|