Fix flicker on page load when color mode is set to dark #9316

Closed
opened 2025-12-29 20:48:20 +01:00 by adam · 1 comment
Owner

Originally created by @jeremystretch on GitHub (Mar 4, 2024).

Originally assigned to: @jeremystretch on GitHub.

Deployment Type

NetBox Cloud

NetBox Version

v4.0

Python Version

3.11

Steps to Reproduce

  1. Open the NetBox UI as an anonymous user (not logged in)
  2. Click the toggle button at top right to switch to dark mode
  3. Navigate among pages several times

Expected Behavior

The application of the dark mode theme should persistent without interruption between page loads.

Observed Behavior

A "flicker" is sometimes visible when a new page loads, as the DOM is initially rendered in light mode and then switched to dark mode. This occurs because the user's preferred theme is being read from local storage after the DOM has finished loading.

Note that this does not occur when authenticated as a known user with the color preference set to dark mode. (In this case, data-bs-theme="dark" is set on each page's <body> tag directly in the page source.)

Originally created by @jeremystretch on GitHub (Mar 4, 2024). Originally assigned to: @jeremystretch on GitHub. ### Deployment Type NetBox Cloud ### NetBox Version v4.0 ### Python Version 3.11 ### Steps to Reproduce 1. Open the NetBox UI as an anonymous user (not logged in) 2. Click the toggle button at top right to switch to dark mode 3. Navigate among pages several times ### Expected Behavior The application of the dark mode theme should persistent without interruption between page loads. ### Observed Behavior A "flicker" is sometimes visible when a new page loads, as the DOM is initially rendered in light mode and then switched to dark mode. This occurs because the user's preferred theme is being read from local storage _after_ the DOM has finished loading. Note that this does _not_ occur when authenticated as a known user with the color preference set to dark mode. (In this case, `data-bs-theme="dark"` is set on each page's `<body>` tag directly in the page source.)
adam added the type: bugstatus: acceptedtopic: UI/UXseverity: low labels 2025-12-29 20:48:20 +01:00
adam closed this issue 2025-12-29 20:48:20 +01:00
Author
Owner

@samumatic commented on GitHub (May 7, 2024):

This only works in Chrome, in Firefox the theme resets after a reload.

@samumatic commented on GitHub (May 7, 2024): This only works in Chrome, in Firefox the theme resets after a reload.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9316