You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
634 lines
19 KiB
634 lines
19 KiB
3 years ago
|
---
|
||
|
order: 5
|
||
|
title:
|
||
|
zh-CN: 全局样式
|
||
|
en-US: Global Theme
|
||
|
---
|
||
|
|
||
|
## zh-CN
|
||
|
|
||
|
通过 css variable 修改全局主题色(你可以切换到组件页面查看更详细的样式展示),不支持 IE。自动生成的变量可能会根据设计调整,请勿直接依赖。详细配置请[点击查看](/docs/react/customize-theme-variable)。
|
||
|
|
||
|
## en-US
|
||
|
|
||
|
Modify global theme color by css variable which IE not support. Css variable depends on the design, it may adjust so please do not directly use it. You can go to other components page for more detail style. [Check this](/docs/react/customize-theme-variable) to view detail.
|
||
|
|
||
|
```jsx
|
||
|
import { SketchPicker } from 'react-color';
|
||
|
import React, { useState } from 'react';
|
||
|
import {
|
||
|
DownOutlined,
|
||
|
MailOutlined,
|
||
|
SettingOutlined,
|
||
|
ClockCircleOutlined,
|
||
|
} from '@ant-design/icons';
|
||
|
import {
|
||
|
ConfigProvider,
|
||
|
Tag,
|
||
|
Mentions,
|
||
|
Steps,
|
||
|
Button,
|
||
|
Radio,
|
||
|
Space,
|
||
|
Form,
|
||
|
Input,
|
||
|
Row,
|
||
|
Col,
|
||
|
Typography,
|
||
|
Menu,
|
||
|
Dropdown,
|
||
|
Divider,
|
||
|
Pagination,
|
||
|
Select,
|
||
|
Checkbox,
|
||
|
DatePicker,
|
||
|
TimePicker,
|
||
|
InputNumber,
|
||
|
Slider,
|
||
|
Switch,
|
||
|
TreeSelect,
|
||
|
Card,
|
||
|
Table,
|
||
|
Tabs,
|
||
|
Timeline,
|
||
|
Tree,
|
||
|
Alert,
|
||
|
Progress,
|
||
|
Spin,
|
||
|
Transfer,
|
||
|
} from 'antd';
|
||
|
|
||
|
const SplitSpace = props => <Space split={<Divider type="vertical" />} size={4} {...props} />;
|
||
|
|
||
|
const inputProps = {
|
||
|
style: { width: 128 },
|
||
|
};
|
||
|
|
||
|
const selectProps = {
|
||
|
...inputProps,
|
||
|
options: [
|
||
|
{ value: 'light', label: 'Light' },
|
||
|
{ value: 'bamboo', label: 'Bamboo' },
|
||
|
{ value: 'little', label: 'Little' },
|
||
|
],
|
||
|
};
|
||
|
|
||
|
const treeData = [
|
||
|
{
|
||
|
value: 'little',
|
||
|
key: 'little',
|
||
|
label: 'Little',
|
||
|
title: 'Little',
|
||
|
children: [
|
||
|
{ value: 'light', key: 'light', label: 'Light', title: 'Light' },
|
||
|
{ value: 'bamboo', key: 'bamboo', label: 'Bamboo', title: 'Bamboo' },
|
||
|
],
|
||
|
},
|
||
|
];
|
||
|
|
||
|
const treeSelectProps = {
|
||
|
...inputProps,
|
||
|
treeCheckable: true,
|
||
|
maxTagCount: 'responsive',
|
||
|
treeData,
|
||
|
};
|
||
|
|
||
|
const carTabListNoTitle = [
|
||
|
{
|
||
|
key: 'article',
|
||
|
tab: 'article',
|
||
|
},
|
||
|
{
|
||
|
key: 'app',
|
||
|
tab: 'app',
|
||
|
},
|
||
|
{
|
||
|
key: 'project',
|
||
|
tab: 'project',
|
||
|
},
|
||
|
];
|
||
|
|
||
|
const MyTransfer = () => {
|
||
|
const mockData = [];
|
||
|
for (let i = 0; i < 20; i++) {
|
||
|
mockData.push({
|
||
|
key: i.toString(),
|
||
|
title: `content${i + 1}`,
|
||
|
description: `description of content${i + 1}`,
|
||
|
});
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<Transfer
|
||
|
dataSource={mockData}
|
||
|
targetKeys={['18']}
|
||
|
selectedKeys={['3']}
|
||
|
render={item => item.title}
|
||
|
/>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
const FormSizeDemo = () => {
|
||
|
const [color, setColor] = useState({
|
||
|
primaryColor: '#1890ff',
|
||
|
errorColor: '#ff4d4f',
|
||
|
warningColor: '#faad14',
|
||
|
successColor: '#52c41a',
|
||
|
infoColor: '#1890ff',
|
||
|
});
|
||
|
|
||
|
function onColorChange(nextColor) {
|
||
|
const mergedNextColor = {
|
||
|
...color,
|
||
|
...nextColor,
|
||
|
};
|
||
|
setColor(mergedNextColor);
|
||
|
ConfigProvider.config({
|
||
|
theme: mergedNextColor,
|
||
|
});
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<Row gutter={16} wrap={false}>
|
||
|
<Col flex="none">
|
||
|
<Space direction="vertical" align="center">
|
||
|
{/* Primary Color */}
|
||
|
<SketchPicker
|
||
|
presetColors={['#1890ff', '#25b864', '#ff6f00']}
|
||
|
color={color.primaryColor}
|
||
|
onChange={({ hex }) => {
|
||
|
onColorChange({
|
||
|
primaryColor: hex,
|
||
|
});
|
||
|
}}
|
||
|
/>
|
||
|
|
||
|
<span style={{ color: 'var(--ant-primary-color)' }}>var(`--ant-primary-color`)</span>
|
||
|
|
||
|
{/* Error Color */}
|
||
|
<SketchPicker
|
||
|
presetColors={['#ff4d4f']}
|
||
|
color={color.errorColor}
|
||
|
onChange={({ hex }) => {
|
||
|
onColorChange({
|
||
|
errorColor: hex,
|
||
|
});
|
||
|
}}
|
||
|
/>
|
||
|
|
||
|
<span style={{ color: 'var(--ant-error-color)' }}>var(`--ant-error-color`)</span>
|
||
|
|
||
|
{/* Warning Color */}
|
||
|
<SketchPicker
|
||
|
presetColors={['#faad14']}
|
||
|
color={color.warningColor}
|
||
|
onChange={({ hex }) => {
|
||
< |