Theme Toggle Glass
shadcn-glass-ui/theme-toggle-glassFreeComponent
Theme cycling button that switches between Light, Aurora, and Glass themes. * Displays animated icon transitions with theme-aware styling. * * ## Features
Install it
npx shadcn@latest add https://raw.githubusercontent.com/artyhoo/shadcn-glass-ui-library/main/public/r/theme-toggle-glass.jsonSource
1/**2 * ThemeToggleGlass Component3 *4 * Theme cycling button that switches between Light, Aurora, and Glass themes.5 * Displays animated icon transitions with theme-aware styling.6 *7 * ## Features8 * - One-click theme cycling through 3 themes (light → aurora → glass → light)9 * - Animated icon transitions (Sun → Moon → Palette)10 * - Built on IconButtonGlass styling for consistency11 * - Theme preview via icon (shows NEXT theme, not current)12 * - Optional text label showing next theme name13 * - Responsive label visibility (hidden on mobile by default)14 * - Integrates with useTheme hook for global theme state15 * - Accessible button with descriptive aria-label16 * - Keyboard accessible (Enter/Space to activate)17 * - Custom toggle handler support for advanced use cases18 *19 * ## CSS Variables20 * Uses IconButtonGlass CSS variables:21 * - `--card-subtle-bg` - Button background22 * - `--card-subtle-border` - Button border23 * - `--text-secondary` - Icon and label color24 *25 * @example Basic theme toggle26 * ```tsx27 * import { ThemeToggleGlass } from 'shadcn-glass-ui'28 *29 * function Header() {30 * return (31 * <ThemeToggleGlass />32 * )33 * }34 * ```35 *36 * @example Icon-only (no label)37 * ```tsx38 * <ThemeToggleGlass iconOnly />39 * ```40 *41 * @example Custom toggle handler42 * ```tsx43 * function AdvancedThemeToggle() {44 * const handleToggle = () => {45 * console.log('Theme changing...')46 * // Custom logic here47 * }48 *49 * return <ThemeToggleGlass onToggle={handleToggle} />50 * }51 * ```52 *53 * @example Larger icon size54 * ```tsx55 * <ThemeToggleGlass iconSize={24} />56 * ```57 *58 * @accessibility59 * - Descriptive aria-label indicates next theme (e.g., "Switch to Aurora theme")60 * - Focus ring visible for keyboard navigation61 * - Keyboard activation via Enter or Space key62 * - Icon provides visual feedback for theme state63 * - Hover scale animation (105%) indicates interactivity64 *65 * @since v1.0.066 */6768import { forwardRef, type ButtonHTMLAttributes, type CSSProperties } from 'react';69import { Sun, Moon, Palette } from 'lucide-react';70import { cn } from '@/lib/utils';71import { useTheme, type ThemeName } from '@/lib/theme-context';72import '@/glass-theme.css';7374// ========================================75// CONFIGURATION76// ========================================7778const themes: ThemeName[] = ['light', 'aurora', 'glass'];7980const themeConfig: Record<ThemeName, { label: string; icon: typeof Sun }> = {81 light: { label: 'Light', icon: Sun },82// … truncated
More from shadcn-glass-ui
All 76 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Alert Glassalert-glass | shadcn-glass-ui | Components | Free | no deps | |
| Animated Background Glassanimated-background-glass | shadcn-glass-ui | Components | Free | no deps | |
| Avatar Glassavatar-glass | shadcn-glass-ui | Components | Free | no deps | |
| Badge Glassbadge-glass | shadcn-glass-ui | Components | Free | no deps | |
| Base Progress Glassbase-progress-glass | shadcn-glass-ui | Components | Free | no deps | |
| Button Glassbutton-glass | shadcn-glass-ui | Components | Free | no deps | |
| Card Glasscard-glass | shadcn-glass-ui | Components | Free | no deps | |
| Checkbox Glasscheckbox-glass | shadcn-glass-ui | Components | Free | no deps |
