Skip to content

[Feature] Text input widget #154

Open

Description

@vmarcella

Overview

Add a text input widget for single-line text entry with cursor and selection.

Current State

No response

Scope

Goals:

  • Single-line text entry
  • Cursor positioning with click
  • Keyboard input handling
  • Text selection (shift+arrow)
  • Copy/paste support

Non-Goals:

  • Multi-line text area
  • Rich text editing
  • Input validation

Proposed API

pub struct TextInput {
  text: String,
  cursor_position: usize,
  selection_start: Option<usize>,
  placeholder: Option<String>,
  on_change: Option<Box<dyn Fn(&str)>>,
  on_submit: Option<Box<dyn Fn(&str)>>,
}

impl TextInput {
  pub fn new() -> Self;
  pub fn with_placeholder(self, text: &str) -> Self;
  pub fn on_change(self, callback: impl Fn(&str) + 'static) -> Self;
  pub fn on_submit(self, callback: impl Fn(&str) + 'static) -> Self;
  pub fn text(&self) -> &str;
  pub fn set_text(&mut self, text: &str);
  pub fn clear(&mut self);
}

impl Widget for TextInput {
  fn render(&self, ctx: &mut UiRenderContext) -> Vec<RenderCommand>;
}

Acceptance Criteria

  • Text entry works with keyboard
  • Cursor visible and blinking
  • Click positions cursor
  • Arrow keys move cursor
  • Selection with shift+arrows
  • Enter key triggers submit
  • Placeholder shows when empty

Affected Crates

lambda-rs

Notes

  • Handle Ctrl+A (select all), Ctrl+C/V (copy/paste)
  • Clipboard requires platform integration

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