Dark mode does not set `data-bs-theme`, so Bootstrap colour-mode styles never apply
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 62/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- bootstrap, javascript, scss
调研方向
导航栏已经在 nav-before-body.ejs 中自己的元素上设置了 data-bs-theme="dark",所以先从那里看这个模式。然后找到把 quarto-dark 添加到 body 的深色模式切换代码,在同一位置为 html 设置 data-bs-theme,切回时使用 light。使用 issue 中的 dark.scss 和 index.qmd 复现,切换模式,并检查 .btn-close 是否应用了 invert 滤镜。当属性跟随切换变化,并且深色背景上的关闭按钮可见时,即完成。
由索引模型根据 Issue 内容生成。
描述
I have:
- searched the issue tracker for similar issues
- installed the latest version of Quarto CLI
- formatted my issue following the Bug Reports guide
Bug description
In dark mode, Quarto marks the page with body.quarto-dark and swaps the stylesheet bundle, but it never sets data-bs-theme="dark".
Bootstrap 5.3 keys its colour-mode rules on that attribute, so Bootstrap components keep their light-mode look on a dark page.
The clearest case is .btn-close.
By default its icon is a black SVG, and Bootstrap only lightens it under [data-bs-theme="dark"].
On a dark surface such as a modal, an offcanvas or a toast, the close button is close to invisible.
This is also an accessibility problem in Quarto's own output.
In a dashboard with light and dark themes and axe: output: document, the accessibility report panel stays white in dark mode, while its close button takes the dark theme's white icon.
The close button cannot be seen.
Setting data-bs-theme="dark" by hand makes it show again.
The navbar already sets data-bs-theme="dark" on its own element in nav-before-body.ejs, but nothing sets it for the page.
Steps to reproduce
dark.scss:
/*-- scss:defaults --*/
$body-bg: #1e1e2e;
$body-color: #f0f0f0;
index.qmd:
---
title: "Dark mode and Bootstrap colour modes"
format:
html:
theme:
light: cosmo
dark: [cosmo, dark.scss]
---
```{=html}
<div class="modal-content p-3" style="max-width:320px">
<div class="d-flex justify-content-between align-items-center">
<strong>Modal header</strong>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
</div>
<div class="alert alert-warning alert-dismissible mt-3" role="alert" style="max-width:420px">
A dismissible alert.
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
```
Render, open the page, and switch to dark mode with the toggle.
Actual behavior
After the switch:
bodyhas the classquarto-dark.document.documentElement.getAttribute("data-bs-theme")isnull..btn-closekeeps the black icon (fill='%23000') with nofilter, so it is barely visible on the dark page..alert-warningkeeps its light tint,rgb(255, 227, 209).
Expected behavior
Dark mode sets data-bs-theme="dark" on <html>, and light mode sets it back to light, so Bootstrap's colour-mode rules apply.
The close button then turns light on dark surfaces.
Setting the attribute by hand in the browser after the switch gives .btn-close the filter invert(1) grayscale(1) brightness(2), which comes from the [data-bs-theme=dark] .btn-close rule already in the compiled dark bundle.
The missing attribute may also explain other dark-mode reports, such as #13173 (navbar dropdown hover) and #13195 (tooltip contrast).
Your environment
- IDE: none, rendered from the command line.
- OS: macOS 27.0.
Quarto check output
quarto check
Quarto 99.9.9
[✓] Checking environment information...
Quarto cache location: /Users/mcanouil/Library/Caches/quarto
Project: none found (single-file mode)
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.10.0: OK
Dart Sass version 1.101.0: OK
Deno version 2.7.14: OK
Typst version 0.15.1: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 99.9.9
commit: b86f98d382940bef6c65f37ea0bdfba844f19b6d
Path: /Users/mcanouil/Projects/quarto-dev/quarto-cli/package/dist/bin
[✓] Checking tools....................OK
TinyTeX: v2026.07
Chrome Headless Shell: (not installed)
VeraPDF: (not installed)
[✓] Checking LaTeX....................OK
Using: TinyTex
Path: /Users/mcanouil/Library/TinyTeX/bin/universal-darwin
Version: 2026
[✓] Checking Chrome Headless....................OK
Using: Chrome from QUARTO_CHROMIUM
Path: /Applications/Brave Browser.app/Contents/MacOS/Brave Browser
[✓] Checking basic markdown render....OK
ℹ R version 4.6.1 (2026-06-24)
! Config '~/.Rprofile' was loaded!
[✓] Checking R installation...........OK
Version: 4.6.1
Path: /Library/Frameworks/R.framework/Versions/4.6/Resources
LibPaths:
- /Users/mcanouil/Library/R/arm64/4.6/library
- /Library/Frameworks/R.framework/Versions/4.6/Resources/library
knitr: 1.51
rmarkdown: 2.31
[✓] Checking Knitr engine render......OK
[✓] Checking Python 3 installation....OK
Version: 3.13.11
Path: /Users/mcanouil/Projects/q2-tests/.venv/bin/python3
Jupyter: (None)
Jupyter is not available in this Python installation.
Install with python3 -m pip install jupyter
[✓] Checking Julia installation...
- 主要语言
- JavaScript
- 星标
- 6.1k
- 派生
- 466
- 平均合并
- 21 小时 36 分钟
- 30 天内合并 PR
- 79
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
quarto-dev/quarto-cli 的其他 Issue
-
accessibility html websites
难度 2/5 1-3 小时 新手友好度 82/100
quarto-dev/quarto-cli#15096 ·
维护者通常 1 天内回复
-
Default listing renders an empty, focusable thumbnail link for posts without an image可能已有人在做 @chanellebingham 今天认领。 未关闭accessibility bug listings
难度 2/5 1-3 小时 新手友好度 72/100
quarto-dev/quarto-cli#15066 · 1 条评论 ·
维护者通常 1 天内回复
-
Code annotation gutter keeps a grey background when code blocks have none (`code-block-bg: false`)未关闭bug code-annotation code-blocks themes
难度 2/5 1-3 小时 新手友好度 76/100
quarto-dev/quarto-cli#15059 ·
维护者通常 1 天内回复
-
bug callouts code-blocks themes
难度 1/5 1-3 小时 新手友好度 82/100
quarto-dev/quarto-cli#15058 ·
维护者通常 1 天内回复
-
diagrams-mermaid maintenance
难度 2/5 1-3 小时 新手友好度 60/100
quarto-dev/quarto-cli#15042 ·
维护者通常 1 天内回复
查看 quarto-dev/quarto-cli 的全部 Issue
相似的 Issue
-
documentation v2
难度 2/5 1-3 小时 新手友好度 78/100
modelcontextprotocol/servers#5170 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
SwiftKickMobile/skai#84 ·
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
Billionmail/BillionMail#389 ·
-
难度 1/5 1 小时以内 新手友好度 92/100
Uniswap/tokenlists-org#3331 ·
-
beginner-friendly category:finding-titles community enhancement first-timers-only good first issue hacktoberfest help wanted low hanging fruit micro-contribution type: task up-for-grabs
难度 1/5 1-3 小时 新手友好度 85/100
Berserk-hub150/skillhawk#227 · 1 条评论 ·
维护者通常 8 天内回复