Skip to content

List

List components are Input Fields designed to handle selection from potentially thousands of items efficiently. They use virtualization to only render the items currently visible in the viewport, ensuring high performance regardless of the total data volume.

list.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
uid: 'list_id',
kind: 'input',
type: 'list',
path: 'selection',
label: 'Pick an option',
props: {
items: [
{
template: 'Option 1',
value: '1',
},
{
template: 'Option 2',
value: '2',
},
{
template: 'Option 3',
value: '3',
},
{
template: 'Option 4',
value: '4',
},
{
template: 'Option 5',
value: '5',
},
],
height: 200,
itemHeight: 40,
},
},
],
});

Use these props to customize your List component.

proptypedescription
itemsarrayRequired. Collection of items. Can be strings, numbers, or objects
valuestring | numberThe currently selected value
valueFieldstringThe key to use for the value if items are objects
heightnumberTotal height of the scrollable viewport. Defaults to 300
itemHeightnumberFixed height of each item for virtualization logic. Defaults to 40
hintstringA description to display for accessibility
itemRendererstringKey or identifier for a custom item renderer

Use the property hint to provide additional context for the list.

list.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
uid: 'list_hint',
kind: 'input',
type: 'list',
path: 'selection',
label: 'Pick an option',
props: {
items: [
{
template: 'Option A',
value: 'a',
},
{
template: 'Option B',
value: 'b',
},
],
hint: 'Please select one of the available choices from the list.',
},
},
],
});

Lists can be styled as explained in the Styling Guide.

Following you will find a list with the CSS Variables and a quick description of what you will style.

CSS VariableDescription
--gui-bg-defaultBackground color for the list container
--gui-border-defaultBorder color for the list container
--gui-radius-mdBorder radius for the list container
--gui-intent-primaryBackground color for the selected item
--gui-intent-primary-hoverBackground color for items on hover
--gui-bg-disabledBackground color for disabled items

This is the anatomy of the List Component in case you want to use your CSS styles.

list-anatomy.html
<gui-list>
<div
role="listbox"
class="gui-list__scroll-viewport"
style="height: 200px; overflow-y: auto; position: relative;"
>
<div class="gui-list__spacer" style="height: 200px;"></div>
<div class="gui-list__content" style="transform: translateY(0px); position: absolute; top: 0; left: 0; width: 100%;">
<div class="gui-list__item-wrapper" role="option" aria-selected="true" id="list_id-item-0">
<div class="gui-list__item gui-list__item-selected">Option 1</div>
</div>
<div class="gui-list__item-wrapper" role="option" aria-selected="false" id="list_id-item-1">
<div class="gui-list__item">Option 2</div>
</div>
<!-- More items -->
</div>
</div>
</gui-list>