Badge
Small alphanumerical value or status descriptor for UI elements.
Importing
To use the badge component, first you need to register the component inside the page. You can register the component manually by importing the register function:
ts
import { register } from "@tapsioss/web-components/badge";
register(); // Now the badge component is ready to use!
ts
import { registerBadge } from "@tapsioss/web-components";
registerBadge(); // Now the badge component is ready to use!
Also you can automatically register the component by importing it with the following approach:
ts
import "@tapsioss/web-components/badge/element";
TIP
If you want to use all the component in your app, you can call registerAll
at the root of your project.
ts
import { registerAll } from "@tapsioss/web-components";
registerAll(); // All the components are now available
In the React package, you can easily add the component using the following code:
ts
import { Badge } from "@tapsioss/react-components";
Component Usage
html
<tapsi-badge></tapsi-badge>
tsx
<Badge />
Properties
Name | Attribute Name | Description | Type | Default Value |
---|---|---|---|---|
value | value | The value of the badge. | string | number | "" |
variant | variant | The variant of the badge. | | "pill" | "numeral" | "dot" | "pill" |
color | color | The color of the badge. | | "success" | "error" | "info" | "warning" | "neutral" | "neutral" |
priority | priority | The priority level of the badge. | "high" | "low" | "high" |
size | size | The size of the badge. | "md" | "sm" | "md" |
Slots
Name | Value | Description |
---|---|---|
ICON | icon | The slot for icon element. |
TIP
The value of slots are available for developer as JavaScript Variables:
ts
// Option 1
import { BadgeSlots } from "@tapsioss/web-components";
// Option 2
import { Slots } from "@tapsioss/web-components/badge";
ts
// Option 1
import { BadgeSlots } from "@tapsioss/react-components";
// Option 2
import { Slots } from "@tapsioss/react-components/Badge";