Skip to content

[Charts] Remove/Hide useDarkMode hook from charts theme service #220432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nickofthyme opened this issue May 7, 2025 · 1 comment
Open

[Charts] Remove/Hide useDarkMode hook from charts theme service #220432

nickofthyme opened this issue May 7, 2025 · 1 comment
Labels
Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion)

Comments

@nickofthyme
Copy link
Contributor

In the charts plugin we exposed a useDarkMode hook to make it easy to fetch dark mode from charts instead of also having to import the theme.

/** A React hook for consuming the dark mode value */
public useDarkMode = (): boolean => {
const [value, update] = useState(false);
useEffect(() => {
const s = this.darkModeEnabled$.subscribe((val) => {
update(val.darkMode);
});
return () => s.unsubscribe();
}, []);
return value;
};

In addition we also provided an observable for darkModeEnabled$.

/** An observable boolean for dark mode of kibana */
public get darkModeEnabled$(): Observable<CoreTheme> {
if (!this.theme$) {
throw new Error('ThemeService not initialized');
}
return this.theme$;
}

With changes to correct usage of the theme across kibana in #220141 we deprecated these properties to prevent usage in favor of useKibanaIsDarkMode (later to be useIsDarkMode from eui).

These properties should eventually be hidden in the case of darkModeEnabled$ and removed in the case of useDarkMode.

@nickofthyme nickofthyme added the Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) label May 7, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations (Team:Visualizations)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion)
Projects
None yet
Development

No branches or pull requests

2 participants