Skip to content
Mosaic
On this page

DirectionProvider

Sets the reading direction that arrow-key navigation follows below it. useDirection reads it, falling back to ltr with no provider, and readingDirectionKeys maps it to the previous and next arrow keys.

Use for

  • right-to-left arrow-key navigation
  • reading the text direction in a primitive that handles arrow keys

Practices

GuidancePractice
DoSet MosaicProvider's direction to match the page's dir. It renders this provider.
DoIn a primitive, get the arrow keys from readingDirectionKeys(useDirection()) instead of hard-coding ArrowLeft and ArrowRight.
Don’tExpect it to set dir on the DOM. It only steers keyboard navigation.

API reference

DirectionProvider

Provides the direction to its children. Renders no element.

PropTypeDescription
directionTextDirectionltr or rtl.Default: 'ltr'
  • MosaicProvider