Fine-tune light, shadows, borders, neumorphic
Light and shadows
Borders
Neumorphic
Forms Form-associated

TreeSelect <pm-tree-select>

Tree select: choose from a hierarchy shown as an expandable tree in a dropdown (folders, departments, categories).

Full screen

Props

<script type="module"> import '@prismora/css'; import '@prismora/elements/tree-select'; </script> <pm-tree-select label="Folders" name="folders" multiple searchable value="invoices,q1" style="inline-size: min(100%, 20rem)" options='[{"value":"docs","label":"Documents","children":[{"value":"invoices","label":"Invoices"},{"value":"contracts","label":"Contracts"},{"value":"reports","label":"Reports","children":[{"value":"q1","label":"Q1 report"},{"value":"q2","label":"Q2 report"}]}]},{"value":"media","label":"Media","children":[{"value":"photos","label":"Photos"},{"value":"video","label":"Video"}]},{"value":"archive","label":"Archive"}]'></pm-tree-select>

Sizes

Set with the size attribute; controls keep touch-sized targets on phones.

size="sm"
size="md"
size="lg"

States

Each state is one attribute.

Disabled
Read-only
Required
Error
With a hint

Overview

Single choice by default; multiple adds tick boxes, and ticking a parent ticks everything under it. Up and Down move, Right opens a branch, Left closes it, Enter or Space chooses, typing in the search box filters. value is the choice, or the ticked items joined with commas when multiple; values is the same as a list. Form-associated: submits the value (one entry per ticked item when multiple).

Attributes

AttributeTypeDefaultDescription
valuesstring—The chosen values as a list: the ticked items with multiple, otherwise the one choice (or none). Setting it sets value (joined with commas). The values='["a","b"]' attribute of 0.2.0 still works; prefer value="a,b".
optionsTreeOption[][]Nested options: { value, label, children? }. Values must be unique across all levels.
valuestring—The chosen value; with multiple, the ticked items (the ones without children) joined with commas.
multiplebooleanfalseAllow several choices, with tick boxes.
namestring—Form field name: the value is submitted under it (one entry per ticked item with multiple).
labelstringChooseVisible label (use hide-label to hide it visually).
placeholderstringSelect…Shown while nothing is chosen.
hintstring—Help text under the field.
errorstring—Custom error message. Setting it marks the field invalid.
size'sm' | 'md' | 'lg'—Field size.
requiredbooleanfalseThe form cannot be submitted until something is chosen.
disabledbooleanfalseNot interactive and not submitted.
searchablebooleanfalseShow a search box that filters the tree.
expand-all
prop: expandAll
booleanfalseStart with every branch open.
hide-label
prop: hideLabel
booleanfalseHide the label visually; it stays the accessible name.
readonlybooleanfalseFocusable and submitted, but the user cannot change the value.

Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.

Events

EventReact / Svelte propDescription
pm-changeonPmChangeThe selection changed. detail.value is detail.values joined with commas.

Methods

checkValidity(), reportValidity(), validate()