feat(a11y): screen reader name and description support for button widgets

This commit is contained in:
Michael Aaron Murphy 2026-01-09 23:03:09 +01:00 committed by Michael Murphy
parent f6039597b7
commit b9c24d2421
6 changed files with 122 additions and 19 deletions

View file

@ -63,6 +63,10 @@ impl<Message> Button<'_, Message> {
Self {
id: Id::unique(),
label: Cow::Borrowed(""),
#[cfg(feature = "a11y")]
name: Cow::Borrowed(""),
#[cfg(feature = "a11y")]
description: Cow::Borrowed(""),
tooltip: Cow::Borrowed(""),
on_press: None,
width: Length::Shrink,
@ -136,8 +140,10 @@ impl<'a, Message: Clone + 'static> From<Button<'a, Message>> for Element<'a, Mes
#[cfg(feature = "a11y")]
{
if !builder.label.is_empty() {
button = button.name(builder.label);
button = button.name(builder.label)
}
button = button.description(builder.description);
}
if builder.tooltip.is_empty() {