Badge 배지
Badge는 아이콘이나 텍스트 오른쪽 위에 붙는 빨간 점·숫자·텍스트예요. 새 콘텐츠나 확인하지 않은 정보가 있다는 걸 알려주는 역할을 하죠.
출처: 문서
설치
@nutui/nutui에서 컴포넌트를 가져와 앱에 등록하면 바로 쓸 수 있어요.
import { createApp } from 'vue'
import { Badge } from '@nutui/nutui'
const app = createApp()
app.use(Badge)
사용 예시
기본 사용법
demo: badge basic
최대값
demo: badge max
색상 커스터마이즈
demo: badge color
콘텐츠 커스터마이즈
demo: badge icon
위치 커스터마이즈
demo: badge position
API
Props
| Attribute | Description | Type | Default |
|---|---|---|---|
| value | content | string | - |
| max | When value is a numeric value, the maximum value | number | 10000 |
| z-index | badge z-index | number | 10 |
| dot | whether to dot | boolean | false |
bubble(>v4.0.0) |
whether to bubble | Boolean | false |
| hidden | whether to hide | boolean | false |
| top | Up and down offset, support unit setting, for example: 5px | number | 0 |
| right | Left and right offset, support unit setting, for example: 5px | number | 0 |
| color | badge background color | string | #fa2c19 |
Slots
| Name | Description |
|---|---|
| default | Default slot |
| icon | Icon slot |
Types v4.3.8
이 컴포넌트는 아래 타입 정의를 함께 내보내요.
import type {
BadgeProps,
BadgeInstance
} from '@nutui/nutui'
Theming
CSS Variables
스타일 커스텀에 쓸 수 있는 CSS 변수를 제공해요. 자세한 내용은 ConfigProvider 컴포넌트를 참고하세요.
| Name | Default Value |
|---|---|
| --nut-badge-background-color | linear-gradient(135deg, var(--nut-primary-color) 0%, var(--nut-primary-color-end) 100%) |
| --nut-badge-color | #fff |
| --nut-badge-font-size | var(--nut-font-size-1) |
| --nut-badge-border-radius | 14px |
| --nut-badge-icon-padding | 4px |
| --nut-badge-padding | 0 5px |
| --nut-badge-content-transform | translate(50%, -50%) |
| --nut-badge-z-index | 1 |
| --nut-badge-dot-width | 7px |
| --nut-badge-dot-height | 7px |
| --nut-badge-dot-border-radius | 7px |
| --nut-badge-dot-padding | 0px |
더 알아보기 (Learn more)
- 원문 문서: NutUI Badge 공식 문서(영문)
- NutUI는 JD.com이 공개한 Vue 3 모바일 컴포넌트 라이브러리예요. 전체 컴포넌트 목록은 공식 문서 사이트에서, 소스 코드는 GitHub 저장소에서 볼 수 있어요.