ContextualToolbarGroupingProvider

Supplies the grouping preset the contextual toolbar applies at the current capacity — the Compose successor to the legacy MenuItemGroupingRule.

Called whenever the toolbar (re-)measures: capacity is the number of item slots the bar can show along its main axis (width when docked top, height when docked start/end), itemCount the number of flat items to fit, and defaultPreset the SDK's preset for that capacity. Return defaultPreset to keep the stock grouping, or any other structure — ids missing from the flat item list are skipped, so a preset can safely reference items that are disabled by configuration or licensing.

Functions

Link copied to clipboard
abstract fun provideGroupingPreset(kind: ContextualToolbarKind, capacity: Int, itemCount: Int, defaultPreset: List<ToolbarPresetEntry>): List<ToolbarPresetEntry>

Returns the preset to apply for kind at the given capacity.