Skip to main content

cosmic_applet_avestruz/views/components/
chip.rs

1// SPDX-License-Identifier: MIT
2
3//! A small choice button: one of a few things to choose between.
4
5use cosmic::Element;
6use cosmic::widget::{button, text};
7
8use crate::messages::Message;
9
10/// A small choice button, highlighted when it is the choice made.
11pub fn chip<'a>(label: String, active: bool, on_press: Message) -> Element<'a, Message> {
12    let class = if active { cosmic::theme::Button::Suggested } else { cosmic::theme::Button::Standard };
13    button::custom(text(label).size(13)).padding([4, 12]).class(class).on_press(on_press).into()
14}