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
818
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-07431f4b1-241030
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2M
increased by7.76%
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 30 Oct 2024

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