Checks if the user color scheme preference is dark
.
Window.matchMedia()
with the appropriate media query to check the user color scheme preference.const prefersDarkColorScheme = () =>
window &&
window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches;
prefersDarkColorScheme(); // true
JavaScript, Browser
Checks if the user color scheme preference is light
.
JavaScript, Browser
Detects the preferred language of the current user.
JavaScript, Browser
Copies a string to the clipboard.
Only works as a result of user action (i.e. inside a click
event listener).