Skip to Content

NativeSelect

Native select element based on Input. Captures user selection from a dropdown list using the browser’s native select element.

Import

import { NativeSelect } from '@tidbcloud/uikit'

Basic Usage

import { NativeSelect } from '@tidbcloud/uikit' function Demo() { return <NativeSelect data={['React', 'Angular', 'Vue']} /> }

Controlled

import { useState } from 'react' import { NativeSelect } from '@tidbcloud/uikit' function Demo() { const [value, setValue] = useState('') return ( <NativeSelect value={value} onChange={(event) => setValue(event.currentTarget.value)} data={['React', 'Angular', 'Svelte', 'Vue']} /> ) }

Data Formats

The data prop accepts multiple formats:

// Array of strings <NativeSelect data={['React', 'Angular', 'Vue']} /> // Array of objects <NativeSelect data={[ { label: 'React', value: 'react' }, { label: 'Angular', value: 'angular' }, { label: 'Vue', value: 'vue', disabled: true }, ]} /> // Grouped options <NativeSelect data={[ { group: 'Frontend', items: ['React', 'Angular', 'Vue'], }, { group: 'Backend', items: ['Express', 'Django'], }, ]} />

With Sections

import { NativeSelect } from '@tidbcloud/uikit' import { IconHash } from '@tabler/icons-react' function Demo() { return <NativeSelect leftSection={<IconHash size={16} />} label="With left section" data={['React', 'Angular']} /> }

Key Props

PropTypeDescription
dataComboboxDataData used to render options
valuestringControlled input value
onChange(event) => voidCalled when value changes
labelReactNodeInput label
descriptionReactNodeInput description
errorReactNodeError message
disabledbooleanDisables the input
leftSectionReactNodeContent on the left side
rightSectionReactNodeContent on the right side
sizeMantineSizeControls input height and padding
radiusMantineRadiusBorder radius
Last updated on