MDUIDocs
Kopiuj link llms.txtKopiuj link llms-full.txtWyświetl tę stronę w formacie MarkdownOmów tę stronę z ChatGPTOmów pełną dokumentację projektu z ChatGPT
Predefiniowany kolor
Własny kolor
Wyodrębnij kolor z tapety
Wybierz tapetę
Pierwsze kroki
Tworzenie wspomagane przez AI
Style
Integracja z frameworkami
Komponenty
Funkcje
Biblioteka narzędziowa jq dialog alert confirm prompt snackbar getTheme setTheme getColorFromImage setColorScheme removeColorScheme loadLocale setLocale getLocale throttle observeResize breakpoint
Biblioteki

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