Badge

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

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add badge

Usage

use yew::prelude::*;

use crate::components::ui::badge::{Badge, BadgeVariant};

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Badge variant={BadgeVariant::Outline}>{"Badge"}>/Badge>
    }
}

You can use the BadgeVariant helper to create a link that looks like a badge.

use yew::prelude::*;
use yew_router::prelude::*;

use crate::components::ui::badge::{Badge, BadgeClass, BadgeVariant};

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Link class={BadgeClass::builder().variant(BadgeVariant::Outline).build().to_class()}>
            {"Badge"}
        </Link>
    }
}

Examples

Default

Secondary

Outline

Destructive

See Also