@egstad/detect-theme
Version:
A micro ES6 module (~0.5KB) for detecting a users preferred-color-scheme and watching for changes.
46 lines (43 loc) • 1.08 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EGSTAD • Detect Theme</title>
<link href="https://fonts.googleapis.com/css2?family=Cutive+Mono&display=swap" rel="stylesheet">
<style>
:root {
--background: black;
--foreground: white;
}
html,
body {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background: var(--background);
color: var(--foreground);
}
h1 {
font-family: 'Cutive Mono', monospace;
font-size: clamp(1em, 2vw, 2em);
line-height: 1.62;
padding: 1em;
text-transform: lowercase;
text-align: center;
}
#currentTheme {
background: var(--foreground);
color: var(--background);
border-radius: 0.25em;
padding: 0 0.25em;
}
</style>
</head>
<body>
<h1>Your theme is currently set to: <span id="currentTheme"></span></h1>
<script src="./app.js"></script>
</body>
</html>