npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chakra-combobox

v4.0.4

Published

A combobox componente for Chakra UI.

Readme

Chakra Combobox

chakra-combobox is a library based on Chakra UI that provides an asynchronous Combobox component with support for option virtualization, dynamic data loading, and multiple selection.

Installation

Before using chakra-combobox, install the necessary dependencies:

pnpm add @chakra-ui/react @emotion/react

If using npm or yarn:

npm install @chakra-ui/react @emotion/react

or

yarn add @chakra-ui/react @emotion/react

Basic Usage with React Query

Single Selection

import { AsyncCombobox } from "chakra-combobox";
import { useState } from "react";
import { useInfiniteQuery } from "@tanstack/react-query";
import { getDogBreeds } from "../api/dogs";

const initialPage = 1;

export const BasicAsyncCombobox = () => {
  const [search, setSearch] = useState("");
  const {
    data: dogs,
    fetchNextPage,
    hasNextPage,
    isLoading,
    isFetchingNextPage,
    isSuccess,
  } = useInfiniteQuery({
    queryKey: ["dogs", search],
    queryFn: ({ pageParam = 0 }) =>
      getDogBreeds({ page: pageParam + 1, limit: 10, search }),
    initialPageParam: initialPage - 1,
    getNextPageParam: (data, _, page) => {
      if (data.hasNextPage) return page + 1;
      return;
    },
  });

  const parsedDogsData = isSuccess
    ? dogs?.pages.map(page => page.data).flat()
    : [];

  const [value, setValue] = useState<string[] | undefined>(undefined);

  return (
    <AsyncCombobox
      options={parsedDogsData}
      fetchNextPage={fetchNextPage}
      getOptionLabel={option => option.name}
      getOptionValue={option => option.id.toString()}
      onSearchChange={value => setSearch(value)}
      isLoading={isLoading}
      isFetchingNextPage={isFetchingNextPage}
      placeholder="Select a dog"
      hasNextPage={hasNextPage}
      value={value}
      onSelect={setValue}
    />
  );
};

Multiple Selection

import { AsyncCombobox } from "chakra-combobox";
import { useState } from "react";
import { useInfiniteQuery } from "@tanstack/react-query";
import { getDogBreeds } from "../api/dogs";

const initialPage = 1;

export const MultipleSelectionCombobox = () => {
  const [search, setSearch] = useState("");
  const {
    data: dogs,
    fetchNextPage,
    hasNextPage,
    isLoading,
    isFetchingNextPage,
    isSuccess,
  } = useInfiniteQuery({
    queryKey: ["dogs", search],
    queryFn: ({ pageParam = 0 }) =>
      getDogBreeds({ page: pageParam + 1, limit: 10, search }),
    initialPageParam: initialPage - 1,
    getNextPageParam: (data, _, page) => {
      if (data.hasNextPage) return page + 1;
      return;
    },
  });

  const parsedDogsData = isSuccess
    ? dogs?.pages.map(page => page.data).flat()
    : [];

  const [value, setValue] = useState<string[] | undefined>(undefined);

  return (
    <AsyncCombobox
      options={parsedDogsData}
      fetchNextPage={fetchNextPage}
      getOptionLabel={option => option.name}
      getOptionValue={option => option.nameWithId}
      onSearchChange={value => setSearch(value)}
      isLoading={isLoading}
      isFetchingNextPage={isFetchingNextPage}
      placeholder="Select dogs"
      hasNextPage={hasNextPage}
      value={value}
      onSelect={setValue}
      withCheckmark
      listboxProps={{
        Root: {
          selectionMode: "multiple",
        },
      }}
    />
  );
};

AsyncCombobox Props

| Property | Type | Description | | ------------------------ | ----------------------------------------- | ----------------------------------------------------------- | | options | OptionType[] | List of available options. | | value | string[] \| undefined | Selected values (array for multiple selection). | | onSelect | (option: string[] \| undefined) => void | Function triggered when options are selected. | | getOptionLabel | (option: OptionType) => string | Function returning the option label. | | getOptionValue | (option: OptionType) => string | Function returning the option value. | | placeholder | string | Input placeholder text. | | onSearchChange | (search: string) => void | Function called when typing in the search input. | | isLoading | boolean | Indicates if data is being loaded. | | isFetchingNextPage | boolean | Indicates if the next page is being loaded. | | hasNextPage | boolean | Indicates if there are more options to load. | | fetchNextPage | () => void | Function to load more options. | | isClearable | boolean (optional) | Indicates whether the combobox is clearable. | | insideDialog | boolean (optional) | Set to false when inside dialogs to prevent z-index issues. | | closeOnSelect | boolean (optional) | Close the dropdown when an option is selected. | | dropdownIndicator | ElementType (optional) | Custom component to render the dropdown indicator. | | loadingElement | ReactNode (optional) | Custom loading message element. | | emptyElement | ReactNode (optional) | Custom empty message element. | | searchInputPlaceholder | string (optional) | Custom placeholder for the search input. | | chakraStyles | AsyncComboboxChakraStyles (optional) | Customize the component styles. | | listboxProps | ListboxProps (optional) | Custom props for the listbox component. | | withIndicator | boolean (optional) | Whether to show the dropdown indicator. | | withCheckmark | boolean (optional) | Whether to show checkmarks for selected items. |

Configuration Options

Multiple Selection

To enable multiple selection, configure the listboxProps:

<AsyncCombobox
  // ... other props
  listboxProps={{
    Root: {
      selectionMode: "multiple",
    },
  }}
  withCheckmark // Shows checkmarks for selected items
/>

Inside Dialogs/Modals

When using the combobox inside dialogs or modals, set insideDialog to prevent z-index issues:

<AsyncCombobox
  // ... other props
  insideDialog
/>

Styling

chakra-combobox allows style customization via the chakraStyles property. The library exports the AsyncComboboxChakraStyles type, which you can use to ensure type safety when defining your custom styles:

import { AsyncCombobox, type AsyncComboboxChakraStyles } from "chakra-combobox";

// ... other imports and component code

const customStyles: AsyncComboboxChakraStyles = {
  control: base => ({ ...base, borderColor: "blue.500" }),
  popoverContentCss: base => ({ ...base, background: "gray.50" }),
  option: base => ({ ...base, color: "black" }),
};

<AsyncCombobox
  // ... other props
  chakraStyles={customStyles}
/>;

Virtualization Support

The component uses react-virtual to render only visible elements on the screen, improving performance when dealing with large lists.

Documentation & Demo

For a full demonstration and detailed documentation, visit the Storybook Documentation.

Version 4.0.0 Changes

  • Breaking Change: Added support for multiple selection
  • Breaking Change: value prop now expects string[] | undefined instead of a single option
  • Breaking Change: onSelect callback now receives string[] | undefined
  • New: Added listboxProps for configuring the underlying listbox component
  • New: Added withCheckmark prop to show selection indicators
  • New: Added withIndicator prop to control dropdown indicator visibility
  • New: Added isClearable prop for clearable functionality
  • Improved: Better TypeScript support with generic types
  • Improved: Enhanced dialog/modal support with insideDialog prop

Conclusion

chakra-combobox is a flexible solution for creating highly customizable asynchronous dropdowns with multiple selection support, optimized for performance and seamlessly integrated with Chakra UI.