Skip to content

Select

Dropdown selector component with support for single selection, search, and custom styling.

Quick Start

Basic Usage

MikeTomLucy
html
<r-select style="width: 120px; height: 40px" defaultValue="185">
      <r-option value="185">Mike</r-option>
      <r-option value="186">Tom</r-option>
      <r-option value="187">Lucy</r-option>
</r-select>

API Reference

Select Properties

PropertyTypeDefaultDescription
defaultValuestring''Default selected value
disabledbooleanfalseWhether the select is disabled
typestring'default'Select type: default, text
placementstring'bottom'Dropdown direction: top, bottom
showSearchbooleanfalseWhether to show search box
getPopupContainerIdstring''Container element id for dropdown
dropdownclassstring''Custom class name for dropdown
triggerstring'click'Trigger method: click, hover, click,hover, none

Option Properties

PropertyTypeDefaultDescription
valuestring''Option value
disabledbooleanfalseWhether the option is disabled

Default Value defaultValue

MikeTomLucy
html
<r-select style="width: 120px; height: 40px" defaultValue="185">
      <r-option value="185">Mike</r-option>
      <r-option value="186">Tom</r-option>
      <r-option value="187">Lucy</r-option>
</r-select>

Disabled State disabled

MikeTomLucy
html
<r-select style="width: 120px; height: 40px" disabled defaultValue="185">
      <r-option value="185">Mike</r-option>
      <r-option value="186">Tom</r-option>
      <r-option value="187">Lucy</r-option>
</r-select>

Text Type type

MikeTomLucy
html
<r-select
      style="width: 120px; height: 40px"
      type="text"
      defaultValue="185"
    >
      <r-option value="185">Mike</r-option>
      <r-option value="186">Tom</r-option>
      <r-option value="187">Lucy</r-option>
</r-select>
MikeTomLucy
html
<r-select
      style="width: 120px; height: 40px"
      type="text"
      defaultValue="185"
      placement="top"
    >
      <r-option value="185">Mike</r-option>
      <r-option value="186">Tom</r-option>
      <r-option value="187">Lucy</r-option>
</r-select>

Search Function showSearch

MikeTomLucy
html
<r-select style="width: 120px; height: 40px" showSearch>
<r-option value="185">Mike</r-option>
<r-option value="186">Tom</r-option>
<r-option value="187">Lucy</r-option>
</r-select>

Container Mount getPopupContainerId

html
<r-select getPopupContainerId="elementid">
      <r-option value="185">Mike</r-option>
      <r-option value="186">Tom</r-option>
      <r-option value="187">Lucy</r-option>
</r-select>

Custom Styling dropdownclass

html
<r-select dropdownclass="custom-dropdown">
      <r-option value="185">Mike</r-option>
      <r-option value="186">Tom</r-option>
      <r-option value="187">Lucy</r-option>
</r-select>

Trigger Method trigger

MikeTomLucy
html
<!-- Click trigger (default) -->
<r-select trigger="click">
      <r-option value="185">Mike</r-option>
      <r-option value="186">Tom</r-option>
      <r-option value="187">Lucy</r-option>
</r-select>

<!-- Hover trigger -->
<r-select trigger="hover">
      <r-option value="185">Mike</r-option>
      <r-option value="186">Tom</r-option>
      <r-option value="187">Lucy</r-option>
</r-select>

<!-- Both click and hover -->
<r-select trigger="click,hover">
      <r-option value="185">Mike</r-option>
      <r-option value="186">Tom</r-option>
      <r-option value="187">Lucy</r-option>
</r-select>

<!-- No trigger -->
<r-select trigger="none">
      <r-option value="185">Mike</r-option>
      <r-option value="186">Tom</r-option>
      <r-option value="187">Lucy</r-option>
</r-select>

Events

Change Event

html
<r-select onchange="handleChange">
      <r-option value="185">Mike</r-option>
      <r-option value="186">Tom</r-option>
      <r-option value="187">Lucy</r-option>
</r-select>

<script>
function handleChange(value) {
  console.log('Selected value:', value);
}
</script>

Best Practices

  • Option Count: Enable search when there are many options
  • Trigger Method: Choose appropriate trigger based on user habits
  • Mount Position: Pay attention to dropdown mount position in complex layouts
  • Custom Styling: Use dropdownclass for style customization
  • Disabled Options: Use disabled attribute for unavailable options

Released under the MIT License.