CamoCard
Concept
1. Why
A card groups related content (a product, an article, a setting) into one visual unit, and is often tappable as a whole. CamoCard is a CamoSurface with three extra concerns: an appearance (solid, soft, raised or outline), a tone (default, or a status color for status panels), and optional clickability with press feedback. It reuses the surface treatment, so it looks right on every skin.
2. Shape
Material mapping preview
| Appearance | tone = Default | Material 3 | With a status tone (e.g. Warning) |
|---|---|---|---|
Solid | primary fill, onPrimary content (a hero or highlight card) | – (Camouflage addition) | warning fill, onWarning content |
Soft | surfaceContainerHighest fill, onSurface content | Filled card | warningContainer fill, onWarningContainer content |
Raised (default) | surfaceContainerLow + level1 | Elevated card | the same, plus a warning start border (4dp) |
Outline | surface + outlineVariant border | Outlined card | warning border |
Ghost and Link fall back to Outline (Design Language §3.3).
See Material Skin.
3. API
Contract
fun CamoCard(
onClick: (() -> Unit)? = null, // null → not clickable, no feedback, no role
appearance: Appearance? = null, // null → CardTheme.defaultAppearance (skin default: Raised)
tone: Tone = Default, // Error / Success / Warning / Info → status panel
enabled: Boolean = true, // only meaningful when clickable
selected: Boolean? = null, // non-null → a selectable card (plan, payment method, address pickers)
content: Slot,
)
State → renderer: CardState(appearance, tone, clickable = onClick != null, enabled, selected?, interaction: InteractionState). Slots: CardSlots(content).
Tokens used
colors.primary/onPrimary,surfaceContainerHighest,surfaceContainerLow,surface,outlineVariant,onSurface- the tone's color family (
xContainer,onXContainer,x) whentone != Default shapes.mediumelevation.level1(resting) andlevel2(hover, clickable only)spacingfor inner padding: none by default. The caller pads the content, because cards often hold edge-to-edge images.
Component theme
theme.components.card: CardTheme?. Every field is nullable in the theme. The skin's defaults(theme) fills whatever isn't set (Material defaults shown). See Theme §3.10.
| Field | Type | Material default | What it's for |
|---|---|---|---|
defaultAppearance | Appearance | Raised | the appearance used when a call passes none (ADR-28: a brand's default variant) |
shape | Shape | shapes.medium | card corners |
contentPadding | Padding | 0 | padding inside the card (0, because cards often hold edge-to-edge images) |
solidColors / softColors / raisedColors / outlineColors | CardColors(container, content, border?) | per the table above | colors per appearance for tone = Default |
raisedElevation | ElevationLevel | Level1 (hover Level2) | depth of the Raised appearance |
borderWidth | Dp | 1 | the Outline border |
selectedBorderColor / selectedBorderWidth | Color / Dp | primary / 2 | the border of a selected card (a brand choice, ADR-28) |
showSelectedCheck | Boolean | false | a check badge in the top-end corner of a selected card |
Accessibility
- Clickable: the role is button, and it's focusable. Its accessible name is the merged text of its content, unless the app sets one. There's a 48dp minimum, which a card nearly always exceeds.
- Not clickable: no role, and the content keeps its own semantics.
- Selectable (
selectednon-null): announced with its selected state ("Pro plan, selected"), and its content is merged into its label. In a single-choice group, the app wraps the cards in a container with radio-group semantics (see the recipe in §5). - No nested clickables inside a clickable card. Screen readers can't reach them reliably. Documented as a usage rule, and flagged in debug builds when detected.
4. Build steps
- Implement
CamoCardin core. Wrap it in the platform's clickable plus interaction tracking only whenonClick != null. Merge semantics when clickable. DebugSkincard renderer: reuse its surface renderer with a border forOutline.- Sample: four cards (Solid/Soft/Raised/Outline), a
Soft + Warningstatus panel, and one clickable card that navigates. - Test:
- a non-clickable card has no click semantics;
- a clickable card fires
onClickonce per tap; enabled = falseblocks clicks and shows the disabled look;- the appearance reaches the renderer.
Done when
- All four appearances render distinctly in light and dark.
- Press feedback appears only on clickable cards.
- A screen reader reads a clickable card as one button with its content as the name.
5. Edge cases
| Case | Decided behavior |
|---|---|
| A button inside a clickable card | Discouraged (see Accessibility). If it's really needed, make the card non-clickable and add an explicit "Open" button. |
| Long content at 200% font scale | The card grows vertically. It never has a fixed height. |
| A card in a horizontal carousel | The width comes from the parent. The card has no intrinsic width. |
| Disabled, non-clickable card | enabled is ignored (nothing to disable). The renderer draws the normal look. |
| RTL | No directional parts. The content mirrors on its own. The selected check moves to the top-left. |
| Selectable cards (settled 2026-09-27) | selected = true/false with onClick. The skin draws the selected border (and the check when showSelectedCheck). It passes ADR-23 (Fluent selectable Card, Carbon selectable tile, Material checkable card, Cupertino accent border + checkmark). |
| Pick one of several cards | A recipe, not a component: the app keeps the selected value and sets selected = (plan == chosen) on each card; Modifier.selectableGroup() (Compose) / Semantics(inMutuallyExclusiveGroup) (Flutter) around them. |
selected without onClick | Display-only selection (a summary screen). No role or focus. |
CardThemegainshoveredElevation(the Raised card's depth while a clickable card is hovered, instead of one level up) andtoneBorderWidth(the start strip a Raised card shows in a status tone: Minimal 4, Fluent 3).selectedwithoutonClickmerges the content into one node that announces the selection, with no role and no focus stop.GhostandLinkresolve toOutlinein core (cardAppearance), soCardState.appearanceis never one of them.
Implementation
1. Why
A card is a surface with an appearance, a tone, and optional clickability. The Kotlin-specific question is how to add the behavior modifier only when onClick != null, so a non-clickable card has no role, no focus stop, and no feedback.
2. Shape
3. API
@Composable
public fun CamoCard(
modifier: Modifier = Modifier,
onClick: (() -> Unit)? = null,
appearance: Appearance? = null, // null → CardTheme.defaultAppearance
tone: Tone = Tone.Default,
enabled: Boolean = true,
selected: Boolean? = null, // non-null → Modifier.selectable / semantics { selected = … }
interactionSource: MutableInteractionSource? = null,
content: @Composable () -> Unit,
)
CardTheme/CardStylehave the fields from the base Component theme table:shape,contentPadding,solidColors,softColors,raisedColors,outlineColors,raisedElevation,borderWidth.CardColors(container: Color, content: Color, border: Color?).- The resolved
CardStyle.colorsFor(appearance, tone, theme)follows the base table (Solid → strong fill, Soft → container fill, Raised → surface + depth, Outline → border). Core applies the fallbacks first:Ghost/Link→Outline.
Behavior only when clickable:
val behavior = if (onClick != null) modifier
.clickable(source, indication = null, enabled = enabled, role = Role.Button, onClick = onClick)
.semantics(mergeDescendants = true) {}
else modifier
The renderer draws the feedback only when state.clickable. Hover elevation (level1 → level2 for Raised) is animated with animateDpAsState(… , tween(theme.motion.durationShort)).
4. Build steps
CardTheme,CardStyle,CardColors,colorsFor.CamoCardwith conditional behavior;CardRendererin DebugSkin.commonTest:- no
onClick→ noRole.Buttonin semantics, and not focusable; - with
onClick→ one merged node, and a click fires once; enabled = false→ the click is ignored;tone = Warning+Soft→ container equalswarningContainer.
- no
Done when
- Four appearances × two tones render in the sample. Only clickable cards show feedback and receive focus.
5. Edge cases
| Case | Decided behavior |
|---|---|
| Nested clickable inside a clickable card | Compose delivers the tap to the innermost clickable. Semantics merging hides the inner one from screen readers, which is why the base discourages it. A debug check logs a warning when a clickable card's merged tree contains another click action. On by default in debug builds; CamouflageDebug.nestedClickableWarnings = false turns it off. |
| Hover on touch-only devices | collectIsHoveredAsState stays false. No special case needed. |
| Desktop right-click / context menu | Wrap the card in CamoContextMenuArea (CamoMenu). |
- The nested-clickable debug warning (
CamouflageDebug.nestedClickableWarnings) isn't built yet: it needs a walk of the merged semantics tree after layout.