简体   繁体   中英

Setting 'badge' to 'panel' in framework ui `ant design`

Is it possible to set Badge to Panel next to 'Info' in ant design ?

在此处输入图片说明

Code

<div>
  <Collapse>
    <Panel header="Info" key="1">
      <Badge
        count={4}
        style={{
          backgroundColor: "#fff",
          color: "#999",
          boxShadow: "0 0 0 1px #d9d9d9 inset"
        }}
      />
    </Panel>
  </Collapse>
</div>

Yes, Collapse.Panel - header prop accepts ReactNode so you can render whatever you want, for example , using antd Grid :

在此处输入图片说明

export default function App() {
  return (
    <Collapse>
      <Collapse.Panel
        header={
          <Row type="flex" gutter={10}>
            <Col>Info</Col>
            <Col>
              <Badge
                count={4}
                style={{
                  backgroundColor: '#fff',
                  color: '#999',
                  boxShadow: '0 0 0 1px #d9d9d9 inset'
                }}
              />
            </Col>
          </Row>
        }
        key="1"
      />
    </Collapse>
  );
}

编辑 styled-antd-react-starter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM