light‑dark() Function Tester - Online Color Switch
Use the light‑dark() CSS function to change colors based on color scheme. Build a simple dark mode toggle with one property.
UD5 Toolkit
This preview shows how your CSS custom properties render in a real UI component with text, buttons, and interactive elements.
-- prefix (e.g., --bg-primary) that store reusable values. They cascade through the DOM, can be updated dynamically with JavaScript, and enable powerful features like easy theme switching without rewriting entire stylesheets. They are supported in all modern browsers.:root for light mode, then override them inside a dark mode selector like [data-theme="dark"] or @media (prefers-color-scheme: dark). Apply these variables throughout your stylesheet. Use JavaScript to toggle a data-theme attribute on the <html> element to switch themes on demand.[data-theme="dark"] is a manual approach where JavaScript controls theme switching based on user interaction (a toggle button). @media (prefers-color-scheme: dark) automatically follows the user's operating system preference. Many websites combine both: default to the OS preference but allow manual override via a toggle that sets the data attribute.document.documentElement.setAttribute('data-theme', 'dark') to switch to dark mode, and document.documentElement.removeAttribute('data-theme') to revert to light. Store the user's preference in localStorage so it persists across page reloads. Add a smooth CSS transition on your variables for a polished feel.filter: brightness(0.9) on images in dark mode to reduce eye strain. For logos and icons, consider using SVG with currentColor or providing separate light/dark versions swapped via CSS. The <picture> element with prefers-color-scheme media queries can also serve different image assets.--color-bg-primary, --color-text-body, --spacing-md. Define all light theme variables under :root and dark overrides in a single dark theme block. Keep variable definitions in one centralized file for maintainability.* { transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease; }. Be mindful of performance—limit transitions to color-related properties and avoid transitioning on too many elements simultaneously. For a more refined approach, apply transitions only to specific component containers.[data-theme="solarized"], [data-theme="high-contrast"], or [data-theme="sepia"]. Each theme block overrides the same set of variables with different values. This generator tool can help you create as many theme variants as you need—simply copy the CSS block and adjust the selector.localStorage: localStorage.setItem('theme', 'dark'). On page load, read the stored value and apply it before the page renders to avoid a flash of incorrect theme (FOIT). For optimal UX, check the stored preference in a small inline script in the <head> so the correct theme is applied immediately.Use the light‑dark() CSS function to change colors based on color scheme. Build a simple dark mode toggle with one property.
Paste a list of hex colors and generate CSS custom properties for them. Create your design token file instantly.
Fetch a website's CSS and extract :root custom properties (‑‑color) to reveal its design token palette. For learning and inspiration.
Interactively create colors in HWB space and get the CSS hwb() function. Simplifies tint/shade workflows. Live preview.
Pick a base color and generate a full palette of 10 shades (50 to 900) like Tailwind CSS. Copy as hex or hsl.
Generate a range of tints and shades from a single hex color. Ideal for data visualization, UI design systems, and Tailwind custom palette creation. Local tool.
Customize Bootstrap 5 variables visually. See the live preview. Download the generated SCSS or CSS file.
Pick a color in the Display‑P3 space and get the CSS color() function. See the difference from sRGB. For modern design.
Dynamically blend two colors using the CSS color‑mix() function in different color spaces. Copy the exact CSS snippet. No JS required.
Pick a source color and generate a complete M3 tonal palette with light/dark schemes. Export as CSS custom properties.
Paste your CSS and get a sorted list of all custom properties defined under :root with their values. Quick audit.
Enter a CSS selector and see its specificity broken down into A,B,C columns with a visual weight comparison. Learn specificity.
Grid of all 148 named CSS colors. Hover to see detail, click to copy the name or hex. Essential frontend reference.
Write modern CSS color functions like oklch(), lab(), hwb() and see the rendered color with fallback. Copy compatible code.
Test the upcoming contrast‑color() CSS function. Get white or black automatically for a given background. See it live.
Style the <progress> and <meter> elements with cross‑browser CSS. Adjust colors and sizes. Copy the final styles.
Type a CSS color name like 'tomato' or 'mediumseagreen' and instantly get its hex code and preview. Complete named colors list.
Pick colors using the HWB (Hue‑Whiteness‑Blackness) model. Get the CSS hwb() function code. Simpler than HSL for some.
Set a custom accent color for checkboxes, radios, range, and progress. See the browser’s rendering. Copy the CSS.
Select emotions (calm, energetic, sad) and generate a harmonious color palette that reflects the mood.
Style an `<input type='range'>` with custom track and thumb. Cross‑browser CSS. Preview and copy the code.
Enter a color palette and see how it looks for different types of color vision deficiency. Get warnings on conflicting colors.
Paste a stylesheet and extract every unique color (hex, rgb, hsl) into a palette. Swatches displayed. Copy as JSON.
Discover beautiful color palettes for your projects. Generate random, complementary, or trendy schemes and copy hex codes. Useful for designers and developers.
Design custom radio buttons and checkboxes using pure CSS. Choose sizes, colors, and animation. Copy the code.
See the Pantone Colors of the Year and popular palettes from past years. Get hex codes. Design inspiration.
Use the browser's native eyedropper tool to pick any color from the screen. Shows zoomed preview. Quick and easy.
A complete, searchable list of all 140+ named HTML/CSS colors with their hex codes and color previews. Click to copy code. Essential web reference.
Build a palette and simulate how it appears to various color deficiencies. Also generate pre-vetted accessible palettes. Local processing.
Choose a base color and see its complementary, split‑complementary, triadic, and tetradic harmonies. Copy palettes. Local.