Chakra React Select

6.1.1 · active · verified Sun Apr 19

chakra-react-select is a comprehensive wrapper that integrates the popular `react-select` component library with Chakra UI, providing accessible and customizable dropdown, combobox, and multi-select inputs. It is currently in version 6.1.1 and actively maintained, with frequent releases addressing bug fixes, dependency updates, and new features. The library closely follows major versions of Chakra UI, with v6 specifically introducing compatibility for Chakra UI v3. It differentiates itself by seamlessly blending the extensive feature set and customization capabilities of `react-select` with Chakra UI's styling system and accessibility principles, offering a unified developer experience. It also provides built-in support for theme integration, including color palettes and dark mode with `next-themes`.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a basic Chakra `Select` component with a list of fruit options, showcasing state management for selection and custom color scheme integration within a Chakra UI provider.

import React, { useState } from 'react';
import Select from 'chakra-react-select';
import { ChakraProvider, extendTheme } from '@chakra-ui/react';

const theme = extendTheme({
  colors: {
    brand: {
      50: '#E6FFFA',
      100: '#B2F5EA',
      200: '#81E6D9',
      300: '#4FD1C5',
      400: '#38B2AC',
      500: '#319795',
      600: '#2C7A7B',
      700: '#285E61',
      800: '#234E52',
      900: '#1D4044'
    }
  }
});

interface Option {
  value: string;
  label: string;
}

const options: Option[] = [
  { value: 'apple', label: 'Apple' },
  { value: 'banana', label: 'Banana' },
  { value: 'cherry', label: 'Cherry' }
];

function App() {
  const [selectedValue, setSelectedValue] = useState<Option | null>(null);

  return (
    <ChakraProvider theme={theme}>
      <div style={{ padding: '20px', maxWidth: '400px', margin: 'auto' }}>
        <Select
          name="fruits"
          options={options}
          placeholder="Select a fruit..."
          closeMenuOnSelect={true}
          selectedOptionColorScheme="brand"
          onChange={(newValue) => {
            setSelectedValue(newValue as Option);
            console.log('Selected value:', newValue);
          }}
          value={selectedValue}
        />
      </div>
    </ChakraProvider>
  );
  }

export default App;

view raw JSON →