125k

Command

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

"use client"

import {

インストール

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
    renderEmptyState={() => <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
    ├── CommandGroup
    │   ├── CommandItem
    │   └── CommandItem
    ├── CommandSeparator
    └── CommandGroup
        ├── CommandItem
        └── CommandItem

基本

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

"use client"

import * as React from "react"

ショートカット

"use client"

import * as React from "react"

グループ

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

"use client"

import * as React from "react"

スクロール可能

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

"use client"

import * as React from "react"

RTL

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

"use client"

import * as React from "react"

API リファレンス

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