Command palette

@yasinsensoy/web

Web · Components

Badge

A small badge showing a status, label or number.

3 exports

Live example

Preview

New

Code

import { Badge } from "@yasinsensoy/web";

<Badge>New</Badge>

Events

  1. Events appear here when you interact with the preview.

Press effects (click or Space/Enter)

Corner shape

Style × color

neutralprimarydangersuccesswarning
neutralprimarydangersuccesswarning
neutralprimarydangersuccesswarning

Import

import { Badge } from "@yasinsensoy/web";

Badge

componentServer component

A small badge showing a status, label or number. A server component; uses the appearance settings of the nearest UIProvider in a client tree and of the defineAppearance registry on the server.

Badge({ tone: toneProp, variant: variantProp, effect, size: sizeProp, icon, dot, tooltip, className, children, ...props }: BadgeProps): ReactNode

Examples

<Badge>Draft</Badge>
<Badge tone="success" icon="check">Paid</Badge>
<Badge tone="danger" variant="solid">3</Badge>
<Badge tone="success" dot>Online</Badge>
<Badge tooltip="Value added tax included">VAT</Badge>
<Badge tone="primary" effect="shine">New</Badge>

Style of the badge.

type BadgeVariant = "solid" | "soft" | "outline"

BadgeProps

interface

Props of the Badge component.

Extends: ComponentProps<"span">

NameTypeDefaultDescription
tone?Tone"neutral"Color.
variant?BadgeVariant | CustomVariant<"badge">"soft"Style: built-in or a custom style added with defineAppearance. Defaults to UIProvider appearance.defaults.badge.variant.
effect?EffectPropEffect or effects (e.g. "shine", ["pulse", "lift"]). Defaults to UIProvider appearance.defaults.badge.effect. See BuiltinEffect.
icon?IconPropIcon at the start of the text: a name ("check") or an element.
dot?booleanPuts a colored status dot at the start of the text (e.g. "Online").
size?"sm" | "md""md"Size.
tooltip?TooltipPropTooltip shown on hover, focus or long press (e.g. what an abbreviation stands for). When given, the badge also becomes keyboard focusable. See TooltipProp.