--- order: 5 version: 4.17.0 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. ```tsx import { ClockCircleOutlined, DownOutlined, MailOutlined, SettingOutlined, } from '@ant-design/icons'; import type { SpaceProps, TreeSelectProps } from 'antd'; import { Alert, Button, Card, Checkbox, Col, ConfigProvider, DatePicker, Divider, Dropdown, Form, Input, InputNumber, Mentions, Menu, Pagination, Progress, Radio, Row, Select, Slider, Space, Spin, Steps, Switch, Table, Tabs, Tag, Timeline, TimePicker, Transfer, Tree, TreeSelect, Typography, } from 'antd'; import React, { useState } from 'react'; import { SketchPicker } from 'react-color'; const SplitSpace: React.FC = props => ( } size={4} {...props} /> ); const menuItems = [ { key: 'mail', icon: , label: 'Mail', }, { key: 'SubMenu', icon: , label: 'Submenu', children: [ { type: 'group', label: 'Item 1', children: [ { key: 'setting:1', label: 'Option 1', }, { key: 'setting:2', label: 'Option 2', }, ], }, ], }, ]; 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: 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 ( item.title} /> ); }; const App: React.FC = () => { const [color, setColor] = useState({ primaryColor: '#1890ff', errorColor: '#ff4d4f', warningColor: '#faad14', successColor: '#52c41a', infoColor: '#1890ff', }); const onColorChange = (nextColor: Partial) => { const mergedNextColor = { ...color, ...nextColor, }; setColor(mergedNextColor); ConfigProvider.config({ theme: mergedNextColor, }); }; return ( {/* Primary Color */} { onColorChange({ primaryColor: hex, }); }} /> var(`--ant-primary-color`) {/* Error Color */} { onColorChange({ errorColor: hex, }); }} /> var(`--ant-error-color`) {/* Warning Color */} { onColorChange({ warningColor: hex, }); }} /> var(`--ant-warning-color`) {/* Success Color */} { onColorChange({ successColor: hex, }); }} /> var(`--ant-success-color`) {/* Info Color */} { onColorChange({ infoColor: hex, }); }} /> var(`--ant-info-color`) } style={{ width: '100%' }} size={0}> {/* Primary Button */} {/* Danger Button */} {/* Ghost Button */} {/* Typography */} Text (success) Text(warning) Text(danger) Link Text {/* Dropdown */} } > e.preventDefault()}> Hover me {/* Spin */} {/* Menu - horizontal */} {/* Menu - vertical */} {/* Pagination */} {/* Steps */} {/* Steps - dot */} {/* Form - Input */}
{/* Form - Select */}