Badge徽标 - 图1

Badge 徽标

基本用法

  1. import { Badge, Cell } from 'zarm';
  2. ReactDOM.render(
  3. <>
  4. <Cell hasArrow title="点状" description={<Badge />} onClick={() => {}} />
  5. <Cell hasArrow title="直角" description={<Badge shape="rect" text="免费" />} onClick={() => {}} />
  6. <Cell hasArrow title="圆角" description={<Badge shape="radius" text="new" />} onClick={() => {}} />
  7. <Cell hasArrow title="椭圆角" description={<Badge shape="round" text="999+" />} onClick={() => {}} />
  8. <Cell hasArrow title="圆形" description={<Badge shape="circle" text={3} />} onClick={() => {}} />
  9. <Cell hasArrow title="叶形" description={<Badge shape="leaf" text="新品" />} onClick={() => {}} />
  10. </>
  11. , mountNode);

多主题

  1. import { Badge } from 'zarm';
  2. ReactDOM.render(
  3. <div className="custom-panel">
  4. <div className="box">
  5. <Badge theme="primary" />
  6. </div>
  7. <div className="box">
  8. <Badge theme="success" />
  9. </div>
  10. <div className="box">
  11. <Badge theme="warning" />
  12. </div>
  13. <div className="box">
  14. <Badge theme="danger" />
  15. </div>
  16. <div className="box">
  17. <Badge shape="round" text="999+" theme="primary" />
  18. </div>
  19. <div className="box">
  20. <Badge shape="round" text="999+" theme="success" />
  21. </div>
  22. <div className="box">
  23. <Badge shape="round" text="999+" theme="warning" />
  24. </div>
  25. <div className="box">
  26. <Badge shape="round" text="999+" theme="danger" />
  27. </div>
  28. </div>
  29. , mountNode);

上标位置

  1. import { Badge } from 'zarm';
  2. ReactDOM.render(
  3. <div className="custom-panel">
  4. <div className="box">
  5. <Badge shape="dot"><div className="box-item" /></Badge>
  6. </div>
  7. <div className="box">
  8. <Badge shape="rect" text="免费"><div className="box-item" /></Badge>
  9. </div>
  10. <div className="box">
  11. <Badge shape="radius" text="new"><div className="box-item" /></Badge>
  12. </div>
  13. <div className="box">
  14. <Badge shape="round" text="999+"><div className="box-item" /></Badge>
  15. </div>
  16. <div className="box">
  17. <Badge shape="circle" text="3"><div className="box-item" /></Badge>
  18. </div>
  19. <div className="box">
  20. <Badge shape="leaf" text="新品"><div className="box-item" /></Badge>
  21. </div>
  22. </div>
  23. , mountNode);

文本示例

  1. import { Badge } from 'zarm';
  2. ReactDOM.render(
  3. <div className="text-panel">
  4. <div className="box">
  5. <Badge shape="dot"><span className="box-text">邀请有奖</span></Badge>
  6. </div>
  7. <div className="box">
  8. <span className="box-text">邀请有奖</span><Badge shape="dot"/>
  9. </div>
  10. </div>
  11. , mountNode);

API

属性类型默认值说明
themestring'danger'设置主题,可选值为 primarysuccesswarningdanger
shapestring'dot'设置形状,可选值为 dotrectradiusroundcircleleaf
textReactNode-设置显示的文字