mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-09 06:55:07 +00:00
20 lines
451 B
TypeScript
20 lines
451 B
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import { useSelectedLayoutSegments } from "next/navigation"
|
|
|
|
export function StyleSwitcher() {
|
|
const segments = useSelectedLayoutSegments()
|
|
|
|
React.useEffect(() => {
|
|
document.body.removeAttribute("data-section")
|
|
|
|
const section = segments.at(-1)
|
|
if (section && typeof window !== "undefined") {
|
|
document.body.setAttribute("data-section", section)
|
|
}
|
|
}, [segments])
|
|
|
|
return null
|
|
}
|