-
-
Notifications
You must be signed in to change notification settings - Fork 45
Command component #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8721b88
added command component
ameybh 99d5412
added command documentation
ameybh 1ef4372
use double quotes in command components install command
ameybh 78b3269
changed examples heading in command docs
ameybh d05e78a
remove unused cmdk imports in command dialog example
ameybh 8275249
added command component to shadcn registry
ameybh c7363c6
updated cmdk install command
ameybh 4980a81
Merge branch 'main' into command
ariflogs 626e2ab
Update components.ts
ariflogs 5e39e5a
Merge branch 'main' into command
ariflogs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| "use client"; | ||
|
|
||
| import React from "react"; | ||
| import { cn } from "@/lib/utils"; | ||
| import { Dialog } from "@/components/retroui/Dialog"; | ||
| import { type DialogProps } from "@radix-ui/react-dialog"; | ||
| import { Command as CommandPrimitive } from "cmdk"; | ||
| import { Check, LucideIcon, Search } from "lucide-react"; | ||
|
|
||
| function Command({ | ||
| className, | ||
| ...props | ||
| }: React.ComponentProps<typeof CommandPrimitive>) { | ||
| return ( | ||
| <CommandPrimitive | ||
| className={cn( | ||
| "flex h-full w-full flex-col overflow-hidden rounded-md bg-background text-foreground border-border shadow-md", | ||
| className, | ||
| )} | ||
| {...props} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| type CommandDialogProps = DialogProps & { className?: string }; | ||
|
|
||
| const CommandDialog = ({ | ||
| children, | ||
| className, | ||
| ...props | ||
| }: CommandDialogProps) => { | ||
| return ( | ||
| <Dialog {...props}> | ||
| <Dialog.Content | ||
| className={cn( | ||
| "overflow-hidden p-0 shadow-lg w-full max-w-md", | ||
| className, | ||
| )} | ||
| > | ||
| <Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5"> | ||
| {children} | ||
| </Command> | ||
| </Dialog.Content> | ||
| </Dialog> | ||
| ); | ||
| }; | ||
|
|
||
| function CommandInput({ | ||
| className, | ||
| ...props | ||
| }: React.ComponentProps<typeof CommandPrimitive.Input>) { | ||
| return ( | ||
| <div | ||
| className="flex items-center border-border border-b px-3" | ||
| cmdk-input-wrapper="" | ||
| data-slot="command-input" | ||
| > | ||
| <Search className="me-2 h-4 w-4 shrink-0 opacity-50 text-foreground" /> | ||
| <CommandPrimitive.Input | ||
| className={cn( | ||
| "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-hidden text-foreground placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50 font-body", | ||
| className, | ||
| )} | ||
| {...props} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| function CommandList({ | ||
| className, | ||
| ...props | ||
| }: React.ComponentProps<typeof CommandPrimitive.List>) { | ||
| return ( | ||
| <CommandPrimitive.List | ||
| data-slot="command-list" | ||
| className={cn( | ||
| "max-h-[400px] overflow-auto overscroll-contain transition-[height] h-[calc(min(300px,var(--cmdk-list-height)))] bg-background", | ||
| className, | ||
| )} | ||
| {...props} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| function CommandEmpty({ | ||
| ...props | ||
| }: React.ComponentProps<typeof CommandPrimitive.Empty>) { | ||
| return ( | ||
| <CommandPrimitive.Empty | ||
| data-slot="command-empty" | ||
| className="py-6 text-center text-sm text-muted-foreground font-body" | ||
| {...props} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| function CommandGroup({ | ||
| className, | ||
| ...props | ||
| }: React.ComponentProps<typeof CommandPrimitive.Group>) { | ||
| return ( | ||
| <CommandPrimitive.Group | ||
| data-slot="command-group" | ||
| className={cn( | ||
| "overflow-hidden p-1.5 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground font-body", | ||
| className, | ||
| )} | ||
| {...props} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| function CommandSeparator({ | ||
| className, | ||
| ...props | ||
| }: React.ComponentProps<typeof CommandPrimitive.Separator>) { | ||
| return ( | ||
| <CommandPrimitive.Separator | ||
| data-slot="command-separator" | ||
| className={cn("h-px bg-border", className)} | ||
| {...props} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| function CommandItem({ | ||
| className, | ||
| ...props | ||
| }: React.ComponentProps<typeof CommandPrimitive.Item>) { | ||
| return ( | ||
| <CommandPrimitive.Item | ||
| data-slot="command-item" | ||
| className={cn( | ||
| "relative flex text-foreground cursor-pointer gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden data-[disabled=true]:pointer-events-none data-[selected=true]:bg-primary data-[selected=true]:text-primary-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover:bg-accent hover:text-accent-foreground transition-all font-body", | ||
| className, | ||
| )} | ||
| {...props} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| const CommandShortcut = ({ | ||
| className, | ||
| ...props | ||
| }: React.HTMLAttributes<HTMLSpanElement>) => { | ||
| return ( | ||
| <span | ||
| data-slot="command-shortcut" | ||
| className={cn( | ||
| "ms-auto text-xs tracking-widest text-muted-foreground font-body", | ||
| className, | ||
| )} | ||
| {...props} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| interface CommandCheckProps { | ||
| icon?: LucideIcon; | ||
| className?: string; | ||
| } | ||
|
|
||
| function CommandCheck({ | ||
| icon: Icon = Check, | ||
| className, | ||
| ...props | ||
| }: CommandCheckProps) { | ||
| return ( | ||
| <Icon | ||
| data-slot="command-check" | ||
| data-check="true" | ||
| className={cn("size-4 ms-auto text-primary", className)} | ||
| {...props} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| const CommandComponent = Object.assign(Command, { | ||
| Check: CommandCheck, | ||
| Dialog: CommandDialog, | ||
| Empty: CommandEmpty, | ||
| Group: CommandGroup, | ||
| Input: CommandInput, | ||
| Item: CommandItem, | ||
| List: CommandList, | ||
| Separator: CommandSeparator, | ||
| Shortcut: CommandShortcut, | ||
| }); | ||
|
|
||
| export { CommandComponent as Command }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| --- | ||
| title: Command | ||
| description: A command palette component for quick navigation and actions | ||
| lastUpdated: 21 Aug, 2025 | ||
| links: | ||
| source: https://github.com/Logging-Stuff/RetroUI/blob/main/components/retroui/Command.tsx | ||
| --- | ||
|
|
||
| <ComponentShowcase name="command-style-default" /> | ||
| <br /> | ||
| <br /> | ||
|
|
||
| <ComponentInstall> | ||
| <ComponentInstall.Cli npmCommand="npx shadcn@latest add "https://retroui.dev/r/command.json"" /> | ||
| <ComponentInstall.Manual> | ||
| #### 1. Install dependencies: | ||
|
|
||
| ```sh | ||
| npm install class-variance-authority cmdk | ||
| ``` | ||
|
|
||
| <br /> | ||
|
|
||
| #### 2. Copy the code 👇 into your project: | ||
|
|
||
| <ComponentSource name="command" /> | ||
|
|
||
| </ComponentInstall.Manual> | ||
| </ComponentInstall> | ||
|
|
||
| <br /> | ||
| <br /> | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Dialog | ||
|
|
||
| <ComponentShowcase name="command-style-dialog" /> | ||
| <br /> | ||
| <br /> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Use real double quotes via JSX braces instead of HTML entities in CLI command
Avoid
"in JSX props; it may copy as literal text. Use a JS string so copied command contains actual quotes across all shells.Run this quick check to catch any remaining HTML-entity quotes in MDX props:
🏁 Script executed:
Length of output: 1374
Refactor CLI command to use real quotes instead of HTML entities
Verified via ripgrep that this is the only occurrence of
"in MDX props. Please update the following line incontent/docs/components/command.mdx:📝 Committable suggestion
🤖 Prompt for AI Agents