Use our Tailwind CSS Select
component to collect user provided information from a list of options.
A Select
component is a dropdown menu for displaying choices. Use the radio component when there are fewer total options (less than 5).
See below our Select
component example that you can use in your Tailwind CSS and React project. The example comes in different colors and styles, so you can adapt it easily to your needs.
import { Select, Option } from "@material-tailwind/react";
export default function Example() {
return (
<div className="w-72">
<Select label="Select Version">
<Option>Material Tailwind HTML</Option>
<Option>Material Tailwind React</Option>
<Option>Material Tailwind Vue</Option>
<Option>Material Tailwind Angular</Option>
<Option>Material Tailwind Svelte</Option>
</Select>
</div>
);
}
The Select
component comes with 3 different variants that you can change it using the variant
prop.
import { Select, Option } from "@material-tailwind/react";
export default function Variants() {
return (
<div className="flex w-full items-end gap-4">
<Select variant="outlined" label="Select Version">
<Option>Material Tailwind HTML</Option>
<Option>Material Tailwind React</Option>
<Option>Material Tailwind Vue</Option>
<Option>Material Tailwind Angular</Option>
<Option>Material Tailwind Svelte</Option>
</Select>
<Select variant="standard" label="Select Version">
<Option>Material Tailwind HTML</Option>
<Option>Material Tailwind React</Option>
<Option>Material Tailwind Vue</Option>
<Option>Material Tailwind Angular</Option>
<Option>Material Tailwind Svelte</Option>
</Select>
<Select variant="static" label="Select Version">
<Option>Material Tailwind HTML</Option>
<Option>Material Tailwind React</Option>
<Option>Material Tailwind Vue</Option>
<Option>Material Tailwind Angular</Option>
<Option>Material Tailwind Svelte</Option>
</Select>
</div>
);
}
The Select
component comes with 2 different sizes that you can change it using the size
prop.
import { Select, Option } from "@material-tailwind/react";
export default function Sizes() {
return (
<div className="flex w-full items-end gap-4">
<Select size="md" label="Select Version">
<Option>Material Tailwind HTML</Option>
<Option>Material Tailwind React</Option>
<Option>Material Tailwind Vue</Option>
<Option>Material Tailwind Angular</Option>
<Option>Material Tailwind Svelte</Option>
</Select>
<Select size="lg" label="Select Version">
<Option>Material Tailwind HTML</Option>
<Option>Material Tailwind React</Option>
<Option>Material Tailwind Vue</Option>
<Option>Material Tailwind Angular</Option>
<Option>Material Tailwind Svelte</Option>
</Select>
</div>
);
}
The Select
component comes with 19 different colors that you can change it using the color
prop, below there are some examples of the colors but you can check all of the them here.
import { Select, Option } from "@material-tailwind/react";
export default function Colors() {
return (
<div className="flex w-72 flex-col gap-4">
<Select color="blue" label="Select Version">
<Option>Material Tailwind HTML</Option>
<Option>Material Tailwind React</Option>
<Option>Material Tailwind Vue</Option>
<Option>Material Tailwind Angular</Option>
<Option>Material Tailwind Svelte</Option>
</Select>
<Select color="purple" label="Select Version">
<Option>Material Tailwind HTML</Option>
<Option>Material Tailwind React</Option>
<Option>Material Tailwind Vue</Option>
<Option>Material Tailwind Angular</Option>
<Option>Material Tailwind Svelte</Option>
</Select>
<Select color="teal" label="Select Version">
<Option>Material Tailwind HTML</Option>
<Option>Material Tailwind React</Option>
<Option>Material Tailwind Vue</Option>
<Option>Material Tailwind Angular</Option>
<Option>Material Tailwind Svelte</Option>
</Select>
</div>
);
}
The Select
component comes with error and success states for performing validations.
import { Select, Option } from "@material-tailwind/react";
export default function Validations() {
return (
<div className="flex w-full items-end gap-4">
<Select label="Select Version" error>
<Option>Material Tailwind HTML</Option>
<Option>Material Tailwind React</Option>
<Option>Material Tailwind Vue</Option>
<Option>Material Tailwind Angular</Option>
<Option>Material Tailwind Svelte</Option>
</Select>
<Select label="Select Version" success>
<Option>Material Tailwind HTML</Option>
<Option>Material Tailwind React</Option>
<Option>Material Tailwind Vue</Option>
<Option>Material Tailwind Angular</Option>
<Option>Material Tailwind Svelte</Option>
</Select>
</div>
);
}
You can modify the open/close state animation for Select
component using the animate
prop.
import { Select, Option } from "@material-tailwind/react";
export default function Example() {
return (
<div className="w-72">
<Select
label="Select Version"
animate={{
mount: { y: 0 },
unmount: { y: 25 },
}}
>
<Option>Material Tailwind HTML</Option>
<Option>Material Tailwind React</Option>
<Option>Material Tailwind Vue</Option>
<Option>Material Tailwind Angular</Option>
<Option>Material Tailwind Svelte</Option>
</Select>
</div>
);
}
A Select
could be disabled as well, it will help you to prevent user interactions like click or focus over the Select
component.
import { Select, Option } from "@material-tailwind/react";
export default function Example() {
return (
<div className="w-72">
<Select label="Select Version" disabled>
<Option>Material Tailwind HTML</Option>
<Option>Material Tailwind React</Option>
<Option>Material Tailwind Vue</Option>
<Option>Material Tailwind Angular</Option>
<Option>Material Tailwind Svelte</Option>
</Select>
</div>
);
}