Topic: Custom toolbar buttons lose their keyboard focus indicator
tinyPatchLab
asked a week ago
We added an application stylesheet for the calendar toolbar. The buttons look correct with the mouse, but tabbing across them no longer shows which action has focus. The browser still activates the focused button when Enter is pressed.
The stylesheet removes both outline and box-shadow from the toolbar's buttons. We added a darker hover background, but that does not appear during keyboard navigation. How can we restore a visible keyboard state without changing every button template?
Arkadiusz Idzikowski
staff answered a week ago
The blanket outline and box-shadow removal is hiding the focus indicator. Remove that rule, or replace it with an explicit focus-visible style scoped to your toolbar. A hover rule does not provide a keyboard focus state.
The example adds an outline without changing the button's size. Choose a color that remains distinguishable against both the button and its surroundings, and make sure a parent container does not clip it. Test all actions with Tab and Shift+Tab after the stylesheet is applied.
.calendar-toolbar button:focus-visible {
outline: 3px solid #163d71;
outline-offset: 3px;
}
https://mdbootstrap.com/docs/angular/components/buttons/
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: MDB Angular
- MDB Version: MDB5 9.1.0
- Device: Desktop
- Browser: Firefox
- OS: Ubuntu
- Provided sample code: No
- Provided link: No