--- localeCode: en-US order: 71 category: Other title: ConfigProvider icon: doc-configprovider dir: column brief: Provide a unified global configuration for components. --- ## Demos ### How to import ```jsx import import { ConfigProvider } from '@douyinfe/semi-ui'; ``` ### Basic Usage By passing in the timeZone parameter, users can configure the time zone for the time components: ```jsx live=true dir="column" hideInDSM import React, { useMemo, useState } from 'react'; import { ConfigProvider, Select, DatePicker, TimePicker } from '@douyinfe/semi-ui'; function Demo(props = {}) { const [timeZone, setTimeZone] = useState('GMT+08:00'); const defaultTimestamp = 1581599305265; const gmtList = useMemo(() => { const list = []; for (let hourOffset = -11; hourOffset <= 14 ; hourOffset++) { const prefix = hourOffset >= 0 ? '+' : '-'; const hOffset = Math.abs(parseInt(hourOffset, 10)); list.push(`GMT${prefix}${String(hOffset).padStart(2, '0')}:00`); } return list; }, []); return (
Select Time Zone:


console.log('DatePicker changed: ', date, dateString)} />

console.log('DatePicker changed: ', date, dateString)} />
); } ``` ### RTL/LTR Global configuration `direction` can change the text direction of components。`rtl` means right to left (similar to Hebrew or Arabic), `ltr` means left to right (similar to most languages such as English) Special components: - Command call of Modal, Notification and Toast needs to be passed to 'direction' through prop. - If you want to internationalize the directional icon, you need to handle it on your own. We think RTL for icon will make it difficult to understand and maintain. Semi has adapted the icons in other components. - Table fixed columns or headers, tree data, and virtualized tables do not support RTL at the moment, Slider does not support RTL at the moment. ```jsx live=true dir="column" hideInDSM import React, { useState } from 'react'; import { ConfigProvider, ButtonGroup, Button, Row, Col, Notification, DatePicker, TimePicker, Timeline, Popover, Tag, Tooltip, Badge, Avatar, Steps, Pagination, Modal, Breadcrumb, Rating, Nav, Spin, Cascader, Radio, Select, Input, Typography, TextArea, Checkbox, Switch } from '@douyinfe/semi-ui'; import { IconVigoLogo, IconEdit, IconCamera, IconList, IconSidebar, IconChevronDown } from '@douyinfe/semi-icons'; import en_GB from '@douyinfe/semi-ui/locale/source/en_GB'; function Demo(props = {}) { const { Option } = Select; const [direction, setDirection] = useState(); const flexStyle = {display: 'flex', marginBottom: 32, flexWrap: 'wrap'}; const titleStyle = {margin: '50px 0 16px 0'}; const rowStyle = {margin: '16px 10px'}; const badgeStyle = { width: '42px', height: '42px', borderRadius: '4px', display: 'inline-block', }; const tagStyle = {marginRight: 8, marginBottom: 8}; const buttonStyle = {...tagStyle}; const opts = { title: 'Hi,Bytedance', content: 'ies dance dance dance', duration: 3, direction, }; const treeData = [ { label: 'Zhejiang', value: 'zhejiang', children: [ { label: 'Hangzhou', value: 'hangzhou', children: [ { label: 'Xihu', value: 'xihu', }, { label: 'Xianhan', value: 'xiaoshan', }, { label: 'Lin’an', value: 'linan', }, ], }, { label: 'Ningbo', value: 'ningbo', children: [ { label: 'Haishu', value: 'haishu', }, { label: 'Jiangbei', value: 'jiangbei', } ] }, ], } ]; return (

Buttons



Input







Suffix} showClear>