本示例是AntDesign Blazor
的入门示例,在学习的同时分享出来,以供新手参考。
示例代码仓库:https://gitee.com/known/BlazorDemo
1)双击打开MainLayout.razor
文件,在header
区域添加Switch
组件及其事件来切换暗黑模式
light
Switch
dark
2)点击运行按钮查看页面效果
color
和background
属性的样式类,下面以RangePicker
组件为例,找到样式类为.ant-picker
,切换暗黑模式时,覆盖该类的color
,其他组件查找方法相同1)双击打开app.css
文件,覆写dark
模式下AntDesign
组件的样式类
color
和background
的颜色.dark .xxx {}
级联选择方式来覆写样式.dark,
.dark .ant-picker,
.dark .ant-table-thead > tr > th,
.dark .ant-table-tbody > tr > td,
.dark .ant-pagination-item,
.dark .ant-pagination-options-quick-jumper input,
.dark .ant-pagination-prev .ant-pagination-item-link,
.dark .ant-pagination-next .ant-pagination-item-link,
.dark .ant-select:not(.ant-select-customize-input) .ant-select-selector {
background-color:#202020;color:#d8d8d8;
}
.dark .ant-picker,
.dark .ant-table-thead > tr > th,
.dark .ant-table-tbody > tr > td {
border-color:rgba(253, 253, 253, 0.12);
}
.dark h1,
.dark .ant-select-arrow,
.dark .ant-picker-input > input,
.dark .ant-picker-separator,
.dark .ant-picker-suffix,
.dark .ant-picker-clear,
.dark .ant-pagination,
.dark .ant-pagination-jump-prev .ant-pagination-item-container .ant-pagination-item-ellipsis,
.dark .ant-pagination-jump-next .ant-pagination-item-container .ant-pagination-item-ellipsis {
color:#d8d8d8;
}