ListView
A ListView is a collection of items that each have a primary piece of information and action, one or multiple secondary actions, as well as associated metadata.
Internal Component
This component is intended solely for use within GitHub and is not available for external use.Props
ListView
| Name | Default | Description |
|---|---|---|
metadata | React.ReactElement<({ title, assistiveAnnouncement, sectionFilters, children, style, className, actionsStyle, actionsClassName, onToggleSelectAll, ...actionBarProps }: ListViewMetadataProps) => React.JSX.Element, string | React.JSXElementConstructor<any>>An optional element to contain bulk actions, a 'Select all' checkbox, a density toggle for the view, etc. | |
variant | "default" | "compact"Controls the width and height of the list and its contents | |
onVariantChange | (variant: "default" | "compact") => voidCallback for when the variant changes | |
isSelectable | booleanControls item's selection mode; bulk actions are allowed if true. Defaults to not selectable. | |
hasDragHandle | booleanControls if a drag handle is shown. Defaults to no drag handles. | |
singularUnits | stringWhat a single list item should be called. Used to customize assistive text about how many list items are selected. Defaults to 'list item'. | |
pluralUnits | stringWhat many list items are called. Used to customize assistive text about how many list items are selected. Defaults to 'list items'. | |
ariaLabelledBy | stringOptional ID of an element that labels the list view. When provided, this takes the place of the default sr-only title. | |
className | string | |
listRef | React.MutableRefObject<HTMLUListElement> | |
strictFocusZone | booleanOptional property that passes through to the | |
as | React.ElementType<any, keyof React.JSX.IntrinsicElements>Component type to render for drag and drop container | |
role | string | |
title Required | ||
titleHeaderTag Required | ||
totalCount Required | ||
selectedCount Required | ||
itemsListClassName Required | ||
itemsListStyle Required |
ListViewActionBar
| Name | Default | Description |
|---|---|---|
actionsLabel Required | ||
actions Required | ||
densityToggle | React.ReactElement<({ localStorageVariantKey, onChange: externalOnChange, ...props }: ListViewDensityToggleProps) => React.JSX.Element, string | React.JSXElementConstructor<any>>Include a toggle to switch between Comfortable and Condensed view modes. | |
className | string | |
style | React.CSSProperties |
ListViewDensityToggle
| Name | Default | Description |
|---|---|---|
localStorageVariantKey | stringOptional key for persisting to local storage the user's density selection. If omitted,
the ListView's |
IdContext
| Name | Default | Description |
|---|---|---|
idPrefix Required | stringThe prefix for use with unique |
ListViewMetadata
| Name | Default | Description |
|---|---|---|
title | React.ReactNodeThe rendered title of the list or information regarding its contents. | |
sectionFilters | ListViewSectionFilterLinks | React.ReactElement<React.ExoticComponent<React.SuspenseProps>, string | React.JSXElementConstructor<any>>Links for applying any categorical, mutually exclusive section filters for the content of the ListView. | |
assistiveAnnouncement | stringUsed for assistive announcements that are reflective of the visual updates to the list container a sighted user will experience when using the list. Defaults to no announcement. Visually hidden, for screenreaders only. | |
onToggleSelectAll | (isSelectAllChecked: boolean) => voidCallback for when the checkbox for selecting and deselecting all list items is toggled. | |
children | React.ReactNodeOptional additional actions to show. Will not fall into an overflow dropdown menu to accommodate small screen widths. | |
className | string | |
style | React.CSSProperties | |
actionsClassName Required | ||
actionsStyle Required | ||
actionsLabel Required | ||
actions Required | ||
densityToggle | React.ReactElement<({ localStorageVariantKey, onChange: externalOnChange, ...props }: ListViewDensityToggleProps) => React.JSX.Element, string | React.JSXElementConstructor<any>>Include a toggle to switch between Comfortable and Condensed view modes. |
MultiPageSelectionProvider
| Name | Default | Description |
|---|---|---|
multiPageSelectionAllowed | booleanIndicate whether list items from multiple pages of ListView items can be selected by the user at a time. Used to determine when the 'Select all' checkbox should be rendered in an indeterminate state, to indicate when some but not all selectable items are selected. Defaults to false. |
ListViewSectionFilterLink
| Name | Default | Description |
|---|---|---|
className | string | |
style | React.CSSProperties | |
title Required | stringThe name of this section filter, e.g., "Open" to describe a section filter that shows only open issues. | |
count | React.ReactNodeThe number of list items in the category this section filter represents. Optional. Changes appearance when
| |
href Required | stringThe URL to load the list with only items matching this section filter. | |
isSelected | booleanOptionally specify whether this section filter is currently active. Defaults to not being selected. | |
isLoading | booleanOptionally specify whether the section filter is still being loaded. Will be used to style the count, if given, when true. |
SelectionProvider
| Name | Default | Description |
|---|---|---|
totalCount Required | ||
singularUnits | string | |
pluralUnits | string | |
isSelectable | boolean | |
hasDragHandle | boolean | |
selectedCount | number | |
countOnPage | number |
TitleProvider
| Name | Default | Description |
|---|---|---|
titleHeaderTag | "h1" | "h2" | "h3" | "h4" | "h5" | "h6"The HTML element used for the visually hidden title. Should change depending on the information hierarchy of the
page where the ListView is used. Defaults to an | |
title Required |
VariantProvider
| Name | Default | Description |
|---|---|---|
variant | "default" | "compact" | |
setVariant | (variant: "default" | "compact") => void |
ListItemActionBar
| Name | Default | Description |
|---|---|---|
className | string | |
style | React.CSSProperties | |
anchorIcon | IconOverride the icon used in the button that opens the action menu. Defaults to KebabHorizontalIcon. | |
label | GitHubUiActionBarProps |
ListItemDescription
| Name | Default | Description |
|---|---|---|
children | React.ReactNode | |
className | string | |
style | React.CSSProperties |
ListItemLeadingBadge
| Name | Default | Description |
|---|---|---|
variant Required | ||
size Required | ||
title Required | stringText that is shown as a visible Primer Label and as visually hidden text for screen readers. | |
href | stringThe link that will be opened when the item is clicked | |
containerClassName Required | ||
containerStyle Required |
ListItemLeadingVisual
| Name | Default | Description |
|---|---|---|
icon | OcticonPropsThe Octicon component representing the desired icon | |
children | React.ReactNodeRender any child content as the leading visual NOTE: if both icon and children are passed, the icon will be rendered first, with the children appended after | |
className | stringAdditional className prop to override or extend pre-existing className styles | |
color | stringThe name of the Primer variable that will be used for the icon's fill eg.: done.fg | |
description | stringA text description of the item Used for visually hidden text to describe the item on focus for the screen readers | |
newActivity | booleanIndicates whether the rendered item has new content since lastViewed |
ListItem
| Name | Default | Description |
|---|---|---|
className | string | |
style | React.CSSProperties | |
metadataContainerClassName Required | ||
metadataContainerStyle Required | ||
isSelected | boolean | |
isActive | boolean | |
onSelect | (isSelected: boolean) => void | |
onKeyDown | (event: React.KeyboardEvent<HTMLLIElement>) => void | |
onFocus | (event: React.FocusEvent<HTMLLIElement, Element>) => void | |
title Required | React.ReactElement<typeof ListItemTitle, string | React.JSXElementConstructor<any>>A ListItem title communicates the overall purpose of the ListItem. | |
metadata | ListItemMetadataContainerPropsOptional extra elements to display on the right side of the list item. You can optionally wrap individual
pieces of content in | |
secondaryActions | React.ReactElement<({ anchorIcon, style, className, label, ...props }: ListItemActionBarProps) => React.JSX.Element, string | React.JSXElementConstructor<any>>Optional menu of additional actions to be shown on the right side of the ListItem. Use | |
role | string | |
as | React.ElementType<any, keyof React.JSX.IntrinsicElements>Component type to render for drag and drop container |
ListItemMainContent
| Name | Default | Description |
|---|---|---|
children | React.ReactNode |
ListItemMetadata
| Name | Default | Description |
|---|---|---|
alignment | "left" | "right"Controls how the metadata will be aligned inside the trailing content. Defaults to 'left'. | |
variant | "primary" | "secondary"Alter the appearance of the metadata to appear more subtle than other ListItem content ('secondary', default) or comparable to other ListItem content ('primary'). Affects text color, font size, width, and distance from other metadata items. |
ListItemSafeHTMLTitle
| Name | Default | Description |
|---|---|---|
children | React.ReactNodeAdditional elements to be rendered after the title header element and trailing badge. | |
headerContainerRef | React.RefObject<HTMLDivElement>A ref object to access the container element of the header. | |
headingRef | React.RefObject<HTMLDivElement>A ref object to access the container element of the header. | |
leadingBadge | React.ReactElement<({ title, containerStyle, containerClassName, href, ...props }: ListItemLeadingBadgeProps) => React.JSX.Element, string | React.JSXElementConstructor<any>> | |
trailingBadges | React.ReactElement<({ title, containerStyle, containerClassName, children, ...props }: ListItemTrailingBadgeProps) => React.JSX.Element, string | React.JSXElementConstructor<any>>[]An optional element used to indicate information such as the status of the item. Appears after the title text. | |
containerClassName Required | ||
containerStyle Required | ||
headingClassName Required | ||
headingStyle Required |
ListItemUnsafeHTMLTitle
| Name | Default | Description |
|---|---|---|
children | React.ReactNodeAdditional elements to be rendered after the title header element and trailing badge. | |
headerContainerRef | React.RefObject<HTMLDivElement>A ref object to access the container element of the header. | |
headingRef | React.RefObject<HTMLDivElement>A ref object to access the container element of the header. | |
leadingBadge | React.ReactElement<({ title, containerStyle, containerClassName, href, ...props }: ListItemLeadingBadgeProps) => React.JSX.Element, string | React.JSXElementConstructor<any>> | |
trailingBadges | React.ReactElement<({ title, containerStyle, containerClassName, children, ...props }: ListItemTrailingBadgeProps) => React.JSX.Element, string | React.JSXElementConstructor<any>>[]An optional element used to indicate information such as the status of the item. Appears after the title text. | |
containerClassName Required | ||
containerStyle Required | ||
headingClassName Required | ||
headingStyle Required |
ListItemTitle
| Name | Default | Description |
|---|---|---|
children Required | ||
headerContainerRef | React.RefObject<HTMLDivElement>A ref object to access the container element of the header. | |
headingRef | React.RefObject<HTMLDivElement>A ref object to access the container element of the header. | |
leadingBadge | React.ReactElement<({ title, containerStyle, containerClassName, href, ...props }: ListItemLeadingBadgeProps) => React.JSX.Element, string | React.JSXElementConstructor<any>> | |
trailingBadges | React.ReactElement<({ title, containerStyle, containerClassName, children, ...props }: ListItemTrailingBadgeProps) => React.JSX.Element, string | React.JSXElementConstructor<any>>[]An optional element used to indicate information such as the status of the item. Appears after the title text. | |
containerClassName Required | ||
containerStyle Required | ||
headingClassName Required | ||
headingStyle Required | ||
anchorClassName Required | ||
anchorStyle Required | ||
anchorRef | React.RefObject<HTMLAnchorElement>A ref to the anchor element | |
linkProps | Omit<Omit<any, "ref">, "sx">An optional prop to pass additional props for the anchor tag of the title, if the title is a link Can be used to add a target or soft navigation, for example | |
value Required | stringThe text content of the header, to convey the primary meaning of the list item. |
ListItemTrailingBadge
| Name | Default | Description |
|---|---|---|
variant Required | ||
size Required | ||
containerClassName Required | ||
containerStyle Required | ||
title Required | stringText that is shown as a visible Primer Label and as visually hidden text for screen readers. |