Skip to content

Instantly share code, notes, and snippets.

@mayognaise
Last active September 28, 2023 21:56
Show Gist options
  • Save mayognaise/4cb4f408fe45f91ca3cd6ef51d1c04d6 to your computer and use it in GitHub Desktop.
Save mayognaise/4cb4f408fe45f91ca3cd6ef51d1c04d6 to your computer and use it in GitHub Desktop.
Set `aria-live` manually here as we cannot use Swiper's navigation since we use custom arrows.
/**
* Set `aria-live` manually here as we cannot use Swiper's navigation since we use custom arrows.
*/
function setAriaLive(el: HTMLDivElement | null, value: string) {
if (!el) return;
el.innerHTML = '';
setTimeout(() => {
el.innerHTML = `<div aria-live="polite" aria-atomic="true" className="visually-hidden">${value}</div>`;
}, 100);
}
/* A11y */
.visually-hidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment