Avalonia Spell Checker adds Hunspell-based spell checking to Avalonia TextBox controls. It highlights misspelled words while the user types and adds spelling suggestions to the existing context menu without requiring a custom text input control.
- Real-time spell checking for Avalonia
TextBox. - Hunspell
.affand.dicdictionary support throughWeCantSpell.Hunspell. - Multiple enabled languages at the same time.
- Context menu suggestions for misspelled words.
- Custom ignored words.
- Automatic style registration when
TextBoxSpellChecker.Initializeis called. - Included dictionaries for
en_GB,es_MX, andpt_BR.
Use the package that matches your Avalonia major version:
| Avalonia version | Package | Target frameworks |
|---|---|---|
| Avalonia 12.x | GHSoftware.Avalonia.SpellChecker |
net8.0, net10.0 |
| Avalonia 11.1+ | GHSoftware.Avalonia.SpellChecker.Avalonia11 |
net6.0, net8.0, net10.0 |
Install the current Avalonia package:
dotnet add package GHSoftware.Avalonia.SpellCheckerInstall the Avalonia 11 package:
dotnet add package GHSoftware.Avalonia.SpellChecker.Avalonia11The two packages expose the same Avalonia.SpellChecker namespace and API. The separate package IDs keep NuGet dependency resolution explicit and avoid mixing Avalonia 11 and Avalonia 12 assets in the same package.
Create a TextBoxSpellChecker and initialize each TextBox that should be checked:
using Avalonia.Controls;
using Avalonia.SpellChecker;
public partial class MainWindow : Window
{
private readonly TextBoxSpellChecker _spellChecker;
public MainWindow()
{
InitializeComponent();
_spellChecker = new TextBoxSpellChecker(
SpellCheckerConfig.Create("pt_BR", "en_GB"));
var textBox = this.FindControl<TextBox>("DescriptionTextBox");
if (textBox is not null)
{
_spellChecker.Initialize(textBox);
}
}
}By default, SpellCheckerConfig.Create(...) looks for dictionaries in:
<application output directory>/Dictionaries
The NuGet packages include the bundled dictionaries as content files and copy them to the output directory automatically.
After Initialize is called, the TextBoxSpellChecker starts checking the target TextBox as soon as its template is applied. Misspelled words are underlined, and suggestions are added to the context menu when the user right-clicks a misspelled word.
When the TextBox is detached from the logical tree, the spell checker removes its event handlers and clears its reference to that control.
Hunspell dictionaries use a pair of files per language:
<language>.aff
<language>.dic
For example:
Dictionaries/pt_BR.aff
Dictionaries/pt_BR.dic
The bundled dictionaries are enough to start using the library. To add or replace dictionaries, use Hunspell-compatible files from maintained dictionary projects such as:
Then configure the folder explicitly if needed:
var config = SpellCheckerConfig.Create("en_GB");
config.DictionariesFolder = @"C:\path\to\Dictionaries";The repository builds two NuGet packages: one for Avalonia 12 and one for Avalonia 11.
.\scripts\pack-all.ps1 -Configuration Release -CleanTo override the package version:
.\scripts\pack-all.ps1 -Configuration Release -Version 0.3.1 -CleanPackages are written to:
artifacts/nuget
- Keyboard-triggered context menus do not currently show spelling suggestions because suggestions are resolved from a pointer position.
- The included dictionaries are limited to
en_GB,es_MX, andpt_BR.
Issues and pull requests are welcome.
This project is licensed under the MIT License.


