Skip to content

Add Button::left_text#7955

Merged
emilk merged 1 commit intoemilk:mainfrom
rustbasic:patch175
Mar 24, 2026
Merged

Add Button::left_text#7955
emilk merged 1 commit intoemilk:mainfrom
rustbasic:patch175

Conversation

@rustbasic
Copy link
Copy Markdown
Contributor

feat: Add left_text() to egui::Button

This PR introduces the left_text() method to egui::Button. It enables placing additional text content on the left side of the button's primary label, which is useful for displaying auxiliary information, labels, and for facilitating left-aligned text within the button.

                            let is_selected = true;
                            let selectable_label_widget = egui::Button::selectable(
                                is_selected,
                                "",
                            ).left_text("Left");

                            let desired_width = ui.available_width();
                            let desired_height = ui.spacing().interact_size.y;

                            interaction_response = ui.add_sized(
                                egui::vec2(desired_width, desired_height),
                                selectable_label_widget,
                            );

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

Preview available at https://egui-pr-preview.github.io/pr/7955-patch175
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

View snapshot changes at kitdiff

@rustbasic rustbasic changed the title Update button.rs feat: Add left_text() to egui::Button Mar 4, 2026
Copy link
Copy Markdown
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to have a symmetric API for this

@emilk emilk added feature New feature or request egui labels Mar 24, 2026
@emilk emilk changed the title feat: Add left_text() to egui::Button Add Button::left_text Mar 24, 2026
@emilk emilk merged commit 5ed92c3 into emilk:main Mar 24, 2026
27 of 28 checks passed
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
feat: Add left_text() to egui::Button

This PR introduces the `left_text()` method to `egui::Button`. It
enables placing additional text content on the left side of the button's
primary label, which is useful for displaying auxiliary information,
labels, and for facilitating left-aligned text within the button.

```rust
                            let is_selected = true;
                            let selectable_label_widget = egui::Button::selectable(
                                is_selected,
                                "",
                            ).left_text("Left");

                            let desired_width = ui.available_width();
                            let desired_height = ui.spacing().interact_size.y;

                            interaction_response = ui.add_sized(
                                egui::vec2(desired_width, desired_height),
                                selectable_label_widget,
                            );
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

egui feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants