Aller au contenu
SUPERPOSITIONS · FREE

CommandPalette

CommandPalette fait partie de RayCraft Free.

Exemple

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

Un court fragment. Ajoutez @using RayCraft.Blazor.Components à votre page et utilisez un mode de rendu interactif.

Inclus dans RayCraft Free. Des exemples fonctionnels se trouvent dans le dépôt GitHub (MIT); il contient du code d’exemple et de démonstration, pas le code de la bibliothèque.

Tous les contrôles ยท Documentation