Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Quick Open Files Command Menu Block for React

A cloud drive's quick open as a command menu shown open at the top of a file manager: recent files first, a search across every folder, middle-shortened paths with sizes and dates, kind chips and a sort, and the chosen row selected in the table behind.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Open any file without remembering which folder it is in with this quick open command menu for React with Base UI. It opens from the Files screen of Attichall, a cloud storage app, whose header holds an outline field with its ⌘ K cap, and the file manager is drawn under a soft scrim inside a hairline frame with a plus mark on each corner: a sidebar of folders and a table of twelve files made of shapes. The menu is the catalog Command at the top of the stage. With the input empty it lists the recent files; typing matches names and folders across every folder at once, with or without accents. Each row is the file's name with the matched letters marked, its path with the middle shortened so the last two folders always show, its size and the day it changed, in tabular numerals. Above the input a ToggleGroup filters by kind (All, Docs, Images, Sheets) and another sorts (Name, Modified, Size); the foot counts the files and says the order. Choosing a file selects its row in the table behind, which wears the file's name. Nothing opens. For preview the menu is drawn open in place when the page loads; the field, or Ctrl or ⌘ K while focus is in the block, opens the real command dialog, wider, with the same filter, sort and query. For drives, document tools, design libraries and any product with more files than anyone files well.

FAQ

Why is the menu already open, and what do I keep?

So you can see it without a click. On load the menu is the Command drawn inline over a picture of the file manager, in a plain shell that is not modal, so nothing is trapped, hidden or focused and the page around the preview keeps working. The header's field opens the real command dialog, modal, with its focus trap, Escape and focus return, and the inline copy stays closed until a reload. Both show the same Palette and share the block's state, so the filter, the order and what you typed in the copy are in the real dialog. In your app keep the dialog and drop the copy: the "in-place" state, the scrim with its shell and the Escape and blur effects.

How is the path shortened, and can a screen reader read all of it?

The path is split into its head and its last two folders. The head is a truncating span, so it gives way with an ellipsis when the row is narrow, and the last two folders never shrink. CSS shortens only what is drawn: the whole path stays in the row's text, so a screen reader reads every folder, and it is in the title, so a hover shows it. The path is set left to right even on a right-to-left page, because it is a typed value.

How do the chips and the sort work together with the search?

The kind chips filter whatever the list holds, recents or matches; the sort orders it by name (A to Z), by the day it changed (newest first) or by size (largest first), with the name settling ties. Both groups always have one chip chosen, and changing either announces the new count and order. The search wins over the recents: once something is typed the list is every file that matches, in any folder, under the same filter and sort.

Why is quick open on ⌘ K and not ⌘ P?

Because ⌘ P and Ctrl P are the browser's print shortcut and never reach a page, so showing them would promise a key that does not work. The field's shortcut, ⌘ K or Ctrl K while focus is inside the block, is a capture listener that does work, and it is the only key shown.

What stays local, and how do I wire it?

All of it. The twelve files, their folders, sizes and dates are typed and made up, the dates are fixed and never read from the clock, and choosing a file only selects its row in the drawing. In your app build FILES from your index (name, folder path, kind, size in bytes and modified time), keep recents as a flag or a list, and make pick open the file.

Is it accessible from the keyboard?

Yes. Tab reaches the two chip groups, then the input; type to search, the arrow keys move through the rows, Enter selects the highlighted file and Escape closes the menu and puts focus on the field; Ctrl or ⌘ K opens the dialog while focus is inside the block, and only then. The rows are options of a cmdk listbox; the block turns off its own fuzzy filter and lists the rows itself.

How does it look on a phone?

The size and the date go and each row keeps its name and its path, still shortened in the middle. The two chip groups wrap onto two lines, the copy shown on load docks to the top of the page at full width so the keyboard does not cover the foot, the key hints go and the count stays. The real dialog keeps the Command dialog's own phone layout.

  • Pro

    A CMS page browser as a command menu shown open as a page stack: a trail of crumbs over the list, the arrow keys go into a folder and back out, and a page closes the menu and names itself on the page list behind.

  • Pro

    Recent Items Command Menu

    Search everything

    A project hub's command menu shown open on what you opened lately: Today, Yesterday and Earlier buckets before you type, recent matches first when you do, opening a row moves it to the top, and a last row clears the list.

  • Pro

    A company intranet's command menu shown open: one input searches pages, docs, people and tags at once, each type is a group of three matches with a row that opens it in place, and the foot counts the results by type.

  • Pro

    Spotlight Command Menu

    Search everything

    A desktop launcher's search bar shown open across a drawn desktop: apps, files and a web row, tabs that filter by kind, a larger top hit with a one-line preview, and a drawn window that opens on the desktop.

  • Pro

    A git client's project switcher as a command menu shown open at the centre of the title bar: pinned and recent repositories with branch, host, ahead and behind, a switch that keeps only projects with changes, and a title bar and file tree that follow the choice.

  • Pro

    A database admin's table finder as a command menu shown open beside a schema pane: a switch between a read-only Production and a Staging connection, tables with their row counts, and a pane of the highlighted table's columns with a Copy SELECT button.