Skip to main content

badge

Function badge 

Source
pub fn badge<S>(variant: BadgeVariant) -> El<S>
Expand description

A <span> that shows a short label, such as a status, as a badge.

A badge is text and takes no role, so a screen reader reads it where it stands. Where the color alone carries the meaning, put the meaning in the text too, such as “Failed” rather than a red dot.

use hypersig::Signals;
use hypersig_ui::{BadgeVariant, badge};
use serde::{Deserialize, Serialize};

#[derive(Signals, Serialize, Deserialize)]
struct App {}

let status = badge::<App>(BadgeVariant::Secondary).text("Draft");
assert!(status.render().starts_with("<span"));