ConfettiButton

A ringed dark button with a sparkle icon that fires a restrained confetti burst on click.

Preview

Loading GPUI

Props

Install

cargo add evilbuttons

Usage

use evilbuttons::ConfettiButton;
use gpui::{div, prelude::*, rgb, Context, IntoElement, Render, Window};

struct ButtonDemo;

impl Render for ButtonDemo {
    fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
        div().child(
            ConfettiButton::new("celebrate")
                .label("Celebrate")
                .colors([rgb(0xfafafa), rgb(0xa3a3a3), rgb(0x93c5fd)])
                .on_celebrate(|_, _| println!("Celebrated!")),
        )
    }
}

Props

ConfettiButton is a GPUI RenderOnce builder; its state is keyed by id. on_click still fires before the burst.

MethodTypeDefaultDescription
new(id)impl Into<ElementId>-Unique id for the button's state.
label(s)impl Into<SharedString>"Continue"Button label.
particle_count(n)usize80Confetti particles per burst.
spread(deg)f3264.0Confetti spread in degrees.
start_velocity(v)f3232.0Launch velocity of the burst (canvas-confetti units).
colors(iter)IntoIterator<Item = impl Into<Hsla>>muted neutrals + soft accentsCustom confetti colors.
icon(bool)booltrueShow the leading sparkle icon.
on_click(f)Fn(&ClickEvent, &mut Window, &mut App)-Fired on every click, before the burst.
on_celebrate(f)Fn(&mut Window, &mut App)-Fired after each confetti burst.
disabled(bool)boolfalseDims the button and ignores input.

Good to know

  • No canvas-confetti: its particle model (velocity decay, gravity, wobble, tilt and fade) is ported natively and stepped at its 60fps tick.
  • Confetti is painted on an unclipped overlay above everything else in the window.

Search docs

Jump to a button documentation page