Hoppa till innehållet
ÖVERLÄGG · FREE

CommandPalette

CommandPalette ingår i RayCraft Free.

Exempel

<CommandPalette @bind-Open="_open" Commands="_commands" OnCommand="command => _last = command.Text" />

<Stack Align="center">
    <Button OnClick="() => _open = true" StartIcon="IconName.Search">Open palette</Button>
    <span>Press <kbd>Ctrl</kbd>+<kbd>K</kbd>. Last command: @_last</span>
</Stack>

@code {
    private bool _open;
    private string _last = "none";

    private readonly PaletteCommand[] _commands =
    [
        new() { Id = "new", Text = "New document", Group = "File", Icon = IconName.Add, Shortcut = "Ctrl+N" },
        new() { Id = "open", Text = "Open file", Group = "File", Icon = IconName.Folder, Shortcut = "Ctrl+O" },
        new() { Id = "print", Text = "Print", Group = "File", Keywords = "paper pdf" },
        new() { Id = "dark", Text = "Switch to the dark theme", Group = "View", Keywords = "appearance" },
        new() { Id = "compact", Text = "Compact density", Group = "View" },
        new() { Id = "locked", Text = "Delete everything", Group = "View", Disabled = true }
    ];
}

Ett kort utdrag. Lägg till @using RayCraft.Blazor.Components på din sida och använd ett interaktivt renderingsläge.

Ingår i RayCraft Free. Fungerande exempel finns i GitHub-arkiv (MIT); det innehåller exempel- och demokod, inte bibliotekets kod.

Alla kontroller ยท Dokumentation