Skip to content

Provide a react hook to obtain isDarkMode directly #8693

Description

@nickofthyme

Is your feature request related to a problem? Please describe.

In kibana we need to access the colorMode fairly frequently. But currently this task is a bit cumbersome and not easily discoverable leading to misuse.

Describe the solution you'd like

A simple hook to return just the isDarkMode ideally of the form...

export const useIsDarkMode = (): boolean => {
  const { colorMode } = useEuiTheme();

  return colorMode === COLOR_MODES_STANDARD.dark;
};

Describe alternatives you've considered

Using useEuiTheme to dig out the colorMode and compare the value.

Desired timeline

Next release if possible. Currently we are using a temporary abstraction in kinana (i.e. useKibanaIsDarkMode) which can be easily replaced, see elastic/kibana#220141.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions