Skip to main content

Select

Basic Example

import { useState } from 'react';
import Select rom '@mavvy/m3-ui/Select';
import Text from '@mavvy/m3-ui/Text';

function SelectExample() {
const [fruit, setFruit] = useState(null);

const options = [
{
text: 'Apple',
value: 'apple',
},
{
text: 'Banana',
value: 'banana',
},
];

const handleChange = (val) => {
setFruit(val);
}

return (
<div>
<Text>Fruit: {fruit}</Text>
<Select
label="Fruits"
onChange={handleChange}
options={options}
value={fruit}
/>
</div>
);
}

Preview

Fruit:

arrow_drop_down

Props

Extends TextField Props

proptypedescription
options{text: string, value: any}[]array of option item to display on the dropdown list
autoCompletebooleanif true, will apply auto complete feature
topbooleanif true, show the dropdown list at the top of the component
ItemComponentReact ComponentRenders a custom component for each item on the list
disableRemoveOverflowbooleandefault behaviour is to add an overflow class to the body, set if to true to disable it
noOptionTextstringif list is empty, show this text