cosmic::iced_widget

Function rich_text

source
pub fn rich_text<'a, Link, Theme, Renderer>(
    spans: impl AsRef<[Span<'a, Link, <Renderer as Renderer>::Font>]> + 'a,
) -> Rich<'a, Link, Theme, Renderer>
where Link: Clone + 'static, Theme: Catalog + 'a, Renderer: Renderer, <Renderer as Renderer>::Font: 'a,
Expand description

Creates a new Rich text widget with the provided spans.

ยง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(" "),
        span("And I am bold!").font(Font { weight: font::Weight::Bold, ..Font::default() }),
    ])
    .size(20)
    .into()
}