shadcn-templ 2.0 beta. Switch to templUI v1
1.7k

Badge

Displays a badge or a component that looks like a badge.

BadgeSecondaryDestructiveOutline
package examples import "github.com/axadrn/shadcn-templ/v2/components/badge"

Installation

shadcn-templ add badge

Usage

import "github.com/axadrn/shadcn-templ/v2/components/badge"
@badge.Badge(badge.Props{Variant: badge.VariantOutline}) {	Badge}

Variants

Use the Variant prop to change the variant of the badge.

DefaultSecondaryDestructiveOutlineGhost
package examples import "github.com/axadrn/shadcn-templ/v2/components/badge"

With Icon

You can render an icon inside the badge. Use data-icon="inline-start" to render the icon on the left and data-icon="inline-end" to render the icon on the right.

VerifiedBookmark
package examples import (

With Spinner

You can render a spinner inside the badge. Remember to add the data-icon="inline-start" or data-icon="inline-end" attribute to the spinner.

DeletingGenerating
package examples import (

Set the Href prop to render the badge as a link.

package examples import (

Custom Colors

You can customize the colors of a badge by adding custom classes such as bg-green-50 dark:bg-green-800 to the Badge component.

BlueGreenSkyPurpleRed
package examples import "github.com/axadrn/shadcn-templ/v2/components/badge"

API Reference

Badge

The Badge component displays a badge or a component that looks like a badge.

Prop Type Default
Variant VariantDefault | VariantSecondary | VariantDestructive | VariantOutline | VariantGhost | VariantLink VariantDefault
Href string -
Class string -