Skip to content

List

List widgets 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.

The simplest way to populate items is a flat array of strings or numbers — the displayed label and the stored value are the same. When you need a separate stored value (e.g. an id behind a human-readable name), pass an array of objects and tell the widget which keys to use via labelField and valueField.

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

Use these props to customize your List widget.

proptypedescription
itemsarrayRequired. Array of strings, numbers, or plain objects. See Using Objects.
hintstringA description to display below the list
labelFieldstringWhen items are objects, the key whose value is shown to the user. Defaults to label.
valueFieldstringWhen items are objects, the key whose value is stored in the form. Defaults to value. Required for selection to emit a primitive.
heightnumberTotal height of the scrollable viewport. Defaults to 300
itemHeightnumberFixed height of each item for virtualization logic. Defaults to 40
itemRendererstringKey of a registered renderer used to draw each item. See Item Renderers

The top-of-page demo uses an array of strings — each entry is both what the user sees and what gets stored. That’s enough when label and value are identical, but lists are often backed by domain data where the human-readable name and the stored identifier differ.

For that case, pass items as plain objects and use labelField and valueField to tell the list which key holds the displayed text and which one holds the stored value.

list.ts
import { gui } from '@golemui/gui-shared';
export default [
gui.inputs.list('selection', {
items: [
{ name: 'USA', code: 'US' },
{ name: 'Canada', code: 'CA' },
{ name: 'Mexico', code: 'MX' },
{ name: 'Brazil', code: 'BR' },
{ name: 'Argentina', code: 'AR' },
],
height: 200,
itemHeight: 40,
labelField: 'name',
valueField: 'code',
label: 'Custom Fields',
uid: 'list_custom',
}),
];
list.json
{
"form": [
{
"uid": "list_custom",
"kind": "input",
"type": "list",
"path": "selection",
"label": "Custom Fields",
"props": {
"height": 200,
"itemHeight": 40,
"labelField": "name",
"valueField": "code",
"items": [
{ "name": "USA", "code": "US" },
{ "name": "Canada", "code": "CA" },
{ "name": "Mexico", "code": "MX" },
{ "name": "Brazil", "code": "BR" },
{ "name": "Argentina", "code": "AR" }
]
}
}
]
}

If your objects already use the default key names (label and value), you can omit labelField and valueField entirely. Otherwise both should be set so selection can extract the right primitive.

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

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

Use the property itemRenderer to draw each row with a registered renderer instead of the default template. The key must match one of the renderers registered on the form host — see Item Renderers for the full setup.

This demo uses the registered complexListItemRenderer to display a title and description per row. Bump itemHeight to match the renderer’s row height so virtualization stays accurate.

list.ts
import { gui } from '@golemui/gui-shared';
export default [
gui.inputs.list('selection', {
items: [
{
value: 'blog',
title: 'Blog',
description: 'A minimalist Markdown blog with RSS feed and dark mode.',
},
{
value: 'docs',
title: 'Documentation Site',
description: 'Versioned docs with full-text search and a live playground.',
},
{
value: 'dashboard',
title: 'Admin Dashboard',
description: 'Data tables, charts, and role-based auth out of the box.',
},
{
value: 'storefront',
title: 'E-commerce Storefront',
description: 'Product catalog, cart, and Stripe checkout wired up.',
},
{
value: 'landing',
title: 'Marketing Landing',
description: 'Hero, pricing tiers, and a contact form ready to ship.',
},
{
value: 'portfolio',
title: 'Developer Portfolio',
description: 'Showcase projects, embed demos, and host a personal blog.',
},
],
height: 240,
itemHeight: 60,
labelField: 'title',
valueField: 'value',
itemRenderer: 'complexListItemRenderer',
label: 'Pick a starter template',
uid: 'list_item_renderer',
}),
];
list.json
{
"form": [
{
"uid": "list_item_renderer",
"kind": "input",
"type": "list",
"path": "selection",
"label": "Pick a starter template",
"props": {
"height": 240,
"itemHeight": 60,
"labelField": "title",
"valueField": "value",
"itemRenderer": "complexListItemRenderer",
"items": [
{
"value": "blog",
"title": "Blog",
"description": "A minimalist Markdown blog with RSS feed and dark mode."
},
{
"value": "docs",
"title": "Documentation Site",
"description": "Versioned docs with full-text search and a live playground."
},
{
"value": "dashboard",
"title": "Admin Dashboard",
"description": "Data tables, charts, and role-based auth out of the box."
},
{
"value": "storefront",
"title": "E-commerce Storefront",
"description": "Product catalog, cart, and Stripe checkout wired up."
},
{
"value": "landing",
"title": "Marketing Landing",
"description": "Hero, pricing tiers, and a contact form ready to ship."
},
{
"value": "portfolio",
"title": "Developer Portfolio",
"description": "Showcase projects, embed demos, and host a personal blog."
}
]
}
}
]
}

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 Widget 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>