Skip to content

setDarkTheme

Adds or removes the dark attribute on the root HTML element. This pairs well with CSS selectors that use html[dark] or [dark] to activate a dark theme.

Importing

ts
import { setDarkTheme } from '@almighty-shogun/utils'

Usage

ts
import { setDarkTheme } from '@almighty-shogun/utils'

setDarkTheme(true);

// <html dark>

Parameters

NameTypeDescription
isDarkbooleanWhether the dark attribute should be present.

Type signature

ts
declare function setDarkTheme(isDark: boolean): void;

All packages are released under the MIT License.