Problem/Motivation
#3584347: Deprecate and replace system_admin_compact_mode() moved the logic which controls the visibility of descriptions from the backend to the frontend. The Hide descriptions / Show descriptions link was inherited from the previous design. The use of a link isn't ideal from an accessibility POV:
As per Curtis Wilcox on slack:
Importantly, the current control changes its name to convey the state, "Hide descriptions" / "Show descriptions"; a control should not use both attributes and name changes to convey state. Attribute changes are more reliably conveyed to screen reader users.
Steps to reproduce
- Install Drupal using the Standard profile.
- Apply or check out the merge request from #3584347.
- Sign in as a user with the Administer permissions permission.
- Visit /admin/people/permissions.
- Locate the Hide descriptions link above the permissions table.
- Inspect the control using browser accessibility tools or a screen reader.
- Confirm that it is exposed as a link, although it changes the state of the page rather than navigating somewhere.
- Activate the link using Enter.
- Confirm that:
- Permission descriptions are hidden.
- The control’s accessible name changes to Show descriptions.
- The control still exposes no programmatically determinable on/off state.
- With focus on the control, press Space.
- Confirm that Space does not activate it, despite the control behaving like a button or switch.
Actual result: The control is exposed as a link. Its name changes between “Hide descriptions” and “Show descriptions,” but its state is not programmatically conveyed. It also lacks the expected Space-key behaviour of a button or switch.
Expected result: The control uses appropriate toggle semantics, exposes its current state programmatically, and supports the standard keyboard interaction for its role. Its accessible name remains stable.

Proposed resolution
Curtis Wilcox further suggests:
Because there's no mixed state (there's no way a user could show only some of the descriptions), [...] a toggle switch could be implemented using
<input type="checkbox" switch>; only Safari has shipped support for the HTML switch attribute but there's a robust polyfill for it.I mainly suggest using that not because I think Safari's move to ship switch was good but because I know the polyfill has done a good job on all the design considerations and I know many others have not. For instance, the "thumb" part of the switch must be at the start position when it's off and the end position when it's on; in left-to-right languages like English, that's left for off, right for on.
The HTML might be something like this (I mildly prefer the input being visually before the label but either is fine):
<div class="compact"> <input id="compact-switch" type="checkbox" switch> <label for="compact-switch">Hide Descriptions</label> </div>
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | 3593539-replace-compact-mode-link-with-switch-2.patch | 13.02 KB | mgifford |
| #15 | Slider-deselected.png | 293.58 KB | mgifford |
| #15 | Slider-selected.png | 300.12 KB | mgifford |
| #14 | 3593539-replace-compact-mode-link-with-switch.patch | 14.37 KB | mgifford |
| #13 | Hide.png | 94.32 KB | mgifford |
Comments
Comment #2
znerol commentedComment #3
znerol commentedComment #4
kentr commentedTo me, it would be good to create a generic Switch element that can be used in other cases. The admin compact mode toggle could then use that.
Default admin already has some functionality related to this, used for general checkboxes. Perhaps some of it could be moved to central libraries (or removed, if the polyfill takes care of it).
Comment #5
kentr commentedI'm noting a discussion regarding the limitations of Safari's
switchelement: https://github.com/whatwg/html/issues/4180#issuecomment-1991750824Ability to be styled might be a sticking point for using it along with the polyfill. I played around with the polyfill demo in Safari and haven't figured out how to style it yet.
I recall reading somewhere that Apple's stance on this is that some UI elements shouldn't change style between websites and native apps (I might be misremembering).
But I also know that difficulty with styling UI components has caused accessibility problems for us, such as with the color contrast ratio of placeholders in date / time fields (
<input type="date">, for example).Adding Accessibility and Usability tags.
Comment #6
alexpott+1,000,000
This would be fantastic. FWIW the experimental default_admin theme already converts single checkboxes to a switch so maybe we can look at bringing this into core and making it intentional instead of magical.
Comment #7
kentr commentedIt seems that this will only be relevant when the behavior changes to JavaScript in #3584347: Deprecate and replace system_admin_compact_mode(), so postponing on that.
I think it will also be related to SC 4.1.2 Name, Role, Value (Level A) because the
linkrole of the current markup will be incorrect when this control is a JavaScript toggle of any kind.In the larger picture, I think that changing to switches will also apply in cases like the "Show / Hide all columns" button for responsive tables. I think the consistency will be better for UX.
I gave credit to @cwilcox808 for his help in Slack.
Comment #8
kentr commentedComment #9
kentr commentedInteresting that Adrian Roselli recommended against using the
switchrole and recommends using abuttoninstead.Comment #10
kentr commentedFollowup to #9:
@cwilcox808 said in Slack that he thinks the current browser situation with regard to announcing the changes for
role="switch"is fine.Comment #11
mgiffordLooking at CanIUse.com https://caniuse.com/wf-switch-control
it still looks like full support for "switch" only comes with Safari.
A possible pollyfill https://blog.tomayac.com/2026/01/12/a-polyfill-for-the-html-switch-element/
Comment #12
kentr commented@mgifford, @cwilcox808 said the polyfill does a good job.
Followup to #5: It might by style-able by using
appearance: none.Comment #13
mgiffordAdding steps (created by AI). Definitely helped me understand the issue better.
Comment #14
mgiffordThe patch (generated by AI) I need to test this tomorrow:
Comment #15
mgiffordBetter patch (there was a reference to a File to patch: core/themes/stable9/templates/admin/admin-page.html.twig in the other one for some reason).
Works with space now. Screenshot included the voiceover text.
I haven't made a MR as this is still dependant on an upstream patch.