Preview
Loading GPUI
Props
Install
cargo add evilbuttonsUsage
use evilbuttons::ShinyButton;
use gpui::{div, prelude::*, Context, IntoElement, Render, Window};
struct ButtonDemo;
impl Render for ButtonDemo {
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
div().child(ShinyButton::new("launch", "Launch").on_click(|_, _, _| println!("Shiny")))
}
}Variants
Slow glint
A longer shine_duration gives a lazier, more luxurious sweep.
Loading GPUI
ShinyButton::new("polish", "Polish").shine_duration(Duration::from_millis(1200))Props
ShinyButton is a GPUI RenderOnce builder; its animation state is keyed by id.
| Method | Type | Default | Description |
|---|---|---|---|
new(id, label) | impl Into<ElementId>, impl Into<SharedString> | - | Unique id and the button label. |
shine_duration(d) | Duration | 650ms | How long the glint takes to sweep across on click. |
on_click(f) | Fn(&ClickEvent, &mut Window, &mut App) | - | Fired before the glint starts. |
disabled(bool) | bool | false | Dims the button and ignores input. |
Good to know
- The skewed glint is painted in thin strips clipped to the rounded rim, so it never spills past the corners.
- Clicking again mid-sweep restarts the glint.