NativeSelect

Capture user feedback limited to large set of options
Import

Usage

This is anonymous
Radius
xs
sm
md
lg
xl
Size
xs
sm
md
lg
xl
<NativeSelect
data={[
{ value: 'react', label: 'React' },
{ value: 'vue', label: 'Vue' },
{ value: 'ng', label: 'Angular' },
{ value: 'svelte', label: 'Svelte' },
]}
placeholder="Pick one"
label="Select your favorite framework/library"
description="This is anonymous"
required
/>

Controlled

import { useState } from 'react';
import { NativeSelect } from '@mantine/core';
function Demo() {
const [value, setValue] = useState('');
return <NativeSelect value={value} onChange={(event) => setValue(event.currentTarget.value)} />;
}

Invalid state and error

Pick at least one item
// Error as boolean – red border color
<NativeSelect error />
// Error as React node – red border color and message below input
<NativeSelect error="Pick at least one item" />

Disabled state

<NativeSelect disabled />

With icon

<NativeSelect icon={<HashIcon />} />

Right section

You can replace icon in right section with rightSection prop. Note that in this case clearable option will not work and will need to handle it yourself:

<NativeSelect rightSection={<ChevronDownIcon />} />

Get input ref

import { useRef } from 'react';
import { NativeSelect } from '@mantine/core';
function Demo() {
const ref = useRef();
return <NativeSelect ref={ref} />;
}

Accessibility

Provide aria-label in case you use component without label for screen reader support:

<NativeSelect /> // -> not ok, select is not labeled
<NativeSelect label="My select" /> // -> ok, select and label is connected
<NativeSelect aria-label="My select" /> // -> ok, label is not visible but will be announced by screen reader
Build fully functional accessible web applications faster than ever
Feedback
Your feedback is most valuable contribution to the project, please share how you use Mantine, what features are missing and what is done good
Leave feedback