Context
Frontblocks should support smooth scrolling for same-page anchor links, especially for landing pages, documentation pages, and block-based layouts.
The implementation should follow accessibility best practices described here:
https://css-tricks.com/smooth-scrolling-accessibility/
Requirements
- Add smooth scrolling for same-page anchor links.
- Only target valid internal hash links.
- Ignore external links.
- Ignore empty hashes such as
# and #0.
- Respect
prefers-reduced-motion.
- Ensure keyboard focus moves to the target element after scrolling.
- If the target element is not naturally focusable, temporarily add
tabindex="-1" before focusing it.
- Preserve or update the URL hash correctly.
- Avoid issues with sticky headers.
- Keep the implementation lightweight and dependency-free.
Suggested approach
Use native CSS when possible:
@media (prefers-reduced-motion: no-preference) {
html {
scroll-behavior: smooth;
}
}
Context
Frontblocks should support smooth scrolling for same-page anchor links, especially for landing pages, documentation pages, and block-based layouts.
The implementation should follow accessibility best practices described here:
https://css-tricks.com/smooth-scrolling-accessibility/
Requirements
#and#0.prefers-reduced-motion.tabindex="-1"before focusing it.Suggested approach
Use native CSS when possible: