Home / File/ themes-selector.tsx — ui Source File

themes-selector.tsx — ui Source File

Architecture documentation for themes-selector.tsx, a tsx file in the ui codebase. 9 imports, 0 dependents.

File tsx ComponentRegistry UIPrimitives 9 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  608507ba_d93d_7212_9b99_5f8639585ddc["themes-selector.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  608507ba_d93d_7212_9b99_5f8639585ddc --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  75d25ec8_fe84_91a4_54c6_20dabb286f91["next-themes"]
  608507ba_d93d_7212_9b99_5f8639585ddc --> 75d25ec8_fe84_91a4_54c6_20dabb286f91
  051af7df_a60b_d4df_95ed_ca045420060f["themes"]
  608507ba_d93d_7212_9b99_5f8639585ddc --> 051af7df_a60b_d4df_95ed_ca045420060f
  79081a1f_55a3_945a_fb8c_d53d6d3eab81["utils"]
  608507ba_d93d_7212_9b99_5f8639585ddc --> 79081a1f_55a3_945a_fb8c_d53d6d3eab81
  5b9fe790_07fa_d673_2d62_394a21141145["use-media-query"]
  608507ba_d93d_7212_9b99_5f8639585ddc --> 5b9fe790_07fa_d673_2d62_394a21141145
  4301cef0_efc0_0be1_8523_bd5b8e946772["use-themes-config"]
  608507ba_d93d_7212_9b99_5f8639585ddc --> 4301cef0_efc0_0be1_8523_bd5b8e946772
  3119ffb8_7316_4004_c2c7_61f58afcb2f8["skeleton"]
  608507ba_d93d_7212_9b99_5f8639585ddc --> 3119ffb8_7316_4004_c2c7_61f58afcb2f8
  c779bc65_85d6_5abf_7b1c_a21b2393881e["toggle-group"]
  608507ba_d93d_7212_9b99_5f8639585ddc --> c779bc65_85d6_5abf_7b1c_a21b2393881e
  4ad968a1_2bd7_248c_f5ed_f80d5b5f7417["tooltip"]
  608507ba_d93d_7212_9b99_5f8639585ddc --> 4ad968a1_2bd7_248c_f5ed_f80d5b5f7417
  style 608507ba_d93d_7212_9b99_5f8639585ddc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import * as React from "react"
import { useTheme } from "next-themes"

import { THEMES, Theme } from "@/lib/themes"
import { cn } from "@/lib/utils"
import { useMediaQuery } from "@/hooks/use-media-query"
import { useThemesConfig } from "@/hooks/use-themes-config"
import { Skeleton } from "@/registry/new-york/ui/skeleton"
import {
  ToggleGroup,
  ToggleGroupItem,
} from "@/registry/new-york/ui/toggle-group"
import {
  Tooltip,
  TooltipContent,
  TooltipTrigger,
} from "@/registry/new-york/ui/tooltip"

export function ThemesSwitcher({
  themes = THEMES,
  className,
}: React.ComponentProps<"div"> & { themes?: Theme[] }) {
  const { theme: mode } = useTheme()
  const [mounted, setMounted] = React.useState(false)
  const { themesConfig, setThemesConfig } = useThemesConfig()
  const activeTheme = themesConfig.activeTheme
  const isDesktop = useMediaQuery("(min-width: 1024px)")

  React.useEffect(() => {
    setMounted(true)
  }, [])

  if (!mounted) {
    return (
      <div
        className={cn(
          "flex items-center justify-center gap-0.5 py-4 lg:flex-col lg:justify-start lg:gap-1",
          className
        )}
      >
        {themes.map((theme) => (
          <div
            key={theme.id}
            className="flex h-10 w-10 items-center justify-center rounded-lg border-2 border-transparent"
          >
            <Skeleton className="h-6 w-6 rounded-sm" />
          </div>
        ))}
      </div>
    )
  }

  return (
    <ToggleGroup
      type="single"
      value={activeTheme.name}
      onValueChange={(value) => {
        const theme = themes.find((theme) => theme.name === value)
// ... (65 more lines)

Subdomains

Functions

Dependencies

  • next-themes
  • react
  • skeleton
  • themes
  • toggle-group
  • tooltip
  • use-media-query
  • use-themes-config
  • utils

Frequently Asked Questions

What does themes-selector.tsx do?
themes-selector.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, UIPrimitives subdomain.
What functions are defined in themes-selector.tsx?
themes-selector.tsx defines 1 function(s): ThemesSwitcher.
What does themes-selector.tsx depend on?
themes-selector.tsx imports 9 module(s): next-themes, react, skeleton, themes, toggle-group, tooltip, use-media-query, use-themes-config, and 1 more.
Where is themes-selector.tsx in the architecture?
themes-selector.tsx is located at deprecated/www/components/themes-selector.tsx (domain: ComponentRegistry, subdomain: UIPrimitives, directory: deprecated/www/components).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free