Align a line or a paragraph

    Apply paragraph alignment at the current selection through the Formatting service. Alignment belongs to the document block rather than the native toolbar layout.

    Use the selection and state APIs when your application provides its own formatting controls.

    Actual formatted document with headings, body paragraphs and a table in the Avalonia editor.
    Actual formatted document with headings, body paragraphs and a table in the Avalonia editor.

    Use it in your application

    Place the caret in the intended paragraph, or select the paragraphs to format, before applying alignment.

    Await each operation. In Source mode, only supported source-formatting operations can act on the current literal selection; inspect the result before saving.

    Use StateQuery to update an application-owned alignment indicator from the actual current view.

    await editor.Formatting.AlignCenterAsync();
    bool centered = await editor.StateQuery.IsJustifyCenterAsync();

    Continue with

    Last updated on Oct 18, 2026

    Put this into practice.

    Start with the C# Avalonia sample. Restore this edition's package and install the native browser prerequisites before running it.

    Prefer a guided look? Book a free live demo with our engineers - live on Zoom or Teams, never a chatbot.