Omnibar
The header's search field, grown in place into scoped results with each row's actions inline. On a phone it becomes a full-screen search.
labelOmnibarScopesrecentshortcutdisabledimport { BedDouble, FileText, Receipt, User, Zap } from "lucide-react"
import { Omnibar, OmnibarContent, OmnibarInput, OmnibarList, OmnibarScopes, OmnibarTrigger, type CommandItem, type OmnibarScope } from "@/components/ui/omnibar"
const commands: CommandItem[] = [
{ id: "arrivals", label: "Arrivals", group: "Pages", icon: <FileText />, shortcut: "G A", actions: [{ id: "open", label: "Open" }] },
{ id: "departures", label: "Departures", group: "Pages", icon: <FileText />, shortcut: "G D", actions: [{ id: "open", label: "Open" }] },
{ id: "housekeeping", label: "Housekeeping", group: "Pages", icon: <FileText />, shortcut: "G H", actions: [{ id: "open", label: "Open" }] },
{ id: "check-in", label: "Check in a guest", group: "Actions", icon: <Zap />, shortcut: "C", actions: [{ id: "run", label: "Run" }] },
{ id: "walk-in", label: "Walk-in booking", group: "Actions", icon: <Zap />, shortcut: "N", actions: [{ id: "run", label: "Run" }] },
{ id: "key-cards", label: "Print key cards", group: "Actions", icon: <Zap />, actions: [{ id: "run", label: "Run" }] },
{ id: "fault", label: "Report a fault", group: "Actions", icon: <Zap />, actions: [{ id: "run", label: "Run" }] },
{ id: "tomas", label: "Tomás Herrera", description: "Arriving 14:00 · room 108 not ready", group: "Guests", icon: <User />, actions: [{ id: "check-in", label: "Check in" }, { id: "assign", label: "Assign room" }, { id: "message", label: "Message" }] },
{ id: "ada", label: "Ada Okafor", description: "Arriving 15:30 · room 214", group: "Guests", icon: <User />, actions: [{ id: "check-in", label: "Check in" }, { id: "assign", label: "Assign room" }, { id: "message", label: "Message" }] },
{ id: "jonas", label: "Jonas Weber", description: "Late arrival, 23:00 · room 110", group: "Guests", icon: <User />, actions: [{ id: "check-in", label: "Check in" }, { id: "assign", label: "Assign room" }, { id: "message", label: "Message" }] },
{ id: "mei", label: "Mei Lin", description: "Checked in · room 302", group: "Guests", icon: <User />, actions: [{ id: "check-in", label: "Check in" }, { id: "assign", label: "Assign room" }, { id: "message", label: "Message" }] },
{ id: "room-108", label: "Room 108", description: "Garden Single · being cleaned", group: "Rooms", icon: <BedDouble />, actions: [{ id: "open", label: "Open" }, { id: "clean", label: "Mark clean" }, { id: "block", label: "Block" }] },
{ id: "room-110", label: "Room 110", description: "Garden Single · ready", group: "Rooms", icon: <BedDouble />, actions: [{ id: "open", label: "Open" }, { id: "clean", label: "Mark clean" }, { id: "block", label: "Block" }] },
{ id: "room-214", label: "Room 214", description: "Sea View Double · ready", group: "Rooms", icon: <BedDouble />, actions: [{ id: "open", label: "Open" }, { id: "clean", label: "Mark clean" }, { id: "block", label: "Block" }] },
{ id: "booking-4807", label: "Booking #4807", description: "Tomás Herrera · 14 to 16 Dec", group: "Bookings", icon: <Receipt />, actions: [{ id: "open", label: "Open" }, { id: "extend", label: "Extend stay" }, { id: "cancel", label: "Cancel" }] },
{ id: "booking-4821", label: "Booking #4821", description: "Ada Okafor · 14 to 16 Dec", group: "Bookings", icon: <Receipt />, actions: [{ id: "open", label: "Open" }, { id: "extend", label: "Extend stay" }, { id: "cancel", label: "Cancel" }] },
]
const scopes: OmnibarScope[] = [
{ id: "actions", label: "Actions", prefix: ">" },
{ id: "guests", label: "Guests", prefix: "@" },
{ id: "rooms", label: "Rooms", prefix: "#" },
{ id: "bookings", label: "Bookings" },
]
export function DeskSearch() {
return (
<Omnibar
items={commands}
scopes={scopes}
recent={["tomas","room-108","housekeeping"]}
suggested={["check-in","walk-in","key-cards","fault"]}
label="Search the desk"
onRun={(item, action) => {
// run it
}}
>
<OmnibarTrigger placeholder="Search guests, rooms, bookings" />
<OmnibarContent>
<OmnibarInput placeholder="Search guests, rooms, bookings or type > for actions" phonePlaceholder="Search guests, rooms, bookings" />
<OmnibarScopes />
<OmnibarList />
</OmnibarContent>
</Omnibar>
)
}Usage
import { BedDouble, User } from "lucide-react"
import {
Omnibar,
OmnibarContent,
OmnibarInput,
OmnibarList,
OmnibarScopes,
OmnibarTrigger,
type CommandItem,
type OmnibarScope,
} from "@/components/ui/omnibar"
const commands: CommandItem[] = [
{
id: "tomas",
label: "Tomás Herrera",
description: "Arriving 14:00",
group: "Guests",
icon: <User />,
actions: [
{ id: "check-in", label: "Check in" },
{ id: "message", label: "Message" },
],
},
{ id: "room-108", label: "Room 108", description: "Garden Single", group: "Rooms", icon: <BedDouble /> },
]
const scopes: OmnibarScope[] = [
{ id: "guests", label: "Guests", prefix: "@" },
{ id: "rooms", label: "Rooms", prefix: "#" },
]
export function DeskSearch({ run }: { run: (id: string, action?: string) => void }) {
return (
<Omnibar items={commands} scopes={scopes} onRun={(item, action) => run(item.id, action?.id)}>
<OmnibarTrigger />
<OmnibarContent>
<OmnibarInput />
<OmnibarScopes />
<OmnibarList />
</OmnibarContent>
</Omnibar>
)
}Examples
Front desk
Saltmarsh Hotel · Mon 14 Dec
import { BedDouble, FileText, User, Zap } from 'lucide-react';
import {
Omnibar,
OmnibarContent,
OmnibarInput,
OmnibarList,
OmnibarScopes,
OmnibarTrigger,
type CommandItem,
type OmnibarScope,
} from '@/components/ui/omnibar';
const guest = [
{ id: 'check-in', label: 'Check in' },
{ id: 'assign', label: 'Assign room' },
{ id: 'message', label: 'Message' },
];
const commands: CommandItem[] = [
{ id: 'arrivals', label: 'Arrivals', group: 'Pages', icon: <FileText />, shortcut: 'G A' },
{ id: 'check-in', label: 'Check in a guest', group: 'Actions', icon: <Zap />, shortcut: 'C' },
{ id: 'tomas', label: 'Tomás Herrera', description: 'Arriving 14:00', group: 'Guests', icon: <User />, actions: guest },
{ id: 'ada', label: 'Ada Okafor', description: 'Arriving 15:30', group: 'Guests', icon: <User />, actions: guest },
{ id: 'room-108', label: 'Room 108', description: 'Garden Single', group: 'Rooms', icon: <BedDouble /> },
];
const scopes: OmnibarScope[] = [
{ id: 'actions', label: 'Actions', prefix: '>' },
{ id: 'guests', label: 'Guests', prefix: '@' },
{ id: 'rooms', label: 'Rooms', prefix: '#' },
];
export function Search({ onRun }: { onRun: (item: CommandItem, actionId?: string) => void }) {
return (
<Omnibar items={commands} scopes={scopes} recent={['tomas']} onRun={(item, action) => onRun(item, action?.id)}>
<OmnibarTrigger placeholder="Search guests, rooms, bookings" />
<OmnibarContent>
<OmnibarInput />
<OmnibarScopes />
<OmnibarList />
</OmnibarContent>
</Omnibar>
);
}Front desk
Saltmarsh Hotel · Mon 14 Dec
import { Omnibar, OmnibarContent, OmnibarInput, OmnibarList, OmnibarTrigger, type CommandItem } from '@/components/ui/omnibar';
const places: CommandItem[] = [
{ id: 'inbox', label: 'Inbox', group: 'Go to' },
{ id: 'projects', label: 'Projects', group: 'Go to' },
{ id: 'new-issue', label: 'New issue', group: 'Create' },
];
export function JumpTo({ onRun }: { onRun: (id: string) => void }) {
return (
<Omnibar items={places} onRun={(item) => onRun(item.id)}>
<OmnibarTrigger placeholder="Jump to" />
<OmnibarContent className="sm:w-[400px]">
<OmnibarInput placeholder="Jump to" />
<OmnibarList empty={(q) => `Nowhere called “${q}”`} />
</OmnibarContent>
</Omnibar>
);
}Notes
Scopes
A scope narrows the list to one kind of record. Pick it from its chip, or type its prefix first: @tom searches guests for tom. A prefix only works from All, so a scoped search can hold an @. Backspace on an empty search goes back to All. By default a scope holds the items whose group is its label; give it match when the groups do not line up.
Actions on the row
The highlighted row shows its actions when it has more than one. Tab and Shift+Tab move between them, Enter runs the one picked, and a click runs the one clicked. Moving the highlight or typing starts again from the first. A row with one action, or none, leaves Tab alone. Disabled rows show no actions and are listed last, so the first highlight is always one Enter can run.
Long lists
The list renders at most limit rows, 50 by default, so a search over thousands of records stays quick: keep typing to narrow it. Moving the highlight re-renders only the two rows it leaves and lands on, and rows are memoized, so a custom OmnibarList child that returns an OmnibarItem keeps that.
The item shape
CommandItem, CommandAction, CommandRunDetails and filterCommands live in command-items, which dinachi add omnibar installs alongside, and the Command Palette uses the same module, so one list can feed both. A sub-list's items are listed in its place here, as the omnibar has no levels.
No motion
It is used many times a day, so it never animates: the field does not grow, the panel does not fade in, and the results, highlight and scope change at once. On a phone the action sheet is a Drawer and keeps its own slide.
On a phone
Below 640px the field opens a full-screen search with Cancel, and chips without prefixes. The best match carries its actions as buttons; other rows have a ⋯ that opens them in a sheet. Rows, chips, the ⋯ menus, buttons and Cancel take a tap of 44px or more, the sheet's actions 50px. Give OmnibarInput a phonePlaceholder when its placeholder is long.
API
details.cancel() keeps it open.details.cancel() refuses the change.Agent
Inside an AgentProvider, it appears in agent.snapshot() as combobox.
Reads
labelThe omnibar's label.
openTrue while the panel is showing.
valueThe search text, with the scope's prefix in front, while open.
itemsEvery command while closed, or the matches while open.
disabledTrue when the omnibar is blocked.
Actions
open() / close()Opens or closes the panel.
search("tom", "Guests")Opens it, picks the scope if named, types the text and returns the matches with their group and actions. A prefix in the text picks its scope too.
select("Tomás Herrera", "Check in")Runs a command with its first action or the one named, and closes.
Opening and closing run through onOpenChange, the search through onValueChange and running through onRun. isAgentChange(details) is true for each; details.cancel() refuses it and the agent is told. disabled refuses everything. The agent finds a closed omnibar through its field, so render OmnibarTrigger.
await agent.act({
steps: [
{ ref: "Search the desk", action: "search", args: ["tom", "Guests"] },
{ ref: "Search the desk", action: "select", args: ["Tomás Herrera", "Check in"] },
],
})Accessibility
- The field is a button named by label while closed; the panel is a popover dialog with the same name, and focus moves to its search and back to the field on close.
- The search has role combobox and the results are a listbox named by label; aria-activedescendant keeps focus in the search and the highlighted option is aria-selected.
- Scope chips are toggle buttons in a group named Scope; the picked one is aria-pressed.
- The listbox holds only options. Their actions are pointer targets hidden from assistive tech; the highlighted option is described by what Enter runs, such as Enter: Message, and moving it with Tab is announced politely, on a phone too.
- Matched words are marked with mark. The number of matches and a scope picked by a typed prefix or Backspace are announced politely; a chip's aria-pressed speaks for itself. Moving the highlight clears the last announcement, so the same text speaks again on the next row.
- On a phone the panel is modal: it has aria-modal and the rest of the page, bar live regions such as toasts, is hidden from assistive tech while it is up. The top hit's buttons and each ⋯ are touch targets inside the listbox, so a screen reader reaches the same sheets through buttons after it named Actions for and the item. The sheet is a Drawer named by the item that returns focus to the button that opened it.