Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Yes—two choices are enough for most dark-mode controls: follow the device’s current appearance, or pin the other appearance. This gives people a useful temporary override without making them choose between labels whose visual result is identical. The important detail is that a manual choice pins light or dark; it must not mean “always use the opposite of whatever my system says.”

What the two-state model actually means

A two-state control represents two intents, not merely two colors:

  • Follow system: use the operating system or browser preference, including future changes.
  • Manual override: pin a concrete appearance—light or dark—until the person changes the choice.

The manual option is relative only when it is presented. If the system is light, the control can offer “Use dark.” If the system is dark, it can offer “Use light.” Once selected, that choice becomes an explicit value. A person who selected dark remains in dark mode even if the operating system later changes to dark as well; the site does not recalculate the choice as “the opposite of the current system.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This behavior follows the Chrome team’s modern web guidance. Two controls that produce the same appearance provide no useful feedback, while “system” and “pinned alternative” communicate distinct intentions.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Compare the two choices by behavior, not label

Choice What it stores What happens when the OS changes What happens on a later visit
Follow system No fixed color, or an explicit system value The page follows the new light or dark preference It starts from the current system preference
Manual override A fixed light or dark value The pinned value remains unchanged The saved value is restored

Avoid naming the manual state “opposite system.” That phrase describes an algorithm, not a stable preference. Suppose someone chooses dark while their laptop is light, then enables dark mode at the operating-system level. An opposite-based implementation would flip the site back to light at exactly the moment the person expects dark to remain selected. Storing the concrete value prevents that surprise.

Choose the default and persistence rules

On a first visit, the system preference is the most useful default. The CSS media feature prefers-color-scheme exposes that user-agent preference; MDN notes that light also covers cases where no active preference has been expressed. Your page should therefore render correctly without a saved value and without JavaScript.

When a person chooses a manual appearance, persist that override, commonly with localStorage. On subsequent visits, restore the saved light or dark value before the page paints. If the person returns to “follow system,” remove the override so the operating-system preference becomes authoritative again.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The CSS default must remain system-aware even if scripts are blocked, fail, or load late. This avoids a permanently light or dark page for users who cannot execute JavaScript and reduces the flash of an incorrect theme during startup.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Declare color-scheme support at the page root

Tell the browser that both schemes are supported. This lets browser-controlled surfaces—such as form controls, scrollbars, and other native UI—adapt along with your page. The W3C CSS Color Adjustment specification defines this mechanism, and Chrome’s guidance recommends declaring both values.

<meta name='color-scheme' content='light dark'>
<style>
  :root {
    color-scheme: light dark;
    --page-bg: #ffffff;
    --page-fg: #1f2328;
    --muted-fg: #57606a;
    --border: #d0d7de;
    --link: #0969da;
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --page-bg: #0d1117;
      --page-fg: #e6edf3;
      --muted-fg: #8b949e;
      --border: #30363d;
      --link: #58a6ff;
    }
  }

  [data-theme='light'] {
    color-scheme: light;
    --page-bg: #ffffff;
    --page-fg: #1f2328;
    --muted-fg: #57606a;
    --border: #d0d7de;
    --link: #0969da;
  }

  [data-theme='dark'] {
    color-scheme: dark;
    --page-bg: #0d1117;
    --page-fg: #e6edf3;
    --muted-fg: #8b949e;
    --border: #30363d;
    --link: #58a6ff;
  }

  body {
    background: var(--page-bg);
    color: var(--page-fg);
  }
</style>

The unqualified variables provide a light baseline, while the media query supplies the system-dark version. The explicit attributes then override those defaults when a saved choice exists. Keep all theme-dependent values in one place so the rest of the stylesheet consumes variables rather than scattering hard-coded colors.

Apply a saved choice before the first paint

An inline head script can set the root attribute before the browser renders the body. It should accept only the values your application understands and tolerate storage failures, such as private browsing restrictions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<script>
  (function () {
    try {
      var saved = localStorage.getItem('theme');
      if (saved === 'light' || saved === 'dark') {
        document.documentElement.dataset.theme = saved;
      }
    } catch (error) {
      // CSS will continue to follow prefers-color-scheme.
    }
  }());
</script>

Do not write data-theme='light' or data-theme='dark' when the user has chosen system-following mode. Leaving the attribute absent allows the media query to respond naturally.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Build a control whose state is understandable

The control needs an accessible name and a state that explain what selecting it will do. A visible label such as “Use dark appearance” is clearer than a sun or moon icon with no text. If you use a button that cycles between the two modes, expose the current mode with aria-pressed or an equivalent status and update the label after every change. A segmented control can show “Follow system” and the currently available pinned alternative.

Here is a compact button implementation. It treats a missing storage value as system-following, then toggles between system and a concrete value. The button’s text describes the next action, while the status text reports the current state.

<button type='button' id='theme-toggle' aria-pressed='false'>
  Use dark appearance
</button>
<span id='theme-status' role='status'>Following system appearance</span>

