Components / controls
IconButton builder
An action carried by a glyph alone.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::controls::button::IconButton;
Reviewed in actions.
Construct
new(ident: impl Into<Ident>, glyph: Icon, name: impl Into<SharedString>) -> Self
Options
Chain onto the value.
variant(variant: impl Into<ButtonStyle>) -> Self
color(color: impl Into<ColorChoice>) -> Self
ground(ground: Surface) -> Self
primary() -> Self
secondary() -> Self
ghost() -> Self
danger() -> Self
loading(loading: bool) -> Self
semantic_parent(parent: impl Into<SharedString>) -> Self
track_focus(handle: &FocusHandle) -> Self
join(join: ButtonJoin) -> Self
on_click(handler: impl Fn(&mut Window, &mut App) + 'static) -> Self
Example · actions
fn actions(window: &mut Window, cx: &mut App) -> AnyElement {
ensure_actions(window, cx);
let split = cx.global::<SceneActions>().split.clone();
let theme = cx.theme().clone();
stack(&theme)
.w(px(560.0))
.h(px(360.0))
.child(
row(&theme)
.child(
// One row, one weight: a chipless button beside four
// chipped ones reads as the one that is unavailable.
IconButton::new("scene.actions.copy", Icon::Copy, "Copy run id")
.secondary()
.on_click(|_, _| {}),
)
.child(
IconButton::new("scene.actions.rename", Icon::Pen, "Rename run")
.secondary()
.on_click(|_, _| {}),
)
.child(
IconButton::new("scene.actions.refresh", Icon::Refresh, "Refresh")
.secondary()
.loading(true)
.on_click(|_, _| {}),
)
.child(
IconButton::new("scene.actions.delete", Icon::Trash, "Delete run")
.danger()
.on_click(|_, _| {}),
)
.child(
IconButton::new("scene.actions.archive", Icon::Archive, "Archive run")
.secondary()
.disabled(true)
.on_click(|_, _| {}),
),
)
.child(
row(&theme).child(
// A range picker built the way a host would build one: the
// track is the group's, the answers that are not current stay
// bare on it, and the one that is holds a chip in the colour
// the library reserves for the current answer.
ButtonGroup::new("scene.actions.range")
.children([
Button::new("scene.actions.range.day")
.label("Day")
.ghost()
.on_click(|_, _| {}),
Button::new("scene.actions.range.week")
.label("Week")
.variant(gpui_kit_theme::Variant::Light)
.selected(true)
.on_click(|_, _| {}),
Button::new("scene.actions.range.month")
.label("Month")
.ghost()
.on_click(|_, _| {}),
])
.small(),
),
)
.child(row(&theme).child(split))
.into_any_element()
}