Preview
Loading GPUI
Variants
Toxic
Swap the two channel colors with colors.
Loading GPUI
GlitchButton::new("biohazard", "BIOHAZARD").colors(rgb(0xa3e635), rgb(0xf472b6))Overload
Crank intensity and lengthen the burst for a more violent glitch on hover.
Loading GPUI
GlitchButton::new("overload", "OVERLOAD")
.intensity(2.5)
.glitch_duration(Duration::from_millis(600))Auto
Use GlitchTrigger::Auto to fire timed bursts on a random interval without needing a hover.
Loading GPUI
GlitchButton::new("drift", "SIGNAL DRIFT")
.trigger(GlitchTrigger::Auto)
.glitch_interval(Duration::from_millis(1400))Always on
Use GlitchTrigger::Always for a permanently corrupted signal.
Loading GPUI
GlitchButton::new("lost", "SIGNAL LOST").trigger(GlitchTrigger::Always)Clean pill
Drop the scanlines with scanlines(false) and round it off with radius.
Loading GPUI
GlitchButton::new("smooth", "SMOOTH").scanlines(false).radius(9999.0)Install
cargo add evilbuttonsUsage
use evilbuttons::GlitchButton;
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(GlitchButton::new("deploy", "DEPLOY DOOM").font_family("Geist Mono"))
}
}Props
GlitchButton is a GPUI RenderOnce builder; its glitch state is keyed by id.
| Method | Type | Default | Description |
|---|---|---|---|
new(id, label) | impl Into<ElementId>, impl Into<SharedString> | - | Unique id and the label (shown uppercase). |
glitch_interval(d) | Duration | 3500ms | Base time between automatic bursts (±20% random jitter). Used with GlitchTrigger::Auto. |
glitch_duration(d) | Duration | 450ms | Duration of a single glitch burst. |
colors(a, b) | impl Into<Hsla>, impl Into<Hsla> | #ef4444, #22d3ee | The two RGB-split channel colors. |
intensity(f) | f32 | 1.0 | Multiplier on the channel and shake displacement. Higher is more violent. |
trigger(t) | GlitchTrigger::{Auto, Hover, Always} | Hover | When the glitch fires: timed bursts, only on hover, or continuously. |
scanlines(bool) | bool | true | Toggle the scanline overlay. |
radius(px) | f32 | 10.0 | Corner radius; a large value makes a pill. |
font_family(name) | impl Into<SharedString> | inherited | Label font, e.g. your monospace font. |
on_click(f) | Fn(&ClickEvent, &mut Window, &mut App) | - | Fired on click, and on Space/Enter while focused. |
disabled(bool) | bool | false | Dims the button and ignores input. |
Good to know
- Stays a dark screen in both themes.
- The channels are drawn as plain colored copies of the label rather than
mix-blend-mode: screen; on the dark surface they look the same.