Skip to main content
An ingredient is one preview: a specific widget configuration with mock data. You implement the Ingredient trait for a struct, and the Pantry renders it in the preview pane with navigation, description, and prop documentation.

The Ingredient trait

Four methods are required: Optional methods with defaults:

Basic ingredient

A static ingredient is a unit struct with mock data:
Each ingredient module exports a factory function:

Interactive ingredient

Set interactive() to true to receive keyboard and mouse input when the preview pane has focus. Press Enter in the sidebar to focus an interactive ingredient. Press Esc to return.
Return true from handle_key() or handle_mouse() to consume the event, false to let the Pantry handle it.

Tab assignment

Override tab() to place ingredients in a different tab:

Feature gating

Gate ingredient modules behind #[cfg(feature = "tui-pantry")] so they don’t compile into production:
For flat crates, gate at the crate root:

Registration

Declare your ingredient modules in pantry.toml:
Each entry expands at compile time to my_crate::widgets::gauge::ingredient::ingredients() via the pantry_ingredients!() proc macro. The entry point uses this automatically:
For crates without an [ingredients] section in pantry.toml, pass the factory directly:
For multi-crate workspaces, see the array-of-tables syntax in the configuration reference.

Example pantry

The TUI Pantry repository includes a complete example pantry showcasing ratatui’s stock widgets with a Catppuccin Mocha theme. It demonstrates all four tabs (Widgets, Panes, Views, and Styles) and serves as a reference for the full integration pattern. Run it with: