Back to Components

Elastic Dropdown

A single elastic dropdown whose outline itself deforms open and closed via a mass-spring simulation, with full keyboard, ARIA listbox, and click-outside support.

Preview

Installation

Install the component using the CLI.

npx shadcn@latest add https://shreyashtech.me/r/elastic-dropdown.json

Usage

Import the component:

import ElasticDropdownShowcase, { ElasticDropdown } from "@/components/elastic-dropdown"

Use it in your code:

<ElasticDropdown placeholder="Project" onChange={(value) => console.log(value)} />

Props

PropertyTypeDefaultDescription
optionsElasticDropdownOption[]Personal / Work / Design / DevelopmentSelectable options, each with a value, label, and optional icon.
valuestring-Controlled selected value. Pass with onChange to control the dropdown externally.
defaultValuestring-Initial selected value for uncontrolled use.
onChangefunction-Called with the newly selected option's value.
placeholderstring"Select option"Trigger text shown when nothing is selected.
placeholderIconIconComponentFolderIconIcon shown next to the placeholder text.
disabledbooleanfalseDisable the trigger and prevent opening.
classNamestring-Extra classes applied to the outermost wrapper.