mirror of https://github.com/vuejs/vitepress
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.7 KiB
70 lines
1.7 KiB
2 years ago
|
# Badge
|
||
|
|
||
|
The badge lets you add status to your headers. For example, it could be useful to specify the section's type, or supported version.
|
||
|
|
||
|
## Usage
|
||
|
|
||
|
You may use the `Badge` component which is globally available.
|
||
|
|
||
|
```html
|
||
|
### Title <Badge type="info" text="default" />
|
||
|
### Title <Badge type="tip" text="^1.9.0" />
|
||
|
### Title <Badge type="warning" text="beta" />
|
||
|
### Title <Badge type="danger" text="caution" />
|
||
|
```
|
||
|
|
||
|
Code above renders like:
|
||
|
|
||
2 years ago
|
### Title <Badge type="info" text="default" />
|
||
|
### Title <Badge type="tip" text="^1.9.0" />
|
||
|
### Title <Badge type="warning" text="beta" />
|
||
|
### Title <Badge type="danger" text="caution" />
|
||
2 years ago
|
|
||
|
## Custom Children
|
||
|
|
||
|
`<Badge>` accept `children`, which will be displayed in the badge.
|
||
|
|
||
|
```html
|
||
|
### Title <Badge type="info">custom element</Badge>
|
||
|
```
|
||
|
|
||
|
### Title <Badge type="info">custom element</Badge>
|
||
|
|
||
|
## Customize Type Color
|
||
|
|
||
1 year ago
|
You can customize the style of badges by overriding css variables. The following are the default values:
|
||
2 years ago
|
|
||
|
```css
|
||
|
:root {
|
||
1 year ago
|
--vp-badge-info-border: transparent;
|
||
2 years ago
|
--vp-badge-info-text: var(--vp-c-text-2);
|
||
1 year ago
|
--vp-badge-info-bg: var(--vp-c-default-soft);
|
||
2 years ago
|
|
||
1 year ago
|
--vp-badge-tip-border: transparent;
|
||
|
--vp-badge-tip-text: var(--vp-c-brand-1);
|
||
|
--vp-badge-tip-bg: var(--vp-c-brand-soft);
|
||
2 years ago
|
|
||
1 year ago
|
--vp-badge-warning-border: transparent;
|
||
|
--vp-badge-warning-text: var(--vp-c-warning-1);
|
||
|
--vp-badge-warning-bg: var(--vp-c-warning-soft);
|
||
2 years ago
|
|
||
1 year ago
|
--vp-badge-danger-border: transparent;
|
||
|
--vp-badge-danger-text: var(--vp-c-danger-1);
|
||
|
--vp-badge-danger-bg: var(--vp-c-danger-soft);
|
||
2 years ago
|
}
|
||
|
```
|
||
|
|
||
|
## `<Badge>`
|
||
|
|
||
|
`<Badge>` component accepts following props:
|
||
|
|
||
|
```ts
|
||
|
interface Props {
|
||
|
// When `<slot>` is passed, this value gets ignored.
|
||
|
text?: string
|
||
|
|
||
|
// Defaults to `tip`.
|
||
|
type?: 'info' | 'tip' | 'warning' | 'danger'
|
||
|
}
|
||
|
```
|