GlitchButton

A button with randomized RGB-split glitch bursts, a scanline overlay, and a flickering label.

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 evilbuttons

Usage

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.

MethodTypeDefaultDescription
new(id, label)impl Into<ElementId>, impl Into<SharedString>-Unique id and the label (shown uppercase).
glitch_interval(d)Duration3500msBase time between automatic bursts (±20% random jitter). Used with GlitchTrigger::Auto.
glitch_duration(d)Duration450msDuration of a single glitch burst.
colors(a, b)impl Into<Hsla>, impl Into<Hsla>#ef4444, #22d3eeThe two RGB-split channel colors.
intensity(f)f321.0Multiplier on the channel and shake displacement. Higher is more violent.
trigger(t)GlitchTrigger::{Auto, Hover, Always}HoverWhen the glitch fires: timed bursts, only on hover, or continuously.
scanlines(bool)booltrueToggle the scanline overlay.
radius(px)f3210.0Corner radius; a large value makes a pill.
font_family(name)impl Into<SharedString>inheritedLabel 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)boolfalseDims 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.

Search docs

Jump to a button documentation page