Skip to main content

swatch

Function swatch 

Source
pub fn swatch<'a>(colour: impl Fn(&Theme) -> Color + 'a) -> Swatch<'a>
Expand description

Creates a swatch whose colour is resolved from the theme each time it is drawn, so it follows theme changes.

use iced_cube::theme::{self, Tokens};

let danger: iced::Element<'_, ()> =
    theme::swatch(|theme| Tokens::of(theme).destructive).into();