iced::widget

Function span

source
pub fn span<'a, Link, Font>(text: impl IntoFragment<'a>) -> Span<'a, Link, Font>
Expand description

Creates a new Span of text with the provided content.

A Span is a fragment of some Rich text.

ยงExample

use iced::font;
use iced::widget::{rich_text, span};
use iced::{color, Font};

#[derive(Debug, Clone)]
enum Message {
    // ...
}

fn view(state: &State) -> Element<'_, Message> {
    rich_text![
        span("I am red!").color(color!(0xff0000)),
        " ",
        span("And I am bold!").font(Font { weight: font::Weight::Bold, ..Font::default() }),
    ]
    .size(20)
    .into()
}