Skip to main content

Categorized Multiselect

Use cases:

  • Selecting one or more from a list of options
  • Adding extra information to the options in addition to what is possible with the select and multiselect components

Example

Click the button to open the Categorized Multiselect

Declaration

<rapid-categorized-multiselect></rapid-categorized-multiselect>

Usage

@customElement({
name: 'my-element',
template: html`
<rapid-categorized-multiselect
${ref('multiselect')}
@selectionChange=${(x) => x.onChange()}
:options=${(x) => x.options}
>
</rapid-categorized-multiselect>
`,
})
export class MyElement extends GenesisElement {
@observable multiselect: CategorizedMultiselect;
const options = [
{
type: "First category",
value: 'First value',
label: 'This is the first value',
description:
'Here you can add further information about each categorized multiselect item if you would like to',
},
{
type: "Second category",
value: 'Second value',
label: 'This is the second value',
},
{
type: "Second category",
value: 'Third value',
label: "This is the third value, and it's disabled",
disabled: true,
},
]
onChange() {
// You can also get the selected options via `event.detail`
console.log(this.multiselect.selectedOptions)
}
}

API

Property and attribute binding examples for Genesis Component syntax. Closing tag omitted.

Attributes

NameTypeDescriptionExample
namestringComponent identifier.
<rapid-categorized-multiselect name="myMultiselect">
auto-positionbooleanControls automatic positioning behavior. Default true.
<rapid-categorized-multiselect auto-position>
searchbooleanControls search functionality visibility. Default true.
<rapid-categorized-multiselect search>
disabledbooleanDisables the component. Default false.
<rapid-categorized-multiselect disabled>

Properties

NameTypeDescriptionExample
optionsCategorizedMultiselectOption[]Data options. Default [].
<rapid-categorized-multiselect :options=${() => [
{ type: 'Category 1', value: 'opt1', label: 'Option 1' },
{ type: 'Category 2', value: 'opt2', label: 'Option 2' }
]}>
<rapid-categorized-multiselect :options=${(x) => x.options}>
selectedOptionsstring[]Selected option values. Default [].
<rapid-categorized-multiselect :selectedOptions=${() => ['opt1', 'opt3']}>
<rapid-categorized-multiselect :selectedOptions=${(x) => x.selectedOptions}>
positionPositionControls dropdown position. Default Position.BELOW.
<rapid-categorized-multiselect :position=${() => Position.ABOVE}>
<rapid-categorized-multiselect :position=${(x) => x.dropdownPosition}>

Slots

NameDescription
DefaultFor the component label content
button-contentCustomizable button content (defaults to a plus icon)

Parts

NameDescription
rootThe main container
controlThe control button area
control-buttonThe button element
labelThe component label
optionsThe dropdown options container
filter-searchThe search input field
checkbox-containerContainer for option checkboxes
multiselect-checkboxIndividual checkbox items

Events fired

EventTypeUseExample
selectionChangestring[]Fired when selection changes. The event detail contains an array of selected option values.
<rapid-categorized-multiselect @selectionChange="${(e) => handleSelectionChange(e.detail)}">

Events listened to

This component doesn't listen to any events.