This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@billogram/use-dropdown
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

@billogram/use-dropdown

A React hook for dropdown components

Install

yarn add @billogram/use-dropdown

Usage

import useDropdown from '@billogram/use-dropdown';

See types for exported types.

useDropdown

It is important that implemented dropdowns conform with WAI-ARIA best practices.

const listRef = React.useRef<HTMLElement>(null);
const optionsRef = React.useRef(new Map<number, HTMLElement | null>());

const {
    change,
    close,
    expanded,
    handleKeyDown,
    handleKeyPress,
    highlightedIndex,
    isTypeahead,
    open,
    selectedOption,
    toggle,
} = useDropdown<Options>({
    disabled: false,
    isExpandedInitial: false,
    listNode: listRef.current,
    optionNodes: Array.from(optionsRef.current.values()),
    options: [],
    onChange: noop,
    onClose: noop,
    shouldTriggerChangeOnEnterOrSpace: true,
    value: '',
});

Note

This library is being published with our use cases in mind and is not necessarily meant to be consumed by the broader public. We probably won't take your feature requests unless they align with our own needs.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @billogram/use-dropdown

Weekly Downloads

1

Version

1.3.0

License

MIT

Unpacked Size

65.3 kB

Total Files

39

Last publish

Collaborators

  • andreagylling
  • ewakosciukiewicz
  • irynaziruikina
  • jamesbillo
  • jmfederico
  • miriamlarsson
  • oscarekholm