Skip to content

Instantly share code, notes, and snippets.

@mayognaise
mayognaise / set-aria-live.ts
Last active September 28, 2023 21:56
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);
}