Skip to content
GitHub11 stars

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.

تسجيل الدخول إلى حسابك
أدخل بريدك الإلكتروني أدناه لتسجيل الدخول إلى حسابك
نسيت كلمة المرور؟
<Card Class="w-full max-w-sm">
    <CardHeader>
        <CardTitle>@T.Title</CardTitle>

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

dnx Blazix.Cli add direction

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; }
}