Skip to content

Badge

A small label used to tag or categorize content. Four variants.

When to use

  • A Default badge for neutral tags.
  • A Secondary badge for slightly stronger emphasis.
  • An Outline badge when you want a visible boundary without a fill.
  • A Destructive badge for error or destructive states.

API

Badge::new(label)

Creates a badge with the given label.

MethodTypeDefaultDescription
.variant(variant)BadgeVariantDefaultVisual style

BadgeVariant

VariantStyle
Defaultbg ZINC_100, ZINC_700 text
Secondarybg ZINC_200, ZINC_800 text
Outline1px ZINC_300 border, ZINC_700 text
Destructivebg RED_100, RED_700 text

Usage

rust
use gpui::{Component, div, prelude::*};
use components::{Badge, BadgeVariant};

div()
    .child(Component::new(
        Badge::new("New").variant(BadgeVariant::Destructive),
    ))

Copy the source

crates/components/src/badge.rs — self-contained, stateless, and free to modify.

Released under the MIT License.