DocsComponentsBadge
Badge
A small status label.
1 file
<pb-ui.badge>Badge</pb-ui.badge>Installation
pyblade-ui add badge- Copy this file into your projectcomponents/ui/badge.html
@props({'variant': 'default'}) <span data-slot="badge" {{ attributes.cn( "inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden whitespace-nowrap rounded-md border px-2 py-0.5 text-xs font-medium transition-[color,box-shadow] [&>svg]:pointer-events-none [&>svg]:size-3", { 'default': 'border-transparent bg-primary text-primary-foreground', 'secondary': 'border-transparent bg-secondary text-secondary-foreground', 'destructive': 'border-transparent bg-destructive text-white dark:bg-destructive/60', 'success': 'border-transparent bg-success text-success-foreground', 'warning': 'border-transparent bg-warning text-warning-foreground', 'outline': 'text-foreground', }[variant], ) }}>{{ slot }}</span> - Update the path to fit your project
The
componentsfolder is the one set inpyblade.toml.
Usage
The tag <pb-ui.badge> is available in all your templates.
<pb-ui.badge variant="success">Paid</pb-ui.badge>Examples
Variants
<div class="flex flex-wrap justify-center gap-2">
<pb-ui.badge>Default</pb-ui.badge>
<pb-ui.badge variant="secondary">Secondary</pb-ui.badge>
<pb-ui.badge variant="outline">Outline</pb-ui.badge>
<pb-ui.badge variant="success">Paid</pb-ui.badge>
<pb-ui.badge variant="warning">Pending</pb-ui.badge>
<pb-ui.badge variant="destructive">Failed</pb-ui.badge>
</div>Props
| Prop | Default |
|---|---|
| variant | 'default' |
Any other attribute (class, id, x-on:click, hx-post…) is passed to the root element; your Tailwind classes win over the component's.