setTheme
Funkcja setTheme ustawia motyw dla bieżącej strony lub określonego elementu.
Dostępne motywy to light, dark i auto. Zobacz Tryb ciemny.
Sposób użycia
Zaimportuj funkcję:
import { setTheme } from 'mdui/functions/setTheme.js';
Przykład użycia:
// Ustaw całą stronę na tryb ciemny
setTheme('dark');
// Ustaw element o klasie "element" na tryb ciemny
setTheme('dark', '.element');
// Ustaw podany element DOM na tryb ciemny
const element = document.querySelector('.element');
setTheme('dark', element);
API
setTheme(theme: 'light' | 'dark' | 'auto', target?: string | HTMLElement | JQ<HTMLElement>): void
Pierwszym parametrem jest ustawiany motyw: light, dark lub auto.
Drugim parametrem jest element, dla którego ma zostać ustawiony motyw. Może to być selektor CSS, element DOM lub obiekt JQ. Jeśli nie podasz drugiego parametru, motyw zostanie ustawiony na elemencie <html>.
Na tej stronie