--- localeCode: en-US order: 46 category: Show title: Badge subTitle: Badge icon: doc-badge brief: Badge generates a small badge to give users tips. --- ## Demos ### How to import ```jsx import import { Badge } from '@douyinfe/semi-ui'; ``` ### Basic Usage The basic type of Badge is `count`. The `dot` property changes a badge into a small dot. The two are mutually exclusive, giving priority to rendering `dot`. When passed in a node type, the node will be rendered directly. ```jsx live=true import React from 'react'; import { Badge, Avatar } from '@douyinfe/semi-ui'; import { IconLock } from '@douyinfe/semi-icons'; () => { const style = { width: '42px', height: '42px', borderRadius: '4px', }; return (
BM

YL

}> XZ

WF
); }; ``` ### Maximum Value You can use the `overflowCount` property to cap the number value of the badge content. When the actual value exceeds that value, it will be formatted into `${overflowCount}+`. ```jsx live=true import React from 'react'; import { Badge, Avatar } from '@douyinfe/semi-ui'; () => { const style = { width: '42px', height: '42px', borderRadius: '4px', }; return (
ZH

HS

DY

TT
); }; ``` ### Position You can use the `position` property to set the position of the badge to its children. The prop uses one of: `leftTop`, `leftBottom`, `rightTop`(default), `rightBottom`. ```jsx live=true import React from 'react'; import { Badge, Avatar } from '@douyinfe/semi-ui'; () => { const style = { width: '42px', height: '42px', borderRadius: '4px', }; return (
ZH

HS

DY

TT
); }; ``` ### Theming You can use the `theme` and `type` prop to customize the styling. `theme` supports the following values: `solid`(default), `light`, `inverted`. ```jsx live=true import React from 'react'; import { Badge, Avatar } from '@douyinfe/semi-ui'; () => { const bgStyle = { padding: '8px', }; const style = { width: '42px', height: '42px', borderRadius: '4px', }; return (
XZ
YB
LX

YZ
HW
XM
); }; ``` `type` support the following values: `primary`(default),`secondary`,`tertiary`,`warning` and `danger`. ```jsx live=true import React from 'react'; import { Badge, Avatar } from '@douyinfe/semi-ui'; () => { const bgStyle = { padding: '8px 8px 3px 8px', }; const style = { width: '42px', height: '42px', borderRadius: '4px', }; return (
MR
YL
ZW

JL
RT
YF
); }; ``` ### Independent Usage Badge can be used alone when it is a stand-alone element. ```jsx live=true import React from 'react'; import { Badge } from '@douyinfe/semi-ui'; () => (






processing
info
success
warning
error
); ``` ## API Reference | Properties | Instructions | type | Default | | ------------- | ------------------------------------------------------------------------------- | ---------- | ---------- | | children | Base | ReactNode | - | | count | Display content | ReactNode | - | | dot | Displayed as a little dot. | boolean | false | | overflowCount | Cap number value | number | - | | position | Badge position, optional `left Top`, `left Bottom`, `right Top`, `right Bottom` | string | `rightTop` | | style | style | CSSProperties | - | | theme | Badge theme, one of `solid`, `light`, `inverted` | string | `solid` | | type | Badge type, one of `primary`, `secondary`, `sense`, `danger`, `warning` | string | `primary` | ## Content Guidelines - Capitalize the first letter ## Design Tokens