<script>
  (function () {
    var root = document.documentElement;
    var button = document.getElementById('theme-toggle');
    var status = document.getElementById('theme-status');
    var systemDark = window.matchMedia('(prefers-color-scheme: dark)');

    function savedTheme() {
      try {
        var value = localStorage.getItem('theme');
        return value === 'light' || value === 'dark' ? value : null;
      } catch (error) {
        return null;
      }
    }

    function setTheme(value) {
      if (value === 'light' || value === 'dark') {
        root.dataset.theme = value;
        root.style.colorScheme = value;
        try { localStorage.setItem('theme', value); } catch (error) {}
        button.setAttribute('aria-pressed', 'true');
        button.textContent = value === 'dark' ? 'Follow system appearance' : 'Use dark appearance';
        status.textContent = 'Using ' + value + ' appearance';
      } else {
        root.removeAttribute('data-theme');
        root.style.colorScheme = 'light dark';
        try { localStorage.removeItem('theme'); } catch (error) {}
        button.setAttribute('aria-pressed', 'false');
        button.textContent = systemDark.matches ? 'Use light appearance' : 'Use dark appearance';
        status.textContent = 'Following system appearance';
      }
    }

    setTheme(savedTheme());

    button.addEventListener('click', function () {
      var current = savedTheme();
      setTheme(current ? null : (systemDark.matches ? 'light' : 'dark'));
    });
  }());
</script>

When a user has pinned a theme, pressing the button in this example returns to system-following. When the user is following the system, it pins the opposite of the system’s current appearance once, then keeps that concrete value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Handle operating-system changes without breaking a pin

If your script observes matchMedia('(prefers-color-scheme: dark)'), listen for its change event. Update labels and the rendered CSS only when no saved override exists. A pinned theme must not be replaced merely because the operating system changed.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
systemDark.addEventListener('change', function () {
  if (!savedTheme()) {
    setTheme(null);
  }
});

Older browsers used systemDark.addListener; support it only if your compatibility target requires it. In either case, the listener is for the system-following state. It is not permission to rewrite a saved light or dark value.

Audit every theme-dependent surface

Changing the page background and body text is not enough. Review the complete interface in both appearances:

  • Body text, headings, captions, placeholders, and disabled text.
  • Links, visited links, hover states, and inline code.
  • Icons, illustrations, logos, charts, and images with transparent backgrounds.
  • Borders, separators, shadows, cards, tables, and selected rows.
  • Inputs, selects, checkboxes, date pickers, validation messages, and autofill states.
  • Keyboard focus indicators, text selection, tooltips, dialogs, and menus.

Check foreground and background as a pair in each scheme. The W3C specification warns that combining system colors with author-specified colors does not guarantee a particular contrast level. A dark background can still have low-contrast gray text, and a light theme can hide focus outlines against white surfaces. Test real components rather than assuming that the color-scheme declaration solves contrast for you.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When a three-option selector is justified

A “System / Light / Dark” selector is reasonable when people need an explicit long-term light choice and an explicit long-term dark choice independent of the current device setting—for example, in a professional tool used across shared workstations. It gives three stable values:

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Option Stored value Responds to OS changes?
System No override Yes
Light light No
Dark dark No

For a simple comfort toggle, however, the extra label adds a decision without adding a new visual outcome at the moment of selection. Chrome’s guidance favors the two-state system-versus-pinned-alternative pattern for that case. Platform conventions also matter: Apple’s Human Interface Guidelines advise against an app-specific appearance setting because users may have to adjust more than one setting. That is a platform design position, not a rule that makes every web toggle inappropriate.

Common failures and precise fixes

The page flashes light before becoming dark

Apply the storage-reading script in the document head, before the main stylesheet or body paints. Keep the CSS media-query fallback so a failed script still follows the system.

The theme flips after the operating system changes

Check whether the implementation stores “opposite” instead of light or dark. Save the concrete value and ignore media-query changes while that value exists.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Native controls remain bright

Declare color-scheme: light dark on the root and set the explicit scheme when applying an override. Also inspect controls with custom backgrounds that may override browser adaptation.

The toggle has no clear state for screen-reader users

Give it a persistent accessible name, expose whether an override is active, and provide a live status or visible text that says “Following system appearance” or “Using dark appearance.” Do not rely on an icon’s shape or color alone.

Dark mode passes a quick glance but fails detailed review

Use a component checklist and keyboard through every page. Inspect focus rings, error colors, charts, images, and disabled controls in both schemes; these are frequent sources of unreadable or misleading states.

Practical launch checklist

  1. Define the two intents: follow system and pin a concrete light or dark value.
  2. Set color-scheme: light dark at the root and provide a CSS prefers-color-scheme fallback.
  3. Read and validate localStorage before first paint.
  4. Apply or remove the root theme attribute without writing an “opposite system” value.
  5. Update the document’s color-scheme state when an override is active.
  6. Listen for system changes only while no override is saved.
  7. Label the control with its action and expose its current state.
  8. Review text, controls, graphics, focus indicators, and contrast in both appearances.
  9. Test first visit, reload, storage denial, JavaScript failure, OS changes, and returning from a pinned theme to system-following.

The result is a small control with predictable behavior: system settings work by default, a manual choice stays put, and the interface remains understandable even when scripts or browser features are unavailable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.