Files
SlpSoftware/src/components/layout/SkipLink.tsx
T

25 lines
762 B
TypeScript

import { t } from '../../i18n';
/**
* "Naar de inhoud" link for keyboard and screen-reader users (WCAG 2.4.1). Hidden until focused.
* Handled in script because the app uses hash routing (a plain #main anchor would be taken by the
* router, see utils/scrollToHash).
*/
export function SkipLink() {
return (
<a
href="#main"
onClick={(event) => {
event.preventDefault();
const main = document.getElementById('main');
main?.focus();
main?.scrollIntoView({ block: 'start' });
}}
className="sr-only z-50 bg-white px-4 py-3 text-base font-bold text-[#0e0d0d] focus:not-sr-only focus:fixed focus:left-4 focus:top-4"
data-testid="skip-link"
>
{t('common.aria.skipLink')}
</a>
);
}