Skip to content

[Feature] Add Spell Check Support #20423

Description

@jsuarezruiz

Is your feature request related to a problem? Please describe.

Avalonia's TextBox currently lacks built-in spell check functionality through an SpellCheck property. While TextInputOptions provides ShowSuggestions for predictive text, there is no dedicated spell check flag.

For mobile applications, users expect native keyboard-driven auto-correction and spell checking that integrates seamlessly with the system IME.

Describe the solution you'd like

Extend TextInputOptions in Avalonia.Input to include spell check control:

namespace Avalonia.Input.TextInput
{
    public static class TextInputOptions
    {
        // Existing properties
        public static readonly AttachedProperty<TextInputContentType> ContentTypeProperty = ...;
        public static readonly AttachedProperty<bool> ShowSuggestionsProperty = ...;
        
        public static readonly AttachedProperty<bool> SpellCheckProperty =
            AvaloniaProperty.RegisterAttached<TextInputOptions, InputElement, bool>(
                "SpellCheck",
                defaultValue: true);
        
        public static bool GetSpellCheck(InputElement element) =>
            element.GetValue(SpellCheckProperty);
            
        public static void SetSpellCheck(InputElement element, bool value) =>
            element.SetValue(SpellCheckProperty, value);
    }
}

Platform Implementation

Android

  • Map to Android.Text.InputTypes
  • Enabled: InputTypes.TextFlagAutoCorrect

iOS

  • Map to UITextInputTraits
  • Configure both AutocorrectionType and SpellCheckingType

Windows

Map to WinUI/UWP IsSpellCheckEnabled or use Windows Spell Check API (Windows.Globalization.Collation)

macOS

Integrate with NSSpellChecker

Linux

Integrate with platform spell checkers where available. Fallback to Hunspell.

Describe alternatives you've considered

  • Separate SpellCheck and AutoCorrect Properties. But on mobile, these are tightly coupled (same InputType flag on Android)

Additional context

This API design aligns with WPF's spell check functionality, though implemented differently:

<TextBox SpellCheck.IsEnabled="True" />

The difference in this case, is intentional, Avalonia uses TextInputOptions for all input-related properties to maintain architectural consistency across platforms.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions