ナビゲーションと開示@neumorphism-ui/command

Command

cmdk のフィルタリング、アクティブ項目、キーボード操作を維持し、入力を inset、選択項目を押し込まれた表面で表現します。CommandDialog で既存の Dialog と組み合わせられます。

@neumorphism-ui/command
Registry JSON

プレビュー

保存済み

インストール

インストール: commandnpx shadcn@latest add @neumorphism-ui/command

CLI が npm 依存関係、base token、utils、コンポーネントソースを順番に処理します。

この Registry を初めて使う場合は、先に namespace の設定 を完了してください。

使い方

Import

Command の import コード
"use client";
import * as React from "react";
import {
  Command,
  CommandEmpty,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
  CommandShortcut,
} from "@/components/ui/command";

Example

Command の使用コード
export default function Example() {
  const [selected, setSelected] = React.useState("コマンド未選択");
  return <div className="grid w-full max-w-md gap-3">
    <Command>
      <CommandInput placeholder="コマンドを検索" />
      <CommandList>
        <CommandEmpty>一致するコマンドはありません。</CommandEmpty>
        <CommandGroup heading="ナビゲーション">
          <CommandItem value="dashboard" onSelect={() => setSelected("ダッシュボード")}>ダッシュボード<CommandShortcut>⌘D</CommandShortcut></CommandItem>
          <CommandItem value="settings" onSelect={() => setSelected("設定")}>設定<CommandShortcut>⌘,</CommandShortcut></CommandItem>
        </CommandGroup>
      </CommandList>
    </Command>
    <p role="status" className="text-sm text-[var(--muted-foreground)]">{selected}</p>
  </div>;
}

API リファレンス

コンポーネントプロパティ型デフォルト説明
CommandshouldFilterbooleantruecmdk の組み込み検索フィルタを使用するか指定します。
Commandvalue / onValueChangestring / (value: string) => void—現在アクティブな項目を制御します。
CommandInputvalue / onValueChangestring / (value: string) => void—検索文字列を制御するか uncontrolled 入力として使います。
CommandItemvalue / onSelectstring / (value: string) => void—項目の検索値と選択時のコールバックを指定します。
CommandItemdisabledbooleanfalse検索結果には残しつつ選択できない状態にします。

アクセシビリティ

  • 01

    CommandInput に検索目的を示す placeholder または aria-label を指定します。

  • 02

    方向キーで項目を移動し Enter で選択できます。可視フォーカスを維持してください。

  • 03

    結果がない場合は CommandEmpty で明示的な空状態を示します。