A small label for a status or a count.
Installation
Components are distributed as source. Copy it and what it depends on into your project, then change it as you need:
cargo run --release --bin amenui -- add badge --to ../my-appFiles copied: src/widgets/badge.rs, src/widgets/mod.rs
Usage
use amenui::widgets::{badge};
fn view() -> El<Msg> {
row().gap(8.0).child(badge("bd1", "新", Variant::Accent)).child(badge("bd2", "草稿", Variant::Default)).child(badge("bd3", "12", Variant::Quiet))
}API
| Functions | badge |
|---|---|
| Props | key, label, variant (Variant::Default outlined, Quiet faint, Primary ink, Accent filled). |
| Files | src/widgets/badge.rs |
| Depends on | base |
| Response to fronts | nudge (a control: pushed as one piece by fronts, held and condensing at most to Look::legible_cap) |
| Recomposition | keyed labels recompose when their text changes |
Keyboard and accessibility
| States | none. |
|---|---|
| Keys and messages | none. |
On the web every control is mirrored into the page as an element with its role and name, so screen readers and the browser's own focus see it (DESIGN.md §1.14).