# Badge ### Install ```js import { createApp } from 'vue'; import { Badge } from 'vant'; const app = createApp(); app.use(Badge); ``` ## Usage ### Basic Usage ```html
``` ### Max ```html
``` ### Custom Color ```html
``` ### Custom Content Use `content` slot to custom :content of badge. ```html
``` ```css .badge-icon { display: block; font-size: 10px; line-height: 16px; } ``` ### Standalone ```html ``` ## API ### Props | Attribute | Description | Type | Default | | --- | --- | --- | --- | | content | Badge content | _number \| string_ | - | | color | Background color | _string_ | `#ee0a24` | | dot | Whether to show dot | _boolean_ | `false` | | max | Max value,show `{max}+` when exceed,only works when content is number | _number \| string_ | - | | offset `v3.0.5` | Offset of badge dot | _[number, number]_ | - | ### Slots | Name | Description | | ------- | -------------------- | | default | Default slot | | content | Custom badge content | ### Less Variables How to use: [Custom Theme](#/en-US/theme). | Name | Default Value | Description | | --- | --- | --- | | @badge-size | `16px` | - | | @badge-color | `@white` | - | | @badge-padding | `0 3px` | - | | @badge-font-size | `@font-size-sm` | - | | @badge-font-weight | `@font-weight-bold` | - | | @badge-border-width | `@border-width-base` | - | | @badge-background-color | `@red` | - | | @badge-dot-color | `@red` | - | | @badge-dot-size | `8px` | - | | @badge-font-family | `-apple-system-font, Helvetica Neue, Arial, sans-serif` | - |