RevealButton

A button that reveals a hidden secret value on hold or toggle, with a blur-in animation and an eye icon indicator.

Preview

Loading GPUI

Props

Variants

Toggle mode

Click once to reveal, click again to hide.

Loading GPUI
RevealButton::new("api-key")
    .mode(RevealButtonMode::Toggle)
    .secret("sk_live_abc123_xQ4z9")
    .masked_value("sk_live_•••••••")
    .label("API Key")
    .hidden_label("API Key")

Light

RevealButtonVariant::Light swaps the dark face for a white one with a soft gray rim.

Loading GPUI
RevealButton::new("api-key")
    .variant(RevealButtonVariant::Light)
    .secret("sk_live_abc123_xQ4z9")
    .masked_value("sk_live_•••••••")

Install

cargo add evilbuttons

Usage

use evilbuttons::{RevealButton, RevealButtonMode};

RevealButton::new("api-key")
    .secret("sk_live_abc123_xQ4z9")
    .masked_value("sk_live_•••••••")
    .mode(RevealButtonMode::Hold)
    .value_font("Geist Mono")
    .on_reveal_change(|revealed, _, _| println!("{revealed}"))

Props

RevealButton is a GPUI RenderOnce builder; its state is keyed by id.

MethodTypeDefaultDescription
new(id)impl Into<ElementId>-Unique id for the button's state.
secret(s)impl Into<SharedString>"sk_live_••••_9xQ4"The real value shown when revealed.
masked_value(s)impl Into<SharedString>"•••• •••• ••••"The placeholder shown when hidden.
label(s)impl Into<SharedString>"Reveal"Small label shown above the value when revealed.
hidden_label(s)impl Into<SharedString>"Hidden"Small label shown above the value when hidden.
mode(m)RevealButtonModeHoldHold requires a sustained press; Toggle switches on each click.
variant(v)RevealButtonVariantDarkGraded surface style: Dark or Light.
value_font(family)impl Into<SharedString>-Font family for the value, e.g. your monospace font.
on_reveal_change(f)Fn(bool, &mut Window, &mut App)-Fired whenever the revealed state changes.
disabled(bool)boolfalseDims the button and ignores input.

Good to know

  • In hold mode, letting go, leaving the button or losing focus hides it again.
  • Hold Space or Enter to reveal from the keyboard.
  • GPUI has no blur filter, so the value swap is a lift and fade without the blur.

Search docs

Jump to a button documentation page