Label
Text with muted secondary text, a required marker, highlighted matches and masking.
Default
ui.add(Label::new("Company Address"));
ui.add(Label::new("Company Name").secondary("(optional)"));
ui.add(Label::new("Email").required(true));
Highlighting
ui.add(Label::new("Banana and mango").highlights(state.query.as_str()));
ui.add(
Label::new("Analysis")
.secondary("of an answer")
.highlights(state.query.as_str()),
);
ui.add(Label::new("这是一个中文标签").highlights("中文"));
ui.add(Label::new("Antenna").highlights_prefix(state.query.as_str()));
Layout
ui.add(Label::new("Centred").align(egui::Align::Center));
ui.add(Label::new("Aligned to the end").align(egui::Align::RIGHT));
ui.add(Label::new("שלום, תווית מימין לשמאל"));
ui.add(Label::new(
"A long label wraps naturally at the width it is given, as text does anywhere else.",
));
Masked
ui.add(Label::new("sk-live-12345").masked(state.masked));
ui.add(Toggle::new(&mut state.masked, "Masked"));
The story above is gallery/src/stories/label.rs, running in your browser. Every snippet on this page is cut from it.