A command palette for Blazor,
every decision in C#.
The Ctrl K box that searches every page, action and setting of an app and runs the one you pick: fuzzy search, nested pages, modes, async sources, recents, global shortcuts, multi-select, prompts and a detail pane - accessible and keyboard-first. Matching, ranking and every decision run in C#; JavaScript only owns the dialog, focus and keys.
dotnet add package Bit.Balette
Project: Acme Dashboard · Labels: bug · Theme: auto
<dialog> and the WAI-ARIA comboboxCapabilities
Everything a command palette does - natively in Blazor
The pattern of VS Code's Quick Pick, Linear, GitHub, Raycast and cmdk: one place where every page, action, setting and record of an app can be reached by typing. Each feature below has a page you can try it on, with this site's own palette.
Registering commands
A fluent builder, declarative BaletteItem markup, commands that exist only while a page is
on screen or only when they apply, and toggles that stay in sync - merged into one list.
Nested pages & flows
Static, lazy and searching pages, prompts, multi-select, confirmations, long-running and failing commands, recents, pins and a Raycast-style action panel - every step in the same box.
Nested pages →Search & ranking
An fzf-style fuzzy matcher with 'exact, ^prefix, suffix$,
!negate, "phrases" and a | b, accents and typos forgiven, weighted
fields, priority and frecency - every score shown live.
Modes & sources
Typed prefixes - > # @ ? - that scope the palette,
and async sources that are debounced, cancelled, paged, timed out and retried.
Keyboard & shortcuts
Every key inside the palette, global chords such as Alt Z and G-then-X sequences, matched in the browser on any keyboard layout and shown in the platform's own symbols.
Keyboard & shortcuts →Theming & templates
Light and dark, CSS custom properties and density changed live on this site's palette, the detail pane, eight templates and a fully unstyled mode - each one running.
Theming & templates →Localization & RTL
Every label and announcement in another language, plural forms, translated commands that keep their English names, and right-to-left layouts.
Localization & RTL →Large registry
Thousands of commands registered, or served from a static source, and what one keystroke costs - measured in your browser.
Large registry →Options & security
Every option with this site's value beside the default, the parameters one palette overrides, and what
keeps text, links and history safe - with a refused javascript: link to try.
In practice
See it in code
A command is a record
A title, where it is listed, what it matches and what it does - built with BaletteCmd
and registered from anywhere. A shortcut is written once, as text, and works with the palette closed.
Palette.Register(
BaletteCmd.Navigate("Settings", "/settings")
.Group("Navigation").Shortcut("G S").Keywords("preferences"),
BaletteCmd.Action("Toggle sidebar", () => _sidebarOpen = !_sidebarOpen)
.Shortcut("Mod+B"));The next step is a return value
A handler does its work and tells the palette what comes next - a prompt, a page, a toast or
Back - so a multi-step flow stays in one place instead of a chain of callbacks.
BaletteCmd.New("Rename project…")
.Shortcut("F2")
.Handler(_ => Task.FromResult(BaletteCommandResult.Prompt(
"New project name",
ctx =>
{
state.Rename(ctx.PromptValue!.Trim());
return Task.FromResult(BaletteCommandResult.Toast("Renamed"));
},
initialValue: state.ProjectName)))Your API is a source
An IBaletteSource answers a query later. The palette debounces it, cancels it when the
query moves on, and ranks what it returns with everything else.
public sealed class PeopleSource : IBaletteSource
{
public string Name => "People";
public bool ApplyMatcher => true; // re-rank with the palette's matcher
public async Task<IReadOnlyList<BaletteCommand>> SearchAsync(
string query, BaletteSourceContext context, CancellationToken cancellationToken)
{
var people = await context.Services.GetRequiredService<PeopleClient>()
.SearchAsync(query, cancellationToken);
return [.. people.Select(p => BaletteCmd.New(p.Name).Subtitle(p.Role).Build())];
}
}Comparison
Why not wrap a JavaScript palette?
A JavaScript command menu keeps its commands, its matching and its flows on the other side of the interop boundary, and every handler has to be reached back across it. Balette keeps all of it in C#, next to the code the commands call.
| Concern | Wrapped JavaScript palette | Balette |
|---|---|---|
| Who matches and ranks | The JavaScript library | IBaletteMatcher and BaletteRanker - C#, replaceable, unit-testable |
| Commands | JavaScript objects, handlers reached through interop | Typed BaletteCommand records; handlers are C# delegates with the user's DI scope |
| Multi-step flows | Callbacks wired across the boundary | A handler returns the next step: Prompt, Page, Toast, Back |
| Results from an API | Fetched in JavaScript, or bridged back from .NET | IBaletteSource: debounced, cancelled through a CancellationToken |
| Script to ship | The library plus interop glue | One small module, imported on demand - no inline script, no eval |
Where to start
Choose your path
New to Balette?
Install, register the services, link the stylesheet, place one palette - and register your first commands.
Getting started →Want to see it live?
Press Ctrl K anywhere on this site. Every feature also has a page that drives this very palette.
Open the demos →Building with an AI agent?
This site is an MCP server: point your agent at /mcp and it reads the shipped library - and runs its real matcher - instead of guessing.
Questions
Frequently asked
Is this a JavaScript command menu behind interop?
No. Matching, ranking, paging, history and what Enter does are C#. A small module does only
what the browser alone can: open the native <dialog>, move focus into and out of it,
scroll the active row into view, and decide which keys belong to the palette.
Which render modes does it work in?
Any interactive one - WebAssembly, Server, Auto and Hybrid - on .NET 10 and 11. Shortcuts and the navigation keys are matched in the browser, so on Blazor Server only the query and the chosen command cross the connection. This site runs on WebAssembly, so the whole search runs next to the list it fills.
Do I have to take its look?
No. Every visual is a --bit-balette-* custom property - this site re-tints them to its own
brand - every part of a row and of the dialog can be replaced with a template, and
Unstyled="true" leaves bare, accessible markup to style from scratch.
How many commands can it hold?
Thousands. Only the best MaxResults rows are rendered, Virtualize renders just
the visible ones, and on WebAssembly a search that takes longer than a frame lets the keystroke paint
first. The large registry page measures it in your browser.
Does it work in other languages, and right to left?
Yes. Every label and announcement - the ones only screen readers hear included - is a property of
BaletteStrings, every rule of the stylesheet uses logical properties, and search treats the
Arabic and Persian forms of a letter and Persian digits as one. The localization
page switches a palette between English, German and Persian as you watch.
What happens when a command or an API fails?
It is logged and reported in the palette - a generic message, never the exception's text, unless you choose to show it - and it never ends a Blazor Server circuit. A page that failed to load and a source that threw or timed out offer a retry, and the rest of the list stays. Try it.
Why does the search box in this site's header answer to / and not Ctrl K?
Because Ctrl K is Balette's, and the palette it opens is the one this site demonstrates. The header's box only searches these docs, and while either of the two is open the keys are its own.
Give your app a Ctrl K
One package, one service registration, one stylesheet and one component - and every page, action and setting is a keystroke away.
dotnet add package Bit.Balette