bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Color theme setting ignored by the menu of a <select> element in mobile browsers

Open andreimilto opened this issue 1 year ago • 1 comments

Prerequisites

Describe the issue

I have a <select> element. And I've set the color theme on the <html> element using data-bs-theme attribute.

In desktop browsers (Chrome, Edge, Safari, Firefox) the <select> is displayed correctly: ✅dark theme - dark <select>'s menu ✅light theme - light <select>'s menu

DesktopDarkDesktopLight

In mobile browsers (Chrome, Safari, Firefox) the menu of the <select> element seems to always be drawn according to the system's color theme, completely ignoring the data-bs-theme setting: ✅dark theme - dark <select>'s menu ❌light theme - dark <select>'s menu

MobileDarkMobileLight

I'm wondering if it can be fixed, or if it's the limitation of the browsers that cannot be overcome.

If latter, then it would be useful to have the documentation on color modes stating this limitation - save developers the trouble of figuring this out and preventing situations similar to the described one from happening in the first place🙌

Reduced test cases

  1. Add <select> element:
<select class="form-select" aria-label="Default select example">
  <option selected>Open this select menu</option>
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three</option>
</select>
  1. Set the color theme to dark and check how <select>'s menu is displayed in desktop and mobile browsers:
<html data-bs-theme="dark">
  1. Set the color theme to light and check how <select>'s menu is displayed in desktop and mobile browsers:
<html data-bs-theme="light">

What operating system(s) are you seeing the problem on?

Android, iOS

What browser(s) are you seeing the problem on?

Chrome, Safari, Firefox

What version of Bootstrap are you using?

v5.3.3

andreimilto avatar Sep 05 '24 15:09 andreimilto

Hi @andreimilto , changing the color of a

MohamadSalman11 avatar Oct 05 '24 09:10 MohamadSalman11

Correct these elements aren't great at custom styles. New select element is on the horizon though that could help, unsure about mobile for those though.

mdo avatar May 05 '25 03:05 mdo