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:| Method | Purpose |
|---|---|
group() | Widget name, shown as a collapsible heading in the sidebar. Shared values nest together. |
name() | Variant label, the leaf node under the group. |
source() | Module path shown as a breadcrumb in the preview pane. |
render() | Draw the widget into the preview area. |
| Method | Default | Purpose |
|---|---|---|
tab() | "Widgets" | Top-level tab: "Widgets", "Panes", "Views", or "Styles". |
description() | "" | One-line summary displayed in the preview pane. |
props() | &[] | PropInfo slice documenting the widget’s configurable surface. |
interactive() | false | Whether the preview captures keyboard and mouse input. |
animated() | false | Whether the ingredient needs periodic redraws (33ms tick). |
handle_key() | false | Process a key event while focused. |
handle_mouse() | false | Process a mouse event while focused. |
Basic ingredient
A static ingredient is a unit struct with mock data:Interactive ingredient
Setinteractive() 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.
true from handle_key() or handle_mouse() to consume the event, false to let the Pantry handle it.
Tab assignment
Overridetab() to place ingredients in a different tab:
Feature gating
Gate ingredient modules behind#[cfg(feature = "tui-pantry")] so they don’t compile into production:
Registration
Declare your ingredient modules inpantry.toml:
my_crate::widgets::gauge::ingredient::ingredients() via the pantry_ingredients!() proc macro. The entry point uses this automatically:
[ingredients] section in pantry.toml, pass the factory directly: