Skip to content

Commit 3de6365

Browse files
authored
Merge pull request #490 from canonical/icon-semantics
feat(a11y): Expose semantic labels for icons
2 parents 82318b7 + 44b3108 commit 3de6365

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/ubuntu_widgets/lib/src/icons.dart

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import 'package:yaru/yaru.dart';
88
/// * [ValidatedFormField]
99
class SuccessIcon extends StatelessWidget {
1010
/// Creates a success icon.
11-
const SuccessIcon({super.key});
11+
const SuccessIcon({super.key, this.semanticLabel});
12+
13+
final String? semanticLabel;
1214

1315
@override
1416
Widget build(BuildContext context) {
1517
return Icon(
1618
Icons.check_circle,
1719
color: Theme.of(context).colorScheme.success,
20+
semanticLabel: semanticLabel,
1821
);
1922
}
2023
}
@@ -25,10 +28,16 @@ class SuccessIcon extends StatelessWidget {
2528
/// * [ValidatedFormField]
2629
class ErrorIcon extends StatelessWidget {
2730
/// Creates an error icon.
28-
const ErrorIcon({super.key});
31+
const ErrorIcon({super.key, this.semanticLabel});
32+
33+
final String? semanticLabel;
2934

3035
@override
3136
Widget build(BuildContext context) {
32-
return Icon(Icons.error, color: Theme.of(context).colorScheme.error);
37+
return Icon(
38+
Icons.error,
39+
color: Theme.of(context).colorScheme.error,
40+
semanticLabel: semanticLabel,
41+
);
3342
}
3443
}

0 commit comments

Comments
 (0)