Skip to content

Implement <SelectableLabel> tag (egui::SelectableLabel) #25

@ZhukMax

Description

@ZhukMax

Provide a <SelectableLabel> tag for single-item selection UX or list-like UIs. Supports a controlled selected={bool} binding and click handling.

  • Common building block for custom lists, nav rails, and option rows.
  • Pairs well with ScrollArea and columns/rows to build list UIs.

Scope

  • Tag: <SelectableLabel>
  • Attributes: selected={bool}, onClick={|| ...}, enabled, wrap, tooltip.
  • Children: text/inline content (same as <Label>).

Proposed API (sketch)

efx!(ui, r#"
<SelectableLabel selected={tab == "home"} onClick={|| tab = "home"}>Home</SelectableLabel>
<SelectableLabel selected={tab == "settings"} onClick={|| tab = "settings"}>Settings</SelectableLabel>
"#);

// Mapping
// ui.add(egui::SelectableLabel::new(selected, "Text"));

Tasks

  • AST + codegen for <SelectableLabel> with text/children support.
  • Controlled selected binding + onClick event hookup.
  • Attribute adapters: enabled, wrap, tooltip.
  • Examples: simple tab-like switcher; list with multiple items.
  • trybuild UI tests for missing/invalid attrs.
  • Ensure examples build for wasm32-unknown-unknown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions