ListView
The ListView is a component for rendering a set of vertically stacked items. These items can be focusable, selectable, have one primary action and one or more secondary actions, and support keyboard navigation and accessibility features.
Usage
<script>
import { ListView, ListViewItem } from 'fluentui-svelte';
let list = ['A', 'B', 'C'];
let selected = ['A'];
</script>
<ListView selectedItems={selected}>
{#each list as item (item)}
<ListViewItem value={item}>{item}</ListViewItem>
{/each}
</ListView> Navigation Mode
Use items to keep each item in the Tab order. Use composite to give the list one tab stop and enter an item's secondary controls with Right. Selection uses listbox and option roles in items mode, or grid, row and gridcell roles in composite mode. For selectable navigation with sublists, set role="list" on each ListView and use aria-current on links: each list manages its own selectedItems, without selecting items at other levels.
Best practices
- Keep lists that only display text out of the Tab sequence. Configure
navigationModeon the outerListView: useitemsfor native link navigation andcompositefor selectable cards with secondary controls. Let the component manage item and controltabindexunless you opt out withdisableTabspot. - With the default grid roles in selectable composite lists, the component wraps each row's content in one
gridcelland manages navigation to its controls. No manualgridcellwrappers are needed. - Use
onActionfor an item's primary action and native buttons or links withonclickfor secondary actions. Enter and Space both activate non-native actionable items; links retain native keyboard behavior. In composite selection rows, the checkmark changes selection independently, and secondary buttons and links do not trigger the row's action or selection. - Keep the default roles for flat selection widgets; they depend on both
selectionModeandnavigationMode. Match the HTML tags:ul/olwithliitems, oras="div"on both a card list and its items. - Use
ListViewItemBranchfor expandable sublists. Branches are never selectable and manage their disclosure attributes and focus. Each nested list owns its selection. Setrole="list"on each selectable list containing branches to preserve native list semantics. - Give selectable
ListViewwidgets an accessible name witharia-labeloraria-labelledby. Give navigation a namednavlandmark and mark the current link witharia-current="page". Use meaningful visible text oraria-labelfor controls, a descriptive branchlabel, and stable itemvaluestrings when using selection.
Keyboard navigation
Up and Down move between siblings; Home and End move to the ends of the current level. Right opens a collapsed branch; Right on an expanded branch enters its sublist. Left closes an expanded branch; Left on a collapsed branch or child returns to its parent. Escape closes the nearest branch and restores focus to its button. Right also enters a composite item's controls: Left and Right move between them, and Left from the first control returns to the row. Enter activates links; Enter and Space activate buttons and selectable items. In items mode, Tab visits the items and their controls; in composite mode, the entire list has one tab stop. disableTabspot opts out of arrow-key focus management.
Simple navigation
Wrap the list in a named nav landmark and use as="a" with href for navigation links. ListView wraps links in native list items when the list is a ul or ol. Use aria-current="page" on the current link; site navigation keeps native list and link semantics.
Navigation with sublists
Nest a ListView inside ListViewItemBranch. Branches are focusable disclosure buttons and never selectable. Expanded state, aria-expanded, aria-controls, hidden content and focus restoration are managed automatically. Each nested list keeps its own selection state when collapsed. Use native list semantics; set role="list" when enabling selection on a list containing branches.
Selection Mode
Use selectionMode (single, multiselect, or extended) to control how items are selected.
Toggle on click
In a multiselect list, a plain click selects only that item and Ctrl/Cmd + click toggles it. Set toggleOnClick to make a plain click toggle the item directly.
Checkmark
Add and configure a checkbox for the element. You can use the same props for the Checkbox component.
The checkbox toggles the selection of its item without triggering onAction. Bind selectedItems to read or control the selection.
Cards with a primary action
With navigationMode set to composite and a selectionMode, every item is a row. Set as="div" on both the list and its card items to keep the HTML structure valid. Clicking a row runs its primary action (onAction), the checkbox toggles its selection, and any button inside is a secondary action. Use checkmark.wrapperAttributes.style to place the checkbox where you need it, like the top-right corner of the card.
Secondary controls run their own actions without selecting the item or triggering its primary action. The checkbox only toggles selection.
ListView Props
| Name | Type | Default | Description |
|---|---|---|---|
role | AriaRole | Overrides the list role and the roles derived for its items. Use list for nested navigation with independent selection. | |
selectionMode | 'none' | 'single' | 'multiselect' | 'extended' | 'none' | How many items can be selected, and how the selection is made. |
navigationMode | 'items' | 'composite' | 'items' | Whether the list itself takes a single tab stop, or every item takes its own. |
manageSpecialKeys | boolean | TabspotRootOptions['manageSpecialKeys'] | true | Which special keys Tabspot handles at the root. Set individual keys to leave Escape to an enclosing panel. Omitted keys in an object are off. |
selectedItems bindable | string[] | The values of the selected items. | |
shape | 'circular' | 'rounded' | 'square' | 'rounded' | The items can have a circular, rounded or square shape. |
onSelectionChange | (e: Event, selectedItems: string[] | []) => void | Called whenever the selection changes. | |
toggleOnClick | boolean | false | When selectionMode is 'multiselect', clicking an item toggles its selection directly instead of requiring Ctrl/Cmd + click. |
as | 'ul' | 'ol' | 'div' | 'ul' | The HTML element to render the list as. |
ref bindable | HTMLUListElement | HTMLOListElement | HTMLDivElement | The DOM reference of the list element. | |
disableTabspot | boolean | false | Opts the list out of the tabspot focus management, to wire your own. |
| HTML Attributes |
ListViewItem Props
| Name | Type | Default | Description |
|---|---|---|---|
as | 'li' | 'a' | 'button' | 'div' | 'li' | The HTML element to render the item as. Links and buttons are wrapped in a list item when the list renders as ul or ol. Use li or div for nested lists and content with multiple controls. Buttons cannot contain checkmarks or composite rows. |
shape | 'circular' | 'rounded' | 'square' | The item can have a circular, rounded or square shape. Inherited from the list by default. | |
value | string | The value reported to the list when the item is selected. Falls back to a generated id. | |
active | boolean | Renders the item in its pressed state. | |
role | 'treeitem' | 'menuitem' | 'option' | 'row' | The ARIA role of the item. Derived from the list by default. | |
disabled | boolean | Disables the user interaction. | |
checkmark | CheckboxProps | The props to spread on the checkbox rendered when the list is multiselect. | |
onAction | (e: MouseEvent, value: string) => void | Called when the item is clicked or activated with the keyboard. | |
onfocus | (e: Event, value: string) => void | Called when the item receives the focus. | |
ref bindable | HTMLLIElement | HTMLAnchorElement | HTMLButtonElement | HTMLDivElement | The DOM reference of the item element. | |
| HTML Attributes |
ListViewItemBranch Props
| Name | Type | Default | Description |
|---|---|---|---|
label | string | The accessible label rendered in the disclosure button. | |
icon | Snippet | Component | The decorative icon before the label. | |
expanded bindable | boolean | false | Whether the nested content is visible. Branches only expand or collapse and are never selectable. |
onExpandedChange | (e: Event, expanded: boolean) => void | Called when a user expands or collapses the branch. | |
disabled | boolean | false | Disables the disclosure button. |
shape | 'circular' | 'rounded' | 'square' | The disclosure button shape. Inherited from the list by default. | |
ref bindable | HTMLButtonElement | The DOM reference of the native disclosure button. Additional HTML attributes, including class and id, also target this button. | |
wrapperRef bindable | HTMLLIElement | HTMLDivElement | The DOM reference of the wrapper element, the list item that holds the button and the nested list. | |
wrapperAttributes | HTMLAttributes | The attributes to spread on the wrapper element. | |
children | Snippet | Nested ListView content, kept mounted while collapsed to preserve its selection. | |
HTMLButtonAttributes without children, role, type, value, aria-expanded, aria-controls |

