Skip to main content

Module chip

Module chip 

Source
Available on crate feature chip only.
Expand description

Compact pills for chosen values, such as guests or tags, with an optional x button that removes them.

Chips share the badge colours and are Variant::Secondary by default. Give a chip Chip::on_remove to draw the x, and Chip::id to find that x in tests through remove_id.

use iced::Element;
use iced_cube::feedback::chip::chip;

#[derive(Debug, Clone)]
enum Message {
    Remove(usize),
}

fn guests(names: &[&str]) -> Element<'static, Message> {
    iced::widget::row(names.iter().enumerate().map(|(index, name)| {
        chip(name.to_string())
            .on_remove(Message::Remove(index))
            .into()
    }))
    .spacing(4)
    .wrap()
    .into()
}

Re-exports§

pub use crate::feedback::badge::Variant;

Structs§

Chip
A chip builder. Convert it into an Element to render.
Metrics
Resolved dimensions for a Size.

Enums§

Size
Chip dimensions. Size::Sm matches a badge.

Functions§

chip
Creates a chip with a text label.
remove_id
The widget id of the x button of the chip with Chip::id key.
remove_style
The x button style: clear until hovered or pressed, then a faint circle of the chip’s foreground colour.
style
The chip’s container style: the badge style of the same variant.