Function that will be called when each data item is rendered. It will be passed three arguments, the individual data item, its index, and an object indicating the state of the item, if any. It should return a react element.
Styling applied to all list items. Object accepts any Box props. To style a specific list item, use itemProps.
{{ background: ..., align: ... }}
disabled
Specified items will be styled as disabled. When combined with onClickItem, the onClick event is also disabled.
array
An array of strings. When data is an array of objects, the string is the value of the object's key specified by itemKey.
["item1", "item2"]
gridArea
The name of the area to place this inside a parent Grid.
string
"a parent grid area name"
itemKey
The key to apply to each item in the List.
string
The property name of a data object.
"id"
function
(item) => key-{item.id}
itemProps
Item specific background, border, and pad, keyed by data index. The background, border, and pad accept the same values as the same named properties on List.
object
{ 27: { background: ..., border: ..., pad: ... }}
margin
The amount of margin around the component.
string
"none"
"xxsmall"
"xsmall"
"small"
"medium"
"large"
"xlarge"
object
Can be specified to distinguish horizontal margin, vertical margin, and margin on a particular side.
When provided, this is called with the index of the item that the user has either moused over or navigated to with their keyboard.
function
(index) => {}
onClickItem
When supplied, this function will be called with an event object which includes an 'item' property containing the data value associated with the clicked item and an 'index' property containing the index in 'data' of the clicked item. You should not include interactive elements, like Anchor or Button inside 'primaryKey' or 'secondaryKey' as that can cause confusion with overlapping interactive elements.
function
({ item, index }) => {}
onMore
Use this to indicate that 'data' doesn't contain all that it could. It will be called when all of the data items have been rendered. This might be used when the total number of items that could be retrieved is more than you'd want to load into the browser. 'onMore' allows you to lazily fetch more from the server only when needed.
function
() => {}
onOrder
Use this to indicate that the user should be allowed to re-order the data items. This cannot be used with 'paginate' or 'onClickItem'. The function will be called with the array of items in their new order when the user moves items via drag and drop or the move up/down controls.
function
() => {}
pad
Item padding.
string
T-shirt sizing based off the theme or a specific size in px, em, etc.
"none"
"xxsmall"
"xsmall"
"small"
"medium"
"large"
"xlarge"
"any CSS size"
object
An object can be specified to distinguish horizontal padding, vertical padding, and padding on a particular side.
If providing an object, any Box props or Pagination props are valid and will be used to style the underlying pagination component.
{}
pinned
Can be used with onOrder to specify items that should not change position in the List.
boolean
true
false
array
An array of numbers or strings that correspond to items in the List. Alternately, an object, where 'items' is an array that corresponds to items in the List, 'icon' is the icon to be rendered instead of Pin, 'color' is the color to be applied to the item text and icon, and 'background' which is the background color for the pinned items.
When a string is supplied, it indicates the property in a data item object to use to get the primary content. If a function is supplied, it will be called with the current data item object and should return a React element that will be rendered as the primary content.
string
"property"
function
item => (<Text>{item.entry}</Text>)
secondaryKey
When a string is supplied, it indicates the property in a data item object to use to get the secondary content. If a function is supplied, it will be called with the current data item object and should return a React element that will be rendered as the secondary content.
string
"secondaryProperty"
function
item => (<Text>{item.entry}</Text>)
show
The index of an item or page to show.
number
If provided as a number, the index of an item to show.
15
object
If using paginate and provided as an object, the default page to show.
{ page: 2 }
showIndex
Whether to display the index number when using onOrder.
boolean
true
false
step
How many items to render at a time.
number
50
React/DOM Properties
At its core, the List component is a regular <ol> element. Thus, both DOM and React properties, methods, and events are accessible. To read up on all of the possible DOM attributes and types available for ol elements, check out this MDN Web Documents page. To learn more about DOM events and methods, you can read more on the MDN Web Events documentation page.