Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-aria/selection

Package Overview
Dependencies
Maintainers
2
Versions
848
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.992
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
893K
decreased by-22.62%
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 14 Apr 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

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc