125k

Command

検索とクイック アクションのためのコマンド メニュー。

import {
  Calculator,
  Calendar,

概要

<Command /> コンポーネントは、Dip による cmdk コンポーネントを使用します。

インストール

pnpm dlx shadcn@latest add command

使用法

import {
  Command,
  CommandDialog,
  CommandEmpty,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
  CommandSeparator,
  CommandShortcut,
} from "@/components/ui/command"
<Command className="max-w-sm rounded-lg border">
  <CommandInput placeholder="Type a command or search..." />
  <CommandList>
    <CommandEmpty>No results found.</CommandEmpty>
    <CommandGroup heading="Suggestions">
      <CommandItem>Calendar</CommandItem>
      <CommandItem>Search Emoji</CommandItem>
      <CommandItem>Calculator</CommandItem>
    </CommandGroup>
    <CommandSeparator />
    <CommandGroup heading="Settings">
      <CommandItem>Profile</CommandItem>
      <CommandItem>Billing</CommandItem>
      <CommandItem>Settings</CommandItem>
    </CommandGroup>
  </CommandList>
</Command>

構成

次の構成を使用して Command を作成します。

Command
├── CommandInput
└── CommandList
    ├── CommandEmpty
    ├── CommandGroup
    │   ├── CommandItem
    │   └── CommandItem
    ├── CommandSeparator
    └── CommandGroup
        ├── CommandItem
        └── CommandItem

基本

ダイアログ内の単純なコマンド メニュー。

Command Palette

Search for a command to run...

"use client"

import * as React from "react"

ショートカット

Command Palette

Search for a command to run...

"use client"

import * as React from "react"

グループ

グループ、アイコン、区切り文字を含むコマンド メニュー。

Command Palette

Search for a command to run...

"use client"

import * as React from "react"

スクロール可能

複数の項目を含むスクロール可能なコマンド メニュー。

Command Palette

Search for a command to run...

"use client"

import * as React from "react"

RTL

shadcn/ui で RTL サポートを有効にするには、RTL 構成ガイド を参照してください。

"use client"

import * as React from "react"

API リファレンス

詳細については、cmdk のドキュメントを参照してください。