颜色模式
Bootstrap v5.3 现在支持暗模式等颜色模式。颜色模式可以在 <html>
元素上全局切换,或者使用 data-bs-theme
属性在特定组件和元素上切换。
示例
结果
正在加载...
实时编辑器
import Dropdown from 'react-bootstrap/Dropdown';import DropdownButton from 'react-bootstrap/DropdownButton';function Example() {return (<Stack direction="horizontal" gap={3}><DropdownButtonid="dropdown-button-dark-example2"variant="secondary"title="Light dropdown"className="mt-2"data-bs-theme="light"><Dropdown.Item href="#/action-1" active>Action</Dropdown.Item><Dropdown.Item href="#/action-2">Another action</Dropdown.Item><Dropdown.Item href="#/action-3">Something else</Dropdown.Item><Dropdown.Divider /><Dropdown.Item href="#/action-4">Separated link</Dropdown.Item></DropdownButton><DropdownButtonid="dropdown-button-dark-example2"variant="secondary"title="Dark dropdown"className="mt-2"data-bs-theme="dark"><Dropdown.Item href="#/action-1" active>Action</Dropdown.Item><Dropdown.Item href="#/action-2">Another action</Dropdown.Item><Dropdown.Item href="#/action-3">Something else</Dropdown.Item><Dropdown.Divider /><Dropdown.Item href="#/action-4">Separated link</Dropdown.Item></DropdownButton></Stack>);}export default ColorMode;
自定义
有关颜色模式工作原理或如何自定义颜色的更多信息,请查看 Bootstrap 颜色模式文档。