TanStack Select
repository·main·Indexed 42 days ago
https://github.com/tanstack/selectA headless UI library for building advanced, highly customizable select, autocomplete, and dropdown components. It provides logic, state management, and accessibility features without prescribing styling or DOM structure. Available as a core package (@tanstack/select) for vanilla JavaScript, with dedicated adapters for React (@tanstack/react-select) and Solid (@tanstack/solid-select).
What's inside TanStack Select
- TanStack Select is a headless UI library designed for building advanced, highly customizable select, autocomplete, and dropdown components. Because it is headless, it provides the logic, state management, and accessibility features without prescribing any specific styling or DOM structure, allowing you to build components that match your application's design system perfectly.
Run the Solid basic example
mainTo run the basic Solid implementation example locally, follow these steps in your terminal:
- Install the project dependencies using
npm install. - Start the development server using
npm run dev.
npm install npm run dev- Install the project dependencies using
Install TanStack Select for Solid
mainTo use TanStack Select in a Solid application, install the
@tanstack/solid-selectpackage. This package is compatible with Solid v1.9.5 or higher.npm install @tanstack/solid-selectInstall TanStack Select for React
mainTo use TanStack Select in a React application, install the
@tanstack/react-selectpackage. This package is compatible with React v16.8 or higher.npm install @tanstack/react-selectRun the React basic example
mainTo run the basic React example provided in this repository, use the following commands to install dependencies and start the development server:
npm install npm run devInstall the TanStack Select React Adapter
mainTo use TanStack Select in a React application, install the
@tanstack/react-selectpackage via npm.npm install @tanstack/react-selectInstall TanStack Select
mainInstall the package corresponding to your framework. Use
@tanstack/react-selectfor React applications, or@tanstack/selectfor vanilla JavaScript implementations.# For React npm install @tanstack/react-select # For Vanilla JS npm install @tanstack/select# Npm npm install @tanstack/react-select npm install @tanstack/select # no framework, just vanilla jsInstall TanStack Select Core for Vanilla JS or other frameworks
mainTo use TanStack Select in a Vanilla JS environment or with a framework not explicitly supported by a dedicated package, install the core
@tanstack/selectpackage. Note that the framework-specific packages (@tanstack/react-selectand@tanstack/solid-select) also re-export everything from this core package.npm install @tanstack/selectUse TanStack Select with SolidJS
mainThe
@tanstack/solid-selectpackage provides the SolidJS implementation of TanStack Select. It re-exports all core logic from@tanstack/select, allowing you to use the headless selection logic within SolidJS applications.To use the library, import the hooks or components directly from
@tanstack/solid-select. Note that hooks should be imported individually rather than through barrel files to ensure optimal tree-shaking and compatibility with Solid's reactivity system.import { useSelect } from '@tanstack/solid-select' // Use the hook within a Solid component const MyComponent = () => { const select = useSelect({ // options from @tanstack/select }) return ( // Your Solid implementation ) }Use TanStack Select with React
mainThe
@tanstack/react-selectpackage provides the React implementation of TanStack Select. It re-exports all core functionality from@tanstack/select, allowing you to use the headless select logic within React components.Note on Imports: To ensure optimal tree-shaking and avoid issues with barrel files, it is recommended to import hooks individually rather than from a single entry point if the package structure allows.
import { useSelect } from '@tanstack/react-select'; // Use the hook within your React component function MyComponent() { const select = useSelect({ // options from @tanstack/select }); return <div>{/* Render your select UI using select state */}</div>; }Use the `select` variable
mainThe
selectvariable is a constant string literal used within the TanStack Select ecosystem, typically for identifying the select type or within internal type-checking mechanisms. It is defined as the literal value'select'.const select: "select" = 'select';The `select` constant
mainThe
@tanstack/selectpackage exports a constantselectwith the string value'select'. This is likely used as a type identifier or a key within the TanStack ecosystem to distinguish select-related logic or state.import { select } from '@tanstack/select' console.log(select) // 'select'