Socket
Book a DemoInstallSign in
Socket

@react-aria/selection

Package Overview
Dependencies
Maintainers
2
Versions
1100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-aria/selection

Spectrum UI components in React

3.0.0-nightly.1081
Source
npmnpm
Version published
Weekly downloads
1.3M
-15.87%
Maintainers
2
Weekly downloads
 
Created

What is @react-aria/selection?

@react-aria/selection is a library that provides React hooks for managing selection state in components. It is part of the React Aria collection of hooks and components that help build accessible user interfaces. This package is particularly useful for creating custom selection logic in lists, tables, and other components where users need to select one or more items.

What are @react-aria/selection's main functionalities?

useSelectableCollection

The `useSelectableCollection` hook is used to manage the selection state of a collection of items. It supports multiple selection modes and provides properties and methods to handle item selection.

import { useSelectableCollection } from '@react-aria/selection';

function MyComponent() {
  let state = useSelectableCollection({
    selectionMode: 'multiple',
    disallowEmptySelection: false
  });

  return (
    <div>
      {state.collection.map(item => (
        <div key={item.key} {...state.getItemProps(item)}>
          {item.rendered}
        </div>
      ))}
    </div>
  );
}

useSelectableItem

The `useSelectableItem` hook is used to manage the selection state of an individual item within a collection. It provides properties and methods to handle item selection and focus.

import { useSelectableItem } from '@react-aria/selection';

function SelectableItem({ item, state }) {
  let ref = React.useRef();
  let { itemProps } = useSelectableItem({
    key: item.key,
    ref,
    state
  });

  return (
    <div {...itemProps} ref={ref}>
      {item.rendered}
    </div>
  );
}

Other packages similar to @react-aria/selection

FAQs

Package last updated on 11 Jun 2021

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.