Към съдържанието
НАСЛАГВАНИЯ · FREE

CommandPalette

CommandPalette е част от RayCraft Free.

Пример

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

Кратък фрагмент. Добавете @using RayCraft.Blazor.Components към страницата си и ползвайте интерактивен режим на рендиране.

Включено в RayCraft Free. Работещи примери има в хранилище в GitHub (MIT); то съдържа примерен и демонстрационен код, не кода на библиотеката.

Всички контроли ยท Документация