Skip to content

docs: add some guidance to configure RTL mode #2121

@mobinseven

Description

@mobinseven

Documentation Request

There is no information about how to configure RTL mode in the docs. However, by searching the issues I have found out some information about RTL support. (e.g. #386 and a demo site)

FluentDesignTheme has a Direction property which when is set to LocalizationDirection.RightToLeft has no impact.

Based on this comment, in the aforementioned issue, I have done this:

  1. Added a simple js file containing a simple dir configuration:
export function switchDirection(dir) {
    document.dir = dir;
}
  1. Added these initializations to OnAfterRenderAsync of the main layout of the app:
    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if(firstRender)
        {
            _jsModule = await JSRuntime.InvokeAsync<IJSObjectReference>("import",
                 "./_content/[corresponding assembly]/Layouts/MainLayout.razor.js");

            var dir = LocalizationDirection.rtl;
            GlobalState.SetDirection(dir);

            await Direction.SetValueFor(container, dir.ToAttributeValue());
            await _jsModule!.InvokeVoidAsync("switchDirection", dir.ToString());

            StateHasChanged();
        }
    }

But the result is a rtl layout with the exactly same issue reported in #386. So there should be a better documentation on this feature which I know implementing it have taken lots of time and effort.

v4.7.2
net8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    community:contributionIssue will/can be addressed by community contributiondocs:articleAdditions, improvements, or fixes to site articles

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions