diff --git a/packages/webawesome/docs/docs/utilities/visually-hidden.md b/packages/webawesome/docs/docs/utilities/visually-hidden.md index 23e608548..8a0b75077 100644 --- a/packages/webawesome/docs/docs/utilities/visually-hidden.md +++ b/packages/webawesome/docs/docs/utilities/visually-hidden.md @@ -43,6 +43,63 @@ Adding a label may seem redundant at times, but they're very helpful for unsight ``` +### Visually Hidden Input Parts + +Sometimes you want a form control to have a cleaner, more minimal appearance by hiding the `label` or `hint` visually. However, removing these elements entirely would make the form inaccessible to users with assistive devices. + +Instead, you can hide them visually while keeping them available to screen readers by adding the `wa-visually-hidden-label` or `wa-visually-hidden-hint` class. + +```html {.example} + + + + + + + + + + United States + Canada + Mexico + United Kingdom + Germany + France + Wakanda + Genovia + Elbonia + + + + + + +``` + ### Force Visually Hidden There are cases where you want to _always_ visually hide certain content, even when it's focused. diff --git a/packages/webawesome/src/styles/utilities/visually-hidden.css b/packages/webawesome/src/styles/utilities/visually-hidden.css index 994cea8bc..a2bb193c0 100644 --- a/packages/webawesome/src/styles/utilities/visually-hidden.css +++ b/packages/webawesome/src/styles/utilities/visually-hidden.css @@ -1,6 +1,8 @@ @layer wa-utilities { .wa-visually-hidden:not(:focus-within), - .wa-visually-hidden-force { + .wa-visually-hidden-force, + .wa-visually-hidden-hint::part(hint), + .wa-visually-hidden-label::part(label) { position: absolute !important; width: 1px !important; height: 1px !important;