Skip Navigation
Type MethodMethod

generateDarkModeCSS(from:)

Generates dark mode CSS variables.

static func generateDarkModeCSS(from settings: ThemeSettings.Root) -> String

Parameters

settings

The theme settings.

Return Value

CSS for dark mode variables, or an empty string if no value differs.

Discussion

Every property whose dark value differs from its light value is redefined as a light-dark() pair of both values, so the colour scheme of the body selects the value. The rule is guarded by @supports, so browsers without light-dark() keep the light values.