SelectList

A component for displaying a list of interactive items, with support for keyboard navigation, single or multiple selection, and row actions.

A SelectList consists of a container element, with rows of data inside. The rows within a list may contain focusable elements or plain text content. If the list supports row selection, each row includes a selection checkbox.

SelectList can be used to select multiple items from a list simultaneously. It provides a familiar interface where users can select multiple items.

Import

import { SelectList } from '@marigold/components';

Props

SelectList

PropertyTypeDefaultDescription
downloadstring | boolean | undefinednoneCauses the browser to download the linked URL. A string may be provided to suggest a file name.
hrefstring | undefinednoneA URL to link to.
pingstring | undefinednoneA space-separated list of URLs to ping when the link is followed.
textValuestring | undefinednoneA string representation of the item's contents, used for features like typeahead.
onScroll(e: React.UIEvent<HTMLDivElement, UIEvent>) => voidnoneHandler that is called when a user scrolls.
renderEmptyState(props: GridListRenderProps) => React.ReactNodenoneProvides content to display when there are no items in the list.

SelectList.Item

PropertyTypeDefaultDescription
dependenciesany[] | undefinednoneValues that should invalidate the item cache when using dynamic collections.
disabledBehaviorDisabledBehavior | undefinednoneWhether disabledKeys applies to all interactions, or only selection.
disallowEmptySelectionboolean | undefinedfalseWhether the collection allows empty selection.
dragAndDropHooksDragAndDropHooks | undefinednoneThe drag and drop hooks returned by useDragAndDrop used to enable drag and drop behavior for the GridList.
itemsIterable<object> | undefinednoneItem objects in the collection.
selectedKeys"all" | Iterable<Key> | undefinednoneThe currently selected keys in the collection (controlled).
selectionMode"multiple" | "none" | "single" | undefinednoneThe type of selection that is allowed in the collection.
selectionBehavior"replace" | "toggle" | undefinednoneHow multiple selection should behave in the collection.
slotstring | null | undefinednoneA slot name for the component. Slots allow the component to receive props from a parent component. An explicit null value indicates that the local props completely override all props received from a parent.
refRef<HTMLUListElement> | undefinedfullAllows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).
onAction(key: Key) => voidnoneHandler that is called when a user performs an action on an item. The exact user event depends on the collection's selectionBehavior prop and the interaction modality.
onSelectionChange(key: Key) => anynoneHandler that is called when the selection changes.
onScroll(e: React.UIEvent<HTMLDivElement, UIEvent>) => voidnoneHandler that is called when a user scrolls.
renderEmptyState(props: GridListRenderProps) => React.ReactNodenoneProvides content to display when there are no items in the list.

Examples

Standard SelectList

This example shows the standard appearance for SelectList component.

Ticket 123
Ticket 456
Ticket 789
Ticket 012

SelectList with single selection mode

Credit Card
Debit Card
Bank Transfer
PayPal
Current Payment is: bankTransfer

SelectList with multiple selection mode

Charizard
Blastoise
Venusaur
Pikachu
charizard