Naar de inhoud
OVERLAYS · FREE

CommandPalette

CommandPalette maakt deel uit van RayCraft Free.

Voorbeeld

<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 }
    ];
}

Een kort fragment. Voeg @using RayCraft.Blazor.Components toe aan je pagina en gebruik een interactieve rendermodus.

Inbegrepen in RayCraft Free. Werkende voorbeelden staan in de GitHub-repository (MIT); het bevat voorbeeld- en democode, niet de code van de bibliotheek.

Alle besturingselementen ยท Documentatie