We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
A keyboard-accessible command palette for Phoenix applications that enables quick navigation and actions via Cmd+K/Ctrl+K shortcuts. Built as a LiveView component with customizable search functionality and extensible result formatting.
Key Benefits
Implementation Details
The feature generates a complete command palette system with LiveView integration, hotkey bindings via hotkeys.js, and a protocol-based architecture for search results. The CommandPalette
module handles search logic across configurable contexts (app, admin), while CommandPalette.Format
protocol enables custom formatting for different data types. Results are wrapped in a Result
struct for consistent iteration and display.
Usage Example
# Mount in your layout
<%= live_render(
@conn,
YourAppWeb.Live.CommandPaletteLive,
id: "command-palette",
session: %{"context" => "app"}
) %>
# Implement custom formatting
defimpl YourAppWeb.CommandPalette.Format, for: User do
def header(_), do: "Users"
def label(user), do: user.email
def link(user, _context), do: ~p"/users/#{user}"
end
Configuration
Add contexts to the @possible_contexts
list in CommandPalette
module to enable different search scopes. The palette automatically adapts to your authentication system and admin interface if present.