Skip to main content

Dropdown

The Dropdown component is a form control that allows users to select a single option from a list of choices.

Basic Usage

import { Dropdown, ThemeProvider } from "@carton-org/react-neumorphism";

const MyComponent = () => {
const options = [
{ label: "Option 1", value: "1" },
{ label: "Option 2", value: "2" },
{ label: "Option 3", value: "3" },
];

const handleChange = (value: string) => {
console.log("Selected value:", value);
};

return (
<Dropdown
options={options}
placeholder="Select an option"
onChange={handleChange}
size="md"
/>
);
};

Live Example

Select an option
Option 1
Option 2
Option 3

Props

NameTypeDescriptionRequiredDefault Value
valuestringCurrently selected valueNo-
placeholderstringPlaceholder text when no option is selectedNo-
optionsArray<{ label: string, value: string }>Array of options to display in the dropdownYes-
onChange(value: string) => voidCallback function when selection changesYes-
size"xs" | "sm" | "md" | "lg" | "xl"Size of the dropdownNo"sm"
dropdownHeaderLabelStyleReact.CSSPropertiesCustom styles for the dropdown header labelNo-
dropdownHeaderStyleReact.CSSPropertiesCustom styles for the dropdown headerNo-
dropdownContentStyleReact.CSSPropertiesCustom styles for the dropdown contentNo-
dropdownOptionLabelStyleReact.CSSPropertiesCustom styles for the dropdown option labelsNo-
dropdownOptionItemStyleReact.CSSPropertiesCustom styles for the dropdown option itemsNo-

Examples

Different Sizes

Small Size

Small dropdown
Small Option 1
Small Option 2

Medium Size

Medium dropdown
Medium Option 1
Medium Option 2

Large Size

Large dropdown
Large Option 1
Large Option 2

With Selected Value

Option 2
Option 1
Option 2
Option 3