kmp-compose-slot-api

Design Compose Multiplatform components with composable lambda slot parameters instead of data parameters.

2|Updated Jun 6, 2026
One-click install
npx skills add https://github.com/ronjunevaldoz/kmp-agent-skills --skill kmp-compose-slot-api-ronjunevaldoz
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: kmp-compose-slot-api
Source: https://github.com/ronjunevaldoz/kmp-agent-skills/tree/main/skills/kmp-compose-slot-api
Command: npx skills add https://github.com/ronjunevaldoz/kmp-agent-skills --skill kmp-compose-slot-api-ronjunevaldoz

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Rigid Compose components that accept only data parameters (like text: String) force an explosion of parameters whenever callers need icons, loading spinners, or custom layouts. This Skill teaches the Slot API pattern so components accept caller-provided composable content, keeping APIs small and flexible. ## Core Features & Use Cases - Single and Named Slots: Apply the trailing lambda convention for one content slot and named @Composable () -> Unit parameters for multi-region components like top bars and scaffolds. - Scoped Slots: Use RowScope and ColumnScope receivers so slotted content can use Modifier.weight() and other layout-scope features. - CompositionLocal Guidance: Decide when deep content injection should use CompositionLocal instead of slot threading, including compositionLocalOf vs staticCompositionLocalOf. - Use Case: Redesigning an AppButton(text = ...) into AppButton(onClick) { content } so the same component renders text, icon-plus-text, or a loading spinner with zero new parameters. ## Quick Start Ask the agent to redesign a Compose component using the slot API pattern with a trailing content lambda.

Frequently Asked Questions about kmp-compose-slot-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design a flexible Compose component with slots?▼

Replace data parameters with a `@Composable () -> Unit` slot parameter placed last so callers use trailing lambda syntax. The caller then decides what renders inside, whether text, icons, or loading spinners, without adding new component parameters.

What is the difference between slots and CompositionLocal in Compose?▼

Use slots when content is positional and belongs to a specific layout region of one component. Use CompositionLocal when a value like theme or a toast host must reach an arbitrary subtree many levels deep without threading parameters through every composable.

When should I use scoped slots like RowScope in Compose?▼

Use a scoped slot such as `@Composable RowScope.() -> Unit` when the caller needs layout scope features like `Modifier.weight()` inside the slotted content. Avoid scoped slots when the caller does not need layout scope, since they add noise without benefit.

When should I not use the slot API pattern?▼

Avoid slots when a simple value parameter suffices, such as a plain text label, when the parent must measure slot content before layout (use SubcomposeLayout), or when a component would need more than about four named slots, which signals it should be split.

How do I test Compose components that use slot parameters?▼

Use compose test rules to set content with tagged slot lambdas, then assert the caller-provided content renders and callbacks fire. Also verify empty slot lambdas do not crash and capture Roborazzi screenshots for visual contract checks.