Skip to content

[Feature] Button widget #150

Open

Description

@vmarcella

Overview

Add a button widget that responds to mouse clicks and displays text or an icon.

Current State

No response

Scope

Goals:

  • Text button with label
  • Click detection
  • Visual states (normal, hover, pressed, disabled)
  • Callback on click

Non-Goals:

  • Icon buttons
  • Toggle buttons
  • Styling

Proposed API

pub enum ButtonState {
  Normal,
  Hovered,
  Pressed,
  Disabled,
}

pub struct Button {
  label: String,
  state: ButtonState,
  on_click: Option<Box<dyn Fn()>>,
}

impl Button {
  pub fn new(label: &str) -> Self;
  pub fn on_click(self, callback: impl Fn() + 'static) -> Self;
  pub fn set_enabled(&mut self, enabled: bool);
  pub fn state(&self) -> ButtonState;
}

impl Widget for Button {
  fn render(&self, ctx: &mut UiRenderContext) -> Vec<RenderCommand>;
  fn hit_test(&self, x: f32, y: f32) -> bool;
  // Mouse event handling internally updates state
}

Acceptance Criteria

  • Button displays label text
  • Hover state when mouse over
  • Pressed state when mouse down
  • Click callback fires on mouse up inside
  • Disabled state ignores i

Affected Crates

lambda-rs

Notes

  • State transitions: Normal <-> Hovered <-> Pressed
  • Click fires only if release is inside button

Activity

  1. added
    enhancement
    lambda-rs
    UI
    on Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    UIenhancementlambda-rs

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions