No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

Select

Usage

import { Select } from '@apitable/components';

Scenes

A drop-down menu pops up for the user to choose.

Examples

option 2

Select action callback

option 2

Placeholder

choose option

Custom width

In some cases, dropdown list needs to be customized according to the length of the content. If so, you can set the dropdownMatchSelectWidth property to false (with a maximum width limit):

option 1 long long long long long
option 1 long long long long long

Option with icon

Each option can set its own pre-icon and suffix-icon, the Icon is imported from the @apitable/icons library.

When the selected option has an icon, the icon will be displayed by default.

test label 1

Note that the trigger itself can also specify the pre-Icon and suffix-Icon. When the selected result also has the corresponding Icon passed in, the Icon specified by the trigger will be higher than the Icon weight of the option.

Option dosabled

When an option cannot be selected, the disabled state can be set for the option, and a reason for not being selected can be provided. When the mouse hovers over the content area, the reason will be displayed.

When an option is too long and the content is not displayed completely, an ellipsis will appear. At this time, hovering over the option will display the complete content of the current option. If the option is disabled at this moment, the weight of disabledTip will be higher than the content.

option 1

Set disabled tips:

option 1

The suffix-icon of an option is special. When an option is in the disabled state, the pre-icon and the text part will turn gray, but the post-icon will keep the original color. And the rear Icon can also have its own hover.

Status prompt, just pass the content in suffixIconTip.

option 2

Select disbaled

label 1

Search option and hightligh keyword

The search is case insensitive in English.

abcdefg

Update hightligh keyword style

abcdefg

Format Selected option

Get option user name by renderValue function:

张三

Select.Option

Instead of using the options props, you can add options through sub-elements, as follows:

label 1

API

NameTypeDescriptionDefault
valuestring / numberselected value, corresponding to the value in option-
onSelected(option: IOption, index: number) => voidselect action callback-
optionsIOption[]dropdown list data-
placeholderstring--
prefixIconReactNodeprefix icon-
suffixIconReactNodesuffix icon-
dropdownMatchSelectWidthbooleanwhether the drop-down box and the trigger keep the same width-
triggerStyleCSSPropertiestrigger inline style-
triggerClsstringtrigger classname-
listClsstringlist classname-
listStyleCSSPropertieslist inline style-
openSearchbooleanwhether to show search-
searchPlaceholderstringsearch placeholder-
highlightStyleCSSPropertiescustom highlight inline style-
noDataTipstring(() => ReactNode)empty data text or UI
hideSelectedOptionbooleanwhether hide selected options-
dropdownRenderReactNodecustom dropdown-
disabledbooleandisabled action-
renderValue(option: IOption) => stringformat select option value-
maxListWidthnumberlimit max list width-
defaultVisibleboolean--
hiddenArrowbooleanhide arrow-
triggerLabelboolean--