2020-11-20 13:41:58 +08:00
|
|
|
---
|
|
|
|
order: 999
|
|
|
|
title:
|
|
|
|
zh-CN: 自定义 label & wrapper 样式
|
|
|
|
en-US: Customize label & wrapper style
|
|
|
|
debug: true
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
自定义 label & wrapper 样式
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Customize label & wrapper style
|
|
|
|
|
|
|
|
```tsx
|
2022-05-19 09:46:26 +08:00
|
|
|
import React, { useState } from 'react';
|
2021-03-30 17:38:50 +08:00
|
|
|
import { Descriptions, Divider, Switch, Radio } from 'antd';
|
2020-11-20 13:41:58 +08:00
|
|
|
|
|
|
|
const labelStyle: React.CSSProperties = { background: 'red' };
|
|
|
|
const contentStyle: React.CSSProperties = { background: 'green' };
|
|
|
|
|
2021-03-30 17:38:50 +08:00
|
|
|
type LayoutType = 'horizontal' | 'vertical' | undefined;
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => {
|
|
|
|
const [border, setBorder] = useState(true);
|
|
|
|
const [layout, setLayout] = useState('horizontal' as LayoutType);
|
2020-11-20 13:41:58 +08:00
|
|
|
|
2020-12-30 17:08:43 +08:00
|
|
|
return (
|
2021-03-30 17:38:50 +08:00
|
|
|
<>
|
|
|
|
<Switch
|
|
|
|
checkedChildren="Border"
|
|
|
|
unCheckedChildren="No Border"
|
|
|
|
checked={border}
|
|
|
|
onChange={e => setBorder(e)}
|
|
|
|
/>
|
|
|
|
<Divider />
|
|
|
|
<Radio.Group onChange={e => setLayout(e.target.value)} value={layout}>
|
|
|
|
<Radio value="horizontal">horizontal</Radio>
|
|
|
|
<Radio value="vertical">vertical</Radio>
|
|
|
|
</Radio.Group>
|
|
|
|
<Divider />
|
|
|
|
<Descriptions title="User Info" bordered={border} layout={layout}>
|
|
|
|
<Descriptions.Item label="Product" labelStyle={labelStyle} contentStyle={contentStyle}>
|
|
|
|
Cloud Database
|
|
|
|
</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Billing Mode">Prepaid</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Automatic Renewal">YES</Descriptions.Item>
|
|
|
|
</Descriptions>
|
|
|
|
<Divider />
|
|
|
|
<Descriptions
|
|
|
|
title="Root style"
|
|
|
|
labelStyle={labelStyle}
|
|
|
|
contentStyle={contentStyle}
|
|
|
|
bordered={border}
|
|
|
|
layout={layout}
|
2020-12-30 17:08:43 +08:00
|
|
|
>
|
2021-03-30 17:38:50 +08:00
|
|
|
<Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Billing Mode">Prepaid</Descriptions.Item>
|
|
|
|
<Descriptions.Item
|
|
|
|
label="Automatic Renewal"
|
|
|
|
labelStyle={{ color: 'orange' }}
|
|
|
|
contentStyle={{ color: 'blue' }}
|
|
|
|
>
|
|
|
|
YES
|
|
|
|
</Descriptions.Item>
|
|
|
|
</Descriptions>
|
|
|
|
</>
|
2020-12-30 17:08:43 +08:00
|
|
|
);
|
2021-03-30 17:38:50 +08:00
|
|
|
};
|
2020-12-30 17:08:43 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
export default App;
|
2020-11-20 13:41:58 +08:00
|
|
|
```
|