Composite
Creates a single tab stop whose items are navigated by arrow keys, which provides list navigation outside of floating element contexts.
This is useful to enable navigation of a list of items that aren’t part of a floating element. A menubar is an example of a composite, with each reference element being an item.
Usage
The render
prop can be used to customize the
rendering of the composite components. Both Composite
and CompositeItem
accept a JSX element:
Or a function that returns an element to customize how the HTML props are spread/passed:
Props
render
default: <div />
Determines the element to render.
orientation
default: 'both'
Determines the orientation of the composite.
loop
default: true
Determines whether the composite should loop around when navigating past the first or last item.
rtl
default: false
Whether the direction of the composite’s navigation is in RTL layout.
cols
default: 1
Determines the number of columns there are in the composite (i.e. it’s a grid).
disabledIndices
Determines which items are disabled. The disabled
or
aria-disabled
attributes are used by default.
activeIndex
default: undefined
Determines which item is active. Used to externally control the active item.
onNavigate
default: undefined
Called when the user navigates to a new item. Used to externally control the active item.
itemSizes
default: undefined
Only for grid navigation, an array of Dimensions
objects, which
specify the width (number of columns) and height (number of rows)
of each item, so the navigation algorithm can take the variable
sizes into account. If not specified, every item will be treated
as if it has a size of 1 row and 1 column.
dense
default: false
Only for grid navigation, determines if the grid positioning
algorithm should follow CSS Grid’s auto-flow
dense
algorithm.