mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-11 09:51:40 +00:00
99 lines
2.2 KiB
TypeScript
99 lines
2.2 KiB
TypeScript
"use client"
|
|
|
|
import { useThemeConfig } from "@/components/active-theme"
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectGroup,
|
|
SelectItem,
|
|
SelectLabel,
|
|
SelectSeparator,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from "@/registry/new-york-v4/ui/select"
|
|
|
|
const DEFAULT_THEMES = [
|
|
{
|
|
name: "Default",
|
|
value: "default",
|
|
},
|
|
{
|
|
name: "Blue",
|
|
value: "blue",
|
|
},
|
|
{
|
|
name: "Green",
|
|
value: "green",
|
|
},
|
|
{
|
|
name: "Amber",
|
|
value: "amber",
|
|
},
|
|
]
|
|
|
|
const SCALED_THEMES = [
|
|
{
|
|
name: "Default",
|
|
value: "default-scaled",
|
|
},
|
|
{
|
|
name: "Blue",
|
|
value: "blue-scaled",
|
|
},
|
|
]
|
|
|
|
const MONO_THEMES = [
|
|
{
|
|
name: "Mono",
|
|
value: "mono-scaled",
|
|
},
|
|
]
|
|
|
|
export function ThemeSelector() {
|
|
const { activeTheme, setActiveTheme } = useThemeConfig()
|
|
|
|
return (
|
|
<div className="flex items-center gap-2">
|
|
<Select value={activeTheme} onValueChange={setActiveTheme}>
|
|
<SelectTrigger
|
|
size="sm"
|
|
className="justify-start *:data-[slot=select-value]:w-12"
|
|
>
|
|
<span className="text-muted-foreground hidden sm:block">
|
|
Select a theme:
|
|
</span>
|
|
<span className="text-muted-foreground block sm:hidden">Theme</span>
|
|
<SelectValue placeholder="Select a theme" />
|
|
</SelectTrigger>
|
|
<SelectContent align="end">
|
|
<SelectGroup>
|
|
<SelectLabel>Default</SelectLabel>
|
|
{DEFAULT_THEMES.map((theme) => (
|
|
<SelectItem key={theme.name} value={theme.value}>
|
|
{theme.name}
|
|
</SelectItem>
|
|
))}
|
|
</SelectGroup>
|
|
<SelectSeparator />
|
|
<SelectGroup>
|
|
<SelectLabel>Scaled</SelectLabel>
|
|
{SCALED_THEMES.map((theme) => (
|
|
<SelectItem key={theme.name} value={theme.value}>
|
|
{theme.name}
|
|
</SelectItem>
|
|
))}
|
|
</SelectGroup>
|
|
<SelectGroup>
|
|
<SelectLabel>Monospaced</SelectLabel>
|
|
{MONO_THEMES.map((theme) => (
|
|
<SelectItem key={theme.name} value={theme.value}>
|
|
{theme.name}
|
|
</SelectItem>
|
|
))}
|
|
</SelectGroup>
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
)
|
|
}
|