Multi Level Select

Default


The MultiLevelSelect kit renders a multi leveled select dropdown based on data from the user. treeData is a required prop that is expected to contain the data in the form of an array of objects. See code snippet for an example data array.

For the React version of the kit, the onSelect prop returns an array of objects. This array contains all checked items irrespective of whether it is a parent, child or grandchild. Open the console on this example and check and uncheck checkboxes to see this is action!

For the Rails version of the kit, there is no onselect. The form submits as a array of strings, following the typical rails pattern of utilizing hidden inputs. The strings are the values of the selected items' ids. For example, ["103", "106", "107"].

Single Select


Optionally enable the single variant to replace checkboxes with radios so the input accepts and returns only a single selection.

Single Select w/ Hidden Radios


Dynamically control your selectable options by passing hideRadio: true to any node within your tree data to omit that node's radio selector. In this example we've hidden all radios except ultimate children (nodes without descendants).

Return All Selected


The returnAllSelected or return_all_selected prop can be used when users want data on all checked nodes from the dropdown, irrespective of whether it is a parent or child node.

NOTE: This variant also does not automatically uncheck the parent when any of the child nodes are unchecked. returnAllSelected is set to false by default.

NOTE: For larger trees that may return many pill selections, you can optionally set input_display: "none"(for Rails) or inputDisplay = "none"(for React) to hide all pills within the input.

With Input Display None


Use the inputDisplay/input_display prop to optionally display only the count in the display as opposed to multiple pills. This prop is set to 'pills' by default.

NOTE: inputDisplay/input_display is particularly useful for larger trees that may return many pill selections, helping to keep the input field clean and compact. This prop should not be used with the Single Select variant.

Selected Ids


selected_ids is an optional prop that accepts an array of ids that, if present, will mark the corresponding nodes on the treeData as checked on page load.

Items that include checked:true on the treeData itself will also be selected on page load, even without being passed to selectedIds.

When an item is marked as checked on page load by any means, the dropdown will expand to show the checked items for easier accessibility.

When using selected_ids and variant: "single" together (see single select doc examples), the selected_ids array should contain only one id, because only one item can be selected and displayed at a time. If the selected_ids array has multiple ids in it, the first id in the array will be the treeData node checked upon page load.

With Form


With Pills (Custom Color)


Change the form pill color by passing the optional pill_color prop. Product, Data, and Status colors are available options. Check them out here in the Form Pill colors example.

Reset Selection


In order to clear the multilevelselect selection using an external trigger (like a reset button), the clearMultiLevelSelect function can be used. See the code snippet below to see this in action. The function is scoped by id so an id MUST be used on the multilevelselect kit and passed to the function as shown for it to work.

With Label


The MultiLevelSelect component optionally accepts a label prop to produce a label above the input.

Add an id to wire the label to the input so that clicking the label will move focus directly to the input, and open the drop-down.

Error


Disabled Input


Disabled Options (Default)


To disable individual items in the treeData, include disabled:true within the object on the treeData that you want disabled. See the code snippet below for an example of how to do this.

If a parent is selected, the parent will be returned in the selected items list, even if it has disabled children.

Disabled Options (Return All Selected)


Individual items can also be disabled by including the disabled:true within the object on the treeData for the returnAllSelected/return_all_selected variant. As noted above, this variant will return data on all checked nodes from the dropdown, irrespective of whether it is a parent or child node.

Disabled Parent Option (Default)


For the default variant, disabling the parent item will automatically disable it's children as well.

If you want to be able to disable a parent WITHOUT disabling it's children, use the returnAllSelected/return_all_selected variant.

Disabled Parent Option (Return All Selected)


For the returnAllSelected/return_all_selected variant, disabling the parent item will NOT automatically disable it's children since this version allows you to select a parent even if all children are unselected.

You can manually pass disabled:true to any and all children of a disabled parent if you want to do so.

Disabled Options (Single Select)


Individual items can be disabled by including disabled: true within the object on the treeData for the single variant. Disabled options are visibly disabled in the dropdown UI and cannot be selected via mouse click or keyboard navigation. When a parent node is disabled, all of its children are automatically disabled as well.

Required Indicator


The requiredIndicator/required_indicator prop displays a red asterisk (*) next to the label, visually indicating that the field is required. This is purely visual and does not enforce validation.

You can use requiredIndicator/required_indicator with any validation approach: HTML5 validation via the required prop, client-side validation, or backend validation. For this reason, it works independently and doesn't need to be paired with the required prop.

Placeholder


Use the placeholder prop to customize the initial text shown in the input when nothing is selected. The default is Start typing....



Available Props

Props Type Values

align_content

enum | responsive
start
end
center
spaceBetween
spaceAround
spaceEvenly

align_items

enum | responsive
start
end
center

border_radius

enum
none
xs
sm
md
lg
xl
rounded

cursor

enum
auto
default
none
contextMenu
help
pointer
progress
wait
cell

dark

boolean
true
false

flex

enum | responsive
auto
initial
0
1
2
3
4
5
6
7
8
9
10
11
12
none

flex_direction

enum | responsive
row
column
rowReverse
columnReverse

flex_wrap

enum | responsive
wrap
nowrap
wrapReverse

justify_content

enum | responsive
start
end
center
spaceBetween
spaceAround
spaceEvenly

line_height

enum
loosest
looser
loose
normal
tight
tighter
tightest

margin_right

array
none
xxs
xs
sm
md
lg
xl

margin_left

array
none
xxs
xs
sm
md
lg
xl

margin_top

array
none
xxs
xs
sm
md
lg
xl

margin_bottom

array
none
xxs
xs
sm
md
lg
xl

margin_x

array
none
xxs
xs
sm
md
lg
xl

margin_y

array
none
xxs
xs
sm
md
lg
xl

margin

array
none
xxs
xs
sm
md
lg
xl

width

string

min_width

string

max_width

string

gap

string | responsive

column_gap

string | responsive

row_gap

string | responsive

number_spacing

enum
tabular

order

enum | responsive
none
first
1
2
3
4
5
6
7
8
9
10
11
12

overflow_x

enum
scroll
visible
hidden
auto

overflow_y

enum
scroll
visible
hidden
auto

overflow

enum
scroll
visible
hidden
auto

padding_right

array
none
xxs
xs
sm
md
lg
xl

padding_left

array
none
xxs
xs
sm
md
lg
xl

padding_top

array
none
xxs
xs
sm
md
lg
xl

padding_bottom

array
none
xxs
xs
sm
md
lg
xl

padding_x

array
none
xxs
xs
sm
md
lg
xl

padding_y

array
none
xxs
xs
sm
md
lg
xl

padding

array
none
xxs
xs
sm
md
lg
xl

position

enum
relative
absolute
fixed
sticky
static

shadow

enum
none
deep
deeper
deepest

text_align

enum | responsive
start
end
left
right
center
justify
justifyAll
matchParent

truncate

enum
none
1
2
3
4
5

vertical_align

enum | responsive
baseline
super
top
middle
bottom
sub
text-top
text-bottom

z_index

enum | responsive
1
2
3
4
5
6
7
8
9
10
max

top

enum | object
xxs
xs
sm
md
lg
xl
xxl

inset

boolean
true
false

right

enum | object
xxs
xs
sm
md
lg
xl
xxl

bottom

enum | object
xxs
xs
sm
md
lg
xl
xxl

left

enum | object
xxs
xs
sm
md
lg
xl
xxl

height

string

max_height

string

min_height

string

hover

object

group_hover

boolean
true
false
Props Type Values Default

disabled

boolean
true
false
false

error

string

input_display

"pills" | "none"
pills
none
pills

input_name

string

label

string

name

string

required

boolean
true
false
false

required_indicator

boolean
true
false
false

return_all_selected

boolean
true
false
false

show_checked_children

boolean
true
false
true

tree_data

{ [key: string]: string }[] | any

on_change

function

on_select

function

placeholder

string
Start typing...

selected_ids

string[] | any

variant

"multi" | "single"
multi
single
multi

wrapped

boolean
true
false
false

pill_color

enum
primary
neutral
success
warning
error
info
data_1
data_2
data_3
data_4
data_5
data_6
data_7
data_8
windows
siding
roofing
doors
gutters
solar
insulation
accessories
primary