embla-carousel-aria

An accessibility plugin for Embla Carousel
29,236 14
Install
npm install embla-carousel-aria
Latest Version:8.0.0-rc19
License:MIT
Last Updated:Jun 24, 2024
Links: GitHub  ·  npm
Maintainer: nwidynski

Installation

First you need to follow the installation instructions for Embla Carousel, after that you can add aria support:

npm install --save embla-carousel-aria  # yarn add embla-carousel-aria

JavaScript / TypeScript

import EmblaCarousel from 'embla-carousel';
import AriaPlugin from 'embla-carousel-aria';

// initialize Embla Carousel
const embla = EmblaCarousel(
  emblaNode,
  {
    inViewThreshold: 0.25, // A high view threshold is recommended.
  },
  [AriaPlugin()]
);

React

import { useEmblaCarousel } from 'embla-carousel-react';
import AriaPlugin from 'embla-carousel-aria';

const EmblaCarouselComponent = ({ children }) => {
  const [emblaRef, embla] = useEmblaCarousel(
    {
      inViewThreshold: 0.25, // A high view threshold is recommended.
    },
    [AriaPlugin()]
  );

  // ...
};

Options

locale

Type: string Default: en-US

Locale to be used in IETF's BCP 47 format.

live

Type: false | "off" | "polite" | "assertive" Default: false

Whether the screen reader should announce slide changes. Recommended to be turned off if autoscroll is used.

debounce

Type: number Default: 300

The debounce to use when updating aria properties.

onFocusChange

Type: Function Default: (evt: HTMLElement, target: HTMLElement) => void

A callback function that is invoked when the focus is moved by the Aria plugin.

Global Options

You can also set global options that will be applied to all instances. This allows for overriding the default plugin options with your own:

AriaPlugin.globalOptions = {
  debounce: 1000,
};

OS & Browser Support

  • Mac OS (Chrome, Firefox, Safari, Edge), Magic Mouse, Magic Trackpad
  • Windows (Chrome, Firefox, Edge), Microsoft Precision Touchpads

Thanks

Kudos to David Jerleke for creating Embla Carousel with its open API 🙏

License

MIT.

Related Packages

embla-carousel

A lightweight carousel library with fluid motion and great swipe precision

1,138,077,498 8,453
embla-carousel-reactive-utils

Reactive utilities for Embla Carousel

1,100,861,544 8,453
embla-carousel-autoplay

An autoplay plugin for Embla Carousel

96,012,888 8,453
embla-carousel-fade

A fade plugin for Embla Carousel

34,985,081 8,454
embla-carousel-auto-scroll

An auto scroll plugin for Embla Carousel

25,642,678 8,454

Version History

Pre-releases (6)
Version Released License
8.0.0-rc19 MIT
8.0.0-rc18 MIT
8.0.0-rc17 MIT
8.0.0-rc16 MIT
8.0.0-rc15 MIT