Select

The Select component provides a way for the user to choose between several options within a dropdown.

Props

NameTypeDescriptionRequiredDefault

label

string

Text that sits inside of the input and floats above the cursor in the input on focus.

null

options

array

List of options that will be populated into the select dropdown.

excludeDefaultOptions

boolean

Determines whether to show "None" as the first option within the select dropdown.

onSelect

function

Executes the provided function when the user chooses an option within the select dropdown.

selected

number

The array of the selected option within the select dropdown.

null

validationError

string

Error text that renders beneath the email input.

null

tooltip

string

Text that appears when hovering over the select.

null

Examples

import { whisper } from '@oliveai/ldk';
import { WhisperComponentType } from '@oliveai/ldk/dist/whisper/types';

export const selectWhisper = async () => {
  await whisper.create({
    label: 'Select',
    components: [
      {
        type: WhisperComponentType.Select,
        excludeDefaultOption: false,
        label: 'Select Label',
        options: [
          'Option One',
          'Option Two',
          'Option Three',
        ],
        selected: 0,
        onSelect: (error, value) => {
          console.log('Selected: ', value);
        },
        validationError: '',
      },
    ],
  });
}

Last updated