Socket
Socket
Sign inDemoInstall

@dnd-kit/accessibility

Package Overview
Dependencies
4
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @dnd-kit/accessibility

A generic toolkit to help with accessibility


Version published
Weekly downloads
1.7M
decreased by-1.5%
Maintainers
1
Created
Weekly downloads
 

Package description

What is @dnd-kit/accessibility?

@dnd-kit/accessibility is a package that provides accessibility utilities for drag-and-drop interactions in web applications. It is part of the @dnd-kit suite, which is a set of utilities for building drag-and-drop interfaces in React. The package focuses on ensuring that drag-and-drop interactions are accessible to users with disabilities, providing keyboard navigation and screen reader support.

What are @dnd-kit/accessibility's main functionalities?

Keyboard Navigation

This feature allows users to navigate and interact with draggable items using the keyboard. The code sample demonstrates how to set up a draggable item with keyboard navigation support using the useKeyboardSensor hook.

import { useDraggable } from '@dnd-kit/core';
import { useKeyboardSensor, useSensor, useSensors } from '@dnd-kit/accessibility';

function DraggableItem() {
  const sensors = useSensors(
    useSensor(useKeyboardSensor)
  );
  const { attributes, listeners, setNodeRef } = useDraggable({ id: 'draggable-item', sensors });

  return (
    <div ref={setNodeRef} {...attributes} {...listeners}>
      Drag me
    </div>
  );
}

Screen Reader Announcements

This feature provides screen reader announcements for drag-and-drop interactions. The code sample shows how to use the useLiveRegion hook to announce the start and end of a drag operation to screen reader users.

import { useDraggable } from '@dnd-kit/core';
import { useLiveRegion } from '@dnd-kit/accessibility';

function DraggableItem() {
  const { attributes, listeners, setNodeRef } = useDraggable({ id: 'draggable-item' });
  const announce = useLiveRegion();

  const handleDragStart = () => {
    announce('Drag started');
  };

  const handleDragEnd = () => {
    announce('Drag ended');
  };

  return (
    <div ref={setNodeRef} {...attributes} {...listeners} onDragStart={handleDragStart} onDragEnd={handleDragEnd}>
      Drag me
    </div>
  );
}

Other packages similar to @dnd-kit/accessibility

Readme

Source

@dnd-kit/accessibility

Stable release

A generic set of components and hooks to help with live region announcements and screen reader instructions. This package is used internally by @dnd-kit/core.

FAQs

Last updated on 06 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc