🌐 Nodejs.cn

搜索和快速操作的命令菜单。

import {
  Command,
  CommandEmpty,

关于

🌐 About

<Command /> 组件通过 Dip 使用 cmdk 组件。

🌐 The <Command /> component uses the cmdk component by Dip.

安装

🌐 Installation

pnpm dlx shadcn@latest add command

用法

🌐 Usage

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>

示例

🌐 Examples

基础

🌐 Basic

对话中的一个简单命令菜单。

🌐 A simple command menu in a dialog.

Command Palette

Search for a command to run...

"use client"

import * as React from "react"

快捷方式

🌐 Shortcuts

Command Palette

Search for a command to run...

"use client"

import * as React from "react"

群组

🌐 Groups

一个带有分组、图标和分隔符的命令菜单。

🌐 A command menu with groups, icons and separators.

Command Palette

Search for a command to run...

"use client"

import * as React from "react"

可滚动

🌐 Scrollable

带有多个项目的可滚动命令菜单。

🌐 Scrollable command menu with multiple items.

Command Palette

Search for a command to run...

"use client"

import * as React from "react"

从右到左

🌐 RTL

要在 shadcn/ui 中启用 RTL 支持,请参阅 RTL 配置指南

🌐 To enable RTL support in shadcn/ui, see the RTL configuration guide.

"use client"

import * as React from "react"

API参考

🌐 API Reference

有关更多信息,请参见 cmdk 文档。

🌐 See the cmdk documentation for more information.