Direction
A provider component that sets the text direction for your application.
The DirectionProvider component is used to set the text direction (ltr or rtl) for your application. This is essential for supporting right-to-left languages like Arabic, Hebrew, and Persian.
Here's a preview of the component in RTL mode. Use the language selector to switch the language. To see more examples, look for the RTL section on component pages, and see the RTL guide to set up a project.
Translated with AI for the demo, so it may have mistakes.
It renders no element and sets no dir attribute: set dir="rtl" on <html> for the layout. Keyboard
navigation and popup placement read that. The provider is for what's decided while rendering: which way a Tabs or Navigation Menu
indicator moves, and which way the arrow keys go in a Calendar.
Installation
Usage
<html dir="rtl">
<body><DirectionProvider Direction="TextDirection.Rtl">...</DirectionProvider></body>
</html>Reading the direction
The provider cascades a TextDirection. Take it as a cascading parameter to read the current direction.
<div>Current direction: @Direction</div>
@code {
[CascadingParameter] public TextDirection Direction { get; set; }
}