4.22.3 • Published 1 year ago

@uiw/react-badge v4.22.3

Weekly downloads
228
License
MIT
Repository
github
Last release
1 year ago

Badge 标记

Buy me a coffee Open in unpkg NPM Downloads npm version

出现在按钮、图标旁的数字或状态标记。

import { Badge } from 'uiw';
// or
import Badge from '@uiw/react-badge';

基础用法

import React from 'react';
import { Badge, Row, Col, Avatar, Divider } from 'uiw';

export default function Demo() {
  return(
    <div>
      <Row gutter={20}>
        <Col fixed>
          <Badge count={9}>
            <Avatar shape="square" size="large" />
          </Badge>
        </Col>
        <Col fixed>
          <Badge count={100}>
            <Avatar shape="square" size="large" />
          </Badge>
        </Col>
        <Col>
          <Badge dot count={9}>
            <Avatar shape="square" size="large" />
          </Badge>
        </Col>
      </Row>
      <Divider />
      <Badge count={12}>
        评论
      </Badge>
    </div>
  );
}

封顶数字

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

import React from 'react';
import { Badge, Row, Col, Avatar, Divider } from 'uiw';

const styl={ marginRight: 20, display: 'inline-block' }

export default function Demo() {
  return (
    <Row gutter={20}>
      <Col fixed>
        <Badge count={99}>
          <Avatar shape="square" size="large" />
        </Badge>
      </Col>
      <Col fixed>
        <Badge count={100} style={{ backgroundColor: '#87d068' }}>
          <Avatar shape="square" size="large" />
        </Badge>
      </Col>
      <Col fixed>
        <Badge count={99} max={10} style={styl}>
          <Avatar shape="square" size="large" />
        </Badge>
      </Col>
      <Col fixed>
        <Badge count={100} max={999} style={styl}>
          <Avatar shape="square" size="large" />
        </Badge>
      </Col>
      <Col fixed>
        <Badge count={100} max={999} style={styl}>
          <Avatar shape="square" size="large" />
        </Badge>
      </Col>
    </Row>
  )
}

独立使用

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

import React from 'react';
import { Badge, Row, Col } from 'uiw';

export default function Demo() {
  return (
    <Row gutter={10}>
      <Col fixed>
        <Badge count={25} />
      </Col>
      <Col fixed>
        <Badge count={4} style={{ backgroundColor: '#fff', color: '#f04134', boxShadow: 'rgb(217, 217, 217) 0px 0px 0px 1px inset' }} /> 
      </Col>
      <Col fixed>
        <Badge count={109} style={{ backgroundColor: '#87d068' }} /> 
      </Col>
    </Row>
  )
}

小红点

以红点的形式标注需要关注的内容。

import React from 'react';
import { Badge, Icon } from 'uiw';

export default function Demo() {
  return (
    <div>
      <Badge dot style={{ marginRight: 10 }}>
        数据查询
      </Badge>
      <Badge dot count={4}>
        <Icon type='mail-o' />
      </Badge>
    </div>
  );
}

状态点

用于表示状态的小圆点,可以设置 processing={true} 让状态点,显示动画效果。

import React from 'react';
import { Badge } from 'uiw';

export default function Demo() {
  return (
    <div>
      <Badge color="#28a745" />
      <Badge color="#008EF0" />
      <Badge color="#dc3545" />
      <Badge color="#393E48" />
      <Badge color="#ffc107" />
      <Badge color="#f95c2b" />
      <Badge color="#dc3545"/>
      <Badge color="#c2c2c2"/>
      <Badge color="#F95C2B" processing />
      <br />
      <Badge color="#28a745">Success</Badge>
      <br />
      <Badge color="#dc3545">Error</Badge>
      <br />
      <Badge color="#c2c2c2">Default</Badge>
      <br />
      <Badge color="#008EF0" processing>Processing</Badge>
      <br />
      <Badge color="#ffc107">Warning</Badge>
      <Badge color="#ffc107" processing>Warning</Badge>
    </div>
  );
}

API

参数说明类型默认值
style默认设置计数圆点样式,设置 colorstyle 设置外层节点样式Object-
count展示的数字Number-
max最大值,超过最大值会显示 '{max}+'Number99
dot不展示数字,只有一个小红点Booleanfalse
processing不展示数字,只有一个小红点Boolean-
color设置 Badge 为状态点的颜色String-
4.22.0

1 year ago

4.22.1

1 year ago

4.22.2

1 year ago

4.22.3

1 year ago

4.21.26

2 years ago

4.21.25

2 years ago

4.21.28

2 years ago

4.21.27

2 years ago

5.0.0-bate.2.1

2 years ago

5.0.0-bate.2.0

2 years ago

4.21.24

2 years ago

5.0.0-bate-19

2 years ago

4.21.22

2 years ago

4.21.21

2 years ago

4.21.23

2 years ago

5.0.0-bate-18

2 years ago

5.0.0-bate-14

2 years ago

5.0.0-bate-17

2 years ago

5.0.0-bate-10

2 years ago

5.0.0-bate-11

2 years ago

5.0.0-bate-12

2 years ago

5.0.0-bate-9

2 years ago

5.0.0-bate-7

2 years ago

5.0.0-bate-8

2 years ago

5.0.0-bate-6

2 years ago

4.21.20

2 years ago

4.21.19

2 years ago

4.21.18

2 years ago

4.21.15

2 years ago

4.21.17

2 years ago

4.21.16

2 years ago

5.0.0-bate-5

2 years ago

5.0.0-bate-3

2 years ago

5.0.0-bate-4

2 years ago

5.0.0-bate-1

2 years ago

5.0.0-bate-2

2 years ago

5.0.0-bate-0

2 years ago

4.21.13

3 years ago

4.21.14

3 years ago

4.21.11

3 years ago

4.21.12

3 years ago

4.21.10

3 years ago

4.21.1

3 years ago

4.21.2

3 years ago

4.21.3

3 years ago

4.21.4

3 years ago

4.21.0

3 years ago

4.20.0

3 years ago

4.21.9

3 years ago

4.21.5

3 years ago

4.21.6

3 years ago

4.21.7

3 years ago

4.21.8

3 years ago

4.18.1

3 years ago

4.18.0

3 years ago

4.17.0

3 years ago

4.16.0

3 years ago

4.16.1

3 years ago

4.16.2

3 years ago

4.19.0

3 years ago

4.15.1

3 years ago

4.14.1

3 years ago

4.14.2

3 years ago

4.14.0

3 years ago

4.13.7

3 years ago

4.13.8

3 years ago

4.13.9

3 years ago

4.13.11

3 years ago

4.13.12

3 years ago

4.13.10

3 years ago

4.15.0

3 years ago

4.10.5

3 years ago

4.10.6

3 years ago

4.10.7

3 years ago

4.9.9

3 years ago

4.10.1

3 years ago

4.10.2

3 years ago

4.10.3

3 years ago

4.10.4

3 years ago

4.10.0

3 years ago

4.13.6

3 years ago

4.13.2

3 years ago

4.13.3

3 years ago

4.13.4

3 years ago

4.13.5

3 years ago

4.13.0

3 years ago

4.13.1

3 years ago

4.12.0

3 years ago

4.12.1

3 years ago

4.12.2

3 years ago

4.11.4

3 years ago

4.11.5

3 years ago

4.11.6

3 years ago

4.9.11

3 years ago

4.9.10

3 years ago

4.11.0

3 years ago

4.11.1

3 years ago

4.11.2

3 years ago

4.11.3

3 years ago

4.9.7

3 years ago

4.9.6

3 years ago

4.9.4

3 years ago

4.9.3

3 years ago

4.9.2

3 years ago

4.9.1

4 years ago

4.9.0

4 years ago

4.8.9

4 years ago

4.8.8

4 years ago

4.7.16

4 years ago

4.8.5

4 years ago

4.8.4

4 years ago

4.8.7

4 years ago

4.8.6

4 years ago

4.8.1

4 years ago

4.8.0

4 years ago

4.8.3

4 years ago

4.8.2

4 years ago

4.7.13

4 years ago

4.7.14

4 years ago

4.7.15

4 years ago

4.7.12

4 years ago

4.7.10

4 years ago

4.7.11

4 years ago

4.7.9

4 years ago

4.7.8

4 years ago

4.7.7

4 years ago

4.7.6

4 years ago

4.7.5

4 years ago

4.7.4

4 years ago

4.7.3

4 years ago

4.7.2

4 years ago

4.7.0

4 years ago

4.6.19

4 years ago

4.6.18

4 years ago

4.6.15

4 years ago

4.6.16

4 years ago

4.6.17

4 years ago

4.6.14

4 years ago

4.6.13

4 years ago

4.6.12

4 years ago

4.6.11

4 years ago

4.6.10

4 years ago

4.6.9

4 years ago

4.6.8

4 years ago

4.6.7

4 years ago

4.6.6

4 years ago

4.6.3

5 years ago

4.6.4

5 years ago

4.6.2

5 years ago

4.6.1

5 years ago

4.6.0

5 years ago

4.5.0

5 years ago

4.4.1

5 years ago

4.4.0

5 years ago

4.3.1

5 years ago

4.2.3

5 years ago

4.2.5

5 years ago

4.3.0

5 years ago

4.2.14

5 years ago

4.2.1

5 years ago

4.1.2

5 years ago

4.1.1

5 years ago

4.1.0

5 years ago

4.0.0

5 years ago

4.0.0-alpha.8

5 years ago

4.0.0-alpha.7

5 years ago

4.0.0-alpha.6

5 years ago

4.0.0-alpha.3

5 years ago

4.0.0-alpha.2

5 years ago

4.0.0-alpha.1

5 years ago

4.0.0-alpha.0

5 years ago