Zum Inhalt springen
ÜBERLAGERUNGEN · FREE

CommandPalette

CommandPalette gehört zu RayCraft Free.

Beispiel

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

Ein kurzes Fragment. Fügen Sie @using RayCraft.Blazor.Components zu Ihrer Seite hinzu und nutzen Sie einen interaktiven Render-Modus.

In RayCraft Free enthalten. Funktionierende Beispiele finden Sie im GitHub-Repository (MIT); es enthält Beispiel- und Democode, nicht den Code der Bibliothek.

Alle Steuerelemente ยท Dokumentation