Line

You are reading docs for v0.8. See latest (v0.9)

ui/client/features/shell/hooks/useTheme

Cockpit client (features), v0.8. Source: ui/client/features/shell/hooks/useTheme.tsx.

Functions#

useTheme()#

useTheme(): object

Defined in: ui/client/features/shell/hooks/useTheme.tsx:14

Current theme, the person's preference (Dark / Light / System) and the actions to change it. The initial values are 'dark' for SSR/hydration parity; the stored preference is read right after mount (the inline init script in the document head has already applied it, so there is no flash). is the resolved source of truth. While the preference is "system", a change of the operating system's own setting is followed live.

Returns#

preference

preference: ThemePreference

setPreference

setPreference: (next) => void

Parameters
next

ThemePreference

Returns

void

theme

theme: Theme

toggle

toggle: () => void

The palette's "Toggle dark / light theme": flips what is painted and pins it as an explicit choice.

Returns

void