Files
portainer--portainer/app/react/portainer/services/applyTheme.ts
T
2026-07-13 12:08:39 +08:00

15 lines
449 B
TypeScript

import { ThemeColor } from '@/portainer/users/types';
export function applyTheme(color: ThemeColor) {
if (color === 'auto' || !color) {
const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
if (isDark) {
document.documentElement.setAttribute('theme', 'dark');
} else {
document.documentElement.removeAttribute('theme');
}
} else {
document.documentElement.setAttribute('theme', color);
}
}