从检查源代码来看,bootstrap.build/app使用的是Bootstrap 4,而不是Bootstrap 5。颜色对比逻辑已从Bootstrap 4改变为Bootstrap 5,并且颜色对比阈值也大有不同。
Bootstrap 4使用YIQ颜色空间...
// The yiq lightness value that determines when the lightness of color changes from "dark" to "light". Acceptable values are between 0 and 255.
$yiq-contrasted-threshold: 150 !default
Bootstrap 5 使用 WCAG 2.0 算法
// The contrast ratio to reach against white, to determine if color changes from "light" to "dark". Acceptable values for WCAG 2.0 are 3, 4.5 and 7.
// See https://www.w3.org/TR/WCAG20/
$min-contrast-ratio: 4.5 !default
比较两个版本和颜色逻辑:
使用4.x颜色对比逻辑将$primary更改为#e84c22 - 结果是浅色文本颜色
使用5.x颜色对比逻辑将$primary更改为#e84c22 - 结果是暗色文本颜色
所以,您的Bootstrap 5 React SASS自定义正在按预期工作,并且bootstrap.build仍在使用旧的4.x。
要在Bootstrap 5 (with React)中获得浅色文本颜色,则可以更改$min-contrast-ratio
变量的默认值...
例如,将$min-contrast-ratio从4.5更改为3会使文本颜色与#e84c22
形成对比并呈浅色:
$min-contrast-ratio: 3;
$orange: #e84c22;
$primary: $orange;
@import "~bootstrap/scss/bootstrap.scss";
https://codeply.com/p/Z1tOoBclnH
如Bootstrap 5 SASS所解释的,“WCAG 2.0的可接受值为3、4.5和7”。另外,您可以使用我相关答案中描述的5.x解决方案。如果您正在寻找进一步自定义Bootstrap,themestr.app(注:我是创作者)已更新至Bootstrap 5.x。
button-outline-variant
和选择器。 - Apostolos