mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 01:19:45 +08:00
06dff86287
* fix: Badge count style when customize color close #31590 close #31591 * add demo for debug * update badge demos * create ribbon.test.tsx
41 lines
844 B
Markdown
41 lines
844 B
Markdown
---
|
|
order: 1
|
|
title:
|
|
zh-CN: 独立使用
|
|
en-US: Standalone
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
不包裹任何元素即是独立使用,可自定样式展现。
|
|
|
|
> 在右上角的 badge 则限定为红色。
|
|
|
|
## en-US
|
|
|
|
Used in standalone when children is empty.
|
|
|
|
```jsx
|
|
import { Badge, Space, Switch } from 'antd';
|
|
import { ClockCircleOutlined } from '@ant-design/icons';
|
|
|
|
const Demo = () => {
|
|
const [show, setShow] = React.useState(true);
|
|
|
|
return (
|
|
<Space>
|
|
<Switch checked={show} onChange={() => setShow(!show)} />
|
|
<Badge count={show ? 25 : 0} />
|
|
<Badge count={show ? <ClockCircleOutlined style={{ color: '#f5222d' }} /> : 0} />
|
|
<Badge
|
|
className="site-badge-count-109"
|
|
count={show ? 109 : 0}
|
|
style={{ backgroundColor: '#52c41a' }}
|
|
/>
|
|
</Space>
|
|
);
|
|
};
|
|
|
|
ReactDOM.render(<Demo />, mountNode);
|
|
```
|