pub struct Label { /* private fields */ }Expand description
Themed text label with an optional trailing (or leading) image.
Interactive by default: hover/click paints a background from
LabelVisuals. Set Label::interactive to false for static text.
Used as the selected-item face of ComboBox.
ui.add(Label::new("Hello", None));Implementations§
Source§impl Label
impl Label
Sourcepub fn new(text: impl Into<WidgetText>, image: Option<Image<'static>>) -> Self
pub fn new(text: impl Into<WidgetText>, image: Option<Image<'static>>) -> Self
Create a new Label with text and an optional image.
By default the image is shown after the text
Sourcepub fn sections(
parts: impl IntoIterator<Item = impl Into<RichText>>,
image: Option<Image<'static>>,
) -> Self
pub fn sections( parts: impl IntoIterator<Item = impl Into<RichText>>, image: Option<Image<'static>>, ) -> Self
Mixed-style wrapping paragraph from several RichText spans.
Unlike super::MultiLabel, the parts share one galley, so the
sentence wraps across style changes. RichText::strong is a stronger
color, not a heavier font weight.
Plain strings need .into() when mixed with RichText:
ui.add(
Label::sections(
[
"Download icons from ".into(),
RichText::new("app.com").strong(),
" instead of a placeholder.".into(),
],
None,
)
.wrap()
.fill_width(true)
.interactive(false),
);Sourcepub fn size(self, size: f32) -> Self
pub fn size(self, size: f32) -> Self
Font size for every section.
Overrides per-span sizes from RichText::size.
Sourcepub fn visuals(self, visuals: LabelVisuals) -> Self
pub fn visuals(self, visuals: LabelVisuals) -> Self
Set the visuals of the label
Sourcepub fn sense(self, sense: Sense) -> Self
pub fn sense(self, sense: Sense) -> Self
Make the label respond to clicks and/or drags.
This will also turn the selectable to false
Sourcepub fn interactive(self, interactive: bool) -> Self
pub fn interactive(self, interactive: bool) -> Self
Make the label interactive
True by default, If false on hover/click there will be no bg color
Sourcepub fn wrap_mode(self, wrap_mode: TextWrapMode) -> Self
pub fn wrap_mode(self, wrap_mode: TextWrapMode) -> Self
Set the wrap mode for the text. Defaults to Ui::wrap_mode.
Sourcepub fn wrap(self) -> Self
pub fn wrap(self) -> Self
Set Self::wrap_mode to TextWrapMode::Wrap.
Sourcepub fn selectable(self, selectable: bool) -> Self
pub fn selectable(self, selectable: bool) -> Self
Set whether the text can be selected with the mouse.
Sourcepub fn image_on_left(self) -> Self
pub fn image_on_left(self) -> Self
Show the image first and then the text
Sourcepub fn selected(self, selected: bool) -> Self
pub fn selected(self, selected: bool) -> Self
Paint the selected fill from LabelVisuals even when not hovered.
Sourcepub fn fill_width(self, fill: bool) -> Self
pub fn fill_width(self, fill: bool) -> Self
Stretch the label to the available width (useful inside combo popups).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Label
impl RefUnwindSafe for Label
impl Send for Label
impl Sync for Label
impl Unpin for Label
impl UnsafeUnpin for Label
impl UnwindSafe for Label
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more