use-themed-page.tsx 438 B

123456789101112
  1. import { useLayoutEffect } from 'react'
  2. import { useActiveOverallTheme } from './use-active-overall-theme'
  3. export default function useThemedPage(featureFlag?: string) {
  4. const activeOverallTheme = useActiveOverallTheme(featureFlag)
  5. useLayoutEffect(() => {
  6. // Sets the body's data-theme attribute for theming
  7. document.body.dataset.theme =
  8. activeOverallTheme === 'dark' ? 'default' : 'light'
  9. }, [activeOverallTheme])
  10. }