ant-design/components/badge/demo/no-wrapper.md
Wuxh 647a03af09
fix(badge): fix the color cannot be customized when count is 0 (#39062)
* test(badge): add case

* fix(badge): fix the color cannot be customized when count is 0

* test(badge): update snapshots

* docs(badge): update demo

* test: update case

* test(badge): update snapshots
2022-11-29 09:49:18 +08:00

933 B

order title
1
zh-CN en-US
独立使用 Standalone

zh-CN

不包裹任何元素即是独立使用,可自定样式展现。

在右上角的 badge 则限定为红色。

en-US

Used in standalone when children is empty.

import { ClockCircleOutlined } from '@ant-design/icons';
import { Badge, Space, Switch } from 'antd';
import React, { useState } from 'react';

const App: React.FC = () => {
  const [show, setShow] = useState(true);

  return (
    <Space>
      <Switch checked={show} onChange={() => setShow(!show)} />
      <Badge count={show ? 11 : 0} showZero color="#faad14" />
      <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>
  );
};

export default App;