A component for displaying a list of items with optional icons and secondary content. — <cs-list>
<cs-list id="my-list" aria-label="Files"></cs-list>
<script>
const list = document.getElementById('my-list');
list.items = ['file1.txt', 'file2.txt'];
list.renderItem = (item) => ({ id: item, content: item });
</script>
aria-describedbystringAdds an aria-describedby to the list.
aria-labelstringAdds an aria-label to the list.
aria-labelledbystringAdds an aria-labelledby to the list.
disable-item-paddingsboolean
default: falseRemoves padding around and inside list items.
disable-paddingsboolean
default: falseRemoves top and bottom padding around the list. Does not apply for sortable lists.
i18n-stringsListProps.I18nStringsAn object containing all the localized strings required by the component.
liveAnnouncementDndStarted ((position: number, total: number) => string) - (Optional) Adds a message to be announced by screen readers when an item is picked for reordering.liveAnnouncementDndDiscarded (string) - (Optional) Adds a message to be announced by screen readers when a reordering action is canceled.liveAnnouncementDndItemReordered ((initialPosition: number, currentPosition: number, total: number) => string) - (Optional) Adds a message to be announced by screen readers when an item is being moved.liveAnnouncementDndItemCommitted ((initialPosition: number, finalPosition: number, total: number) => string) - (Optional) Adds a message to be announced by screen readers when a reordering action is committed.dragHandleAriaDescription (string) - (Optional) Adds an ARIA description for the drag handle.dragHandleAriaLabel (string) - (Optional) Adds an ARIA label for the drag handle.itemsReadonlyArray<T>requiredThe items to display in the list.
render-item(item: T) => {
id: string;
content: unknown;
secondaryContent?: unknown;
icon?: unknown;
actions?: unknown;
announcementLabel?: string;
}requiredRender an item. The function should return an object with the following keys:
id (string) - A unique identifier for the item.content (unknown) - The content of the item.secondaryContent (unknown) - (Optional) Secondary content, for example item description.icon (unknown) - (Optional) An icon, displayed at the start.actions (unknown) - (Optional) Action button(s).announcementLabel (string) - (Optional) An announcement label for the item, used when sorting.
By default, the content is used: a custom label should be provided if content is not a string.sortableboolean
default: falseMakes the list sortable by enabling drag and drop functionality.
sort-disabledboolean
default: falseDisables sorting drag handles. Use this to temporarily prevent users from reordering the list.
tag-override'ol' | 'ul'The HTML tag to render. By default ul is used for standard lists and ol for sortable lists.
sortingChangeCustomEvent<ListProps.SortingState<T>>Called when items are reordered in a sortable list.