compose-slot-api-pattern
This skill shows how to build flexible, reusable Compose components by delegating content to callers through `@Composable` lambda slots instead of accumulating primitive parameters. You'll learn to structure components around layout responsibility, use scope receivers to expose layout features, and co-locate sensible defaults in a `Defaults` object—the pattern Material 3's `ListItem` exemplifies.
Compose: slot API pattern teaches you to replace primitive content parameters with composable lambda slots for truly reusable components.
AI-generated summary based on this skill's SKILL.md
Decision gist · record as of 2026-07-28
Compose: slot API pattern teaches you to replace primitive content parameters with composable lambda slots for truly reusable components. This skill shows how to build flexible, reusable Compose components by delegating content to callers through `@Composable` lambda slots instead of accumulating primitive parameters. You'll learn to structure components around layout responsibility, use scope receivers to expose layout features, and co-locate sensible defaults in a `Defaults` object—the pattern Material 3's `ListItem` exemplifies.
Use it when
- The compose-slot-api-pattern shows how to use `@Composable` lambda slots for flexible component content.
- compose-slot-api-pattern covers `@Composable` lambda parameters as a core technique for content delegation.
Verify before relying
Read SKILL.md below before installing (1 file). Open directory: indexed for reading, not audited.
Install
vitorpamplona/amethyst/compose-slot-api-pattern · repository language: Kotlin
Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.
Frequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
What is the compose slot API pattern?
The compose-slot-api-pattern skill teaches how to build flexible, reusable Compose components by delegating content to callers through `@Composable` lambda slots instead of accumulating primitive parameters. You'll learn to structure components around layout responsibility, use scope receivers to expose layout features, and co-locate sensible defaults in a `Defaults` object—the pattern Material 3's `ListItem` exemplifies.
How do I make composable components flexible with slot APIs?
The compose-slot-api-pattern shows how to use `@Composable` lambda slots for flexible component content. Instead of adding boolean flags or string parameters, you delegate content areas to the caller. This lets you design reusable components that accept composable functions as parameters, giving callers full control over what renders in each slot while you manage the layout structure.
What are @Composable lambda parameters and when should I use them?
compose-slot-api-pattern covers `@Composable` lambda parameters as a core technique for content delegation. These are function parameters of type `@Composable () -> Unit` that let callers pass composable content directly into your component. Use them when you want to avoid primitive parameters like booleans or strings, and instead let callers define what renders in specific layout areas.
How do I avoid primitive parameters and anti-patterns in Compose?
The compose-slot-api-pattern skill reviews component signatures to identify and fix anti-patterns like boolean flags or string parameters. Instead, use `@Composable` lambda slots to let callers provide content. This approach scales better than adding more parameters, keeps your component signature clean, and follows Material 3 patterns like `ListItem` and `TopAppBar`.
What are scope receivers and nullable slots in Compose components?
compose-slot-api-pattern explains scope receivers and nullable slots for optional composable content areas. Scope receivers (like `RowScope`) expose layout features to slot content, letting callers use modifiers specific to that layout. Nullable slots let you provide optional content areas with sensible defaults, often co-located in a `Defaults` object for consistency.
How do I refactor Compose components using the slot pattern?
The compose-slot-api-pattern teaches refactoring by replacing primitive parameters with `@Composable` lambda slots, applying scope receivers to expose layout context, and grouping defaults in a `Defaults` object. This pattern improves component reusability and scalability, following Material 3 design principles used in `ListItem` and other flexible layout components.
SKILL.md
Rendered from the published skill. Quoted content, verbatim.
Compose: slot API pattern
Core principle
A reusable Compose component's job is to lay things out, not to enumerate what it lays out. The moment you write title: String, subtitle: String?, leadingIcon: ImageVector?, trailingIcon: ImageVector?, trailingText: String?, showSwitch: Boolean, switchValue: Boolean, onSwitchChange: (Boolean) -> Unit?, badge: String?, …, the component has stopped describing a layout and started enumerating call sites — and the next call site will need a parameter the component doesn't have.
The fix is to delegate content to the caller via @Composable lambda parameters. The component contributes structure (where the leading bit, headline, supporting bit, trailing bit go). The caller contributes everything that goes in those slots.
Material 3's ListItem is the canonical example: every visual piece is a slot (headlineContent,
(truncated - see the full file via the links below)
File tree — 1 file
.claude/skills/compose-slot-api-pattern/SKILL.md
Let your AI agent find skills like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.
wish › “Design or refactor a reusable Compose component using slot APIs instead of primitive parameters”
Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →
Related skills
This skill covers the slot API pattern for building reusable Jetpack Compose components. Learn to replace primitive content parameters and boolean flags with composable slots, use scope receivers to expose layout capabilities, and organize defaults in companion objects. The pattern keeps call sites clean while preserving full flexibility for unusual cases.
Compose Expert guides you through creating reusable visual components that work across Android and Desktop platforms. Learn when to share composables in commonMain versus keeping them platform-specific, master state patterns like remember and derivedStateOf, and apply Material3 theming consistently. The skill covers component structure, state hoisting, recomposition optimization, and custom icon creation.
Learn to craft responsive Android interfaces using Jetpack Compose and Material Design 3 (Material You). This skill covers adaptive layouts for phones, tablets, and foldables, dynamic color theming, and accessibility best practices.
This skill equips you to develop, test, and ship mobile applications across iOS and Android ecosystems. Whether you're building native apps or leveraging cross-platform frameworks, you'll learn to architect scalable solutions, integrate device capabilities, and navigate platform-specific deployment processes. Master the full lifecycle from prototyping through app store release.
This skill covers the core patterns for writing composables that respect the parent's layout choices. You'll learn to declare a modifier parameter with a default value, apply it to the root layout first, avoid hardcoding positioning decisions, and construct modifier chains as fluent expressions rather than step-by-step reassignments.
Build custom message bubble rendering in CometChat Android V6 Compose by implementing BubbleFactory to handle specific message types, override individual slots (avatar, header, content, footer), and apply immutable style classes. Register factories on CometChatMessageList and return null from slot methods to fall back to defaults, or replace entire bubbles by overriding getBubbleView().
More skills android-design-guidelines (MIT)