Home / File/ mode-switcher.tsx — ui Source File

mode-switcher.tsx — ui Source File

Architecture documentation for mode-switcher.tsx, a tsx file in the ui codebase. 6 imports, 0 dependents.

File tsx ComponentRegistry UIPrimitives 6 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  aadbd60f_8438_6522_8e1e_62875148352e["mode-switcher.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  aadbd60f_8438_6522_8e1e_62875148352e --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  d39cd1e4_1b2d_9aa2_1d29_fd0b4bfb61c3["lucide-react"]
  aadbd60f_8438_6522_8e1e_62875148352e --> d39cd1e4_1b2d_9aa2_1d29_fd0b4bfb61c3
  75d25ec8_fe84_91a4_54c6_20dabb286f91["next-themes"]
  aadbd60f_8438_6522_8e1e_62875148352e --> 75d25ec8_fe84_91a4_54c6_20dabb286f91
  109802f5_d07a_09ac_1761_f7055113f24f["site"]
  aadbd60f_8438_6522_8e1e_62875148352e --> 109802f5_d07a_09ac_1761_f7055113f24f
  78f438c1_34dd_4824_63b3_180c613db378["use-meta-color"]
  aadbd60f_8438_6522_8e1e_62875148352e --> 78f438c1_34dd_4824_63b3_180c613db378
  aa2f3ec6_f291_3763_88ec_65a3f5ad5939["button"]
  aadbd60f_8438_6522_8e1e_62875148352e --> aa2f3ec6_f291_3763_88ec_65a3f5ad5939
  style aadbd60f_8438_6522_8e1e_62875148352e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import * as React from "react"
import { MoonIcon, SunIcon } from "lucide-react"
import { useTheme } from "next-themes"

import { META_THEME_COLORS } from "@/config/site"
import { useMetaColor } from "@/hooks/use-meta-color"
import { Button } from "@/registry/new-york/ui/button"

export function ModeSwitcher() {
  const { setTheme, resolvedTheme } = useTheme()
  const { setMetaColor } = useMetaColor()

  const toggleTheme = React.useCallback(() => {
    setTheme(resolvedTheme === "dark" ? "light" : "dark")
    setMetaColor(
      resolvedTheme === "dark"
        ? META_THEME_COLORS.light
        : META_THEME_COLORS.dark
    )
  }, [resolvedTheme, setTheme, setMetaColor])

  return (
    <Button
      variant="ghost"
      className="group/toggle h-8 w-8 px-0"
      onClick={toggleTheme}
    >
      <SunIcon className="hidden [html.dark_&]:block" />
      <MoonIcon className="hidden [html.light_&]:block" />
      <span className="sr-only">Toggle theme</span>
    </Button>
  )
}

Subdomains

Functions

Dependencies

  • button
  • lucide-react
  • next-themes
  • react
  • site
  • use-meta-color

Frequently Asked Questions

What does mode-switcher.tsx do?
mode-switcher.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 mode-switcher.tsx?
mode-switcher.tsx defines 1 function(s): ModeSwitcher.
What does mode-switcher.tsx depend on?
mode-switcher.tsx imports 6 module(s): button, lucide-react, next-themes, react, site, use-meta-color.
Where is mode-switcher.tsx in the architecture?
mode-switcher.tsx is located at deprecated/www/components/mode-switcher.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