CamoBanner
Concept
1. Why
A banner is an inline message that stays in the layout until it's resolved: "Your trial ends in 3 days · Upgrade", "Couldn't sync · Retry", a form-level error summary. Fluent calls it MessageBar, and Carbon inline notification. Material dropped banners in M3, but apps still need them. Unlike a snackbar, it's placed in the page, not shown. It's the clearest showcase of Tone.
2. Shape
Material mapping preview: there's no M3 component. The Material skin draws it like a Soft card:
- the tone's container color and a default status icon per tone (info ⓘ, success ✓, warning ⚠, error ⨯);
- actions as
Ghostbuttons in the tone's strong color; shapes.medium.
3. API
Contract
fun CamoBanner(
message: String,
tone: Tone = Info,
title: String? = null,
icon: Widget? = null, // null → the skin's default icon for the tone; pass an empty widget for none
actions: List<Widget> = emptyList(), // usually CamoButtons (appearance = Ghost)
onDismiss: (() -> Unit)? = null, // non-null → a ✕ button
appearance: Appearance? = null, // null → BannerTheme.defaultAppearance (skin default: Soft); Soft | Solid | Outline
)
State → renderer: BannerState(title?, message, tone, appearance, dismissible). Slots: BannerSlots(icon?, actions, dismiss?).
Tokens used
- the tone family (container, on-container, strong)
typography.titleSmall(title),bodyMedium(message)shapes.medium,spacing.lpadding
Component theme
theme.components.banner: BannerTheme?. 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 | Soft | the appearance used when a call passes none (ADR-28: a brand's default variant) |
shape | Shape | shapes.medium | corners |
padding | Padding | 16 | inner padding |
titleStyle / messageStyle | CamoTextStyle | titleSmall / bodyMedium | texts |
iconSize | Dp | 24 | status icon |
accentBorder | Boolean | false | a start border in the tone's strong color (Carbon style) |
toneIcons | ToneIcons(info, success, warning, error: IconSource) | the skin's icons | the default status icons, so a brand can use its own icon set (ADR-28). CamoSnackbar uses the same icons when showToneIcon is on. |
Accessibility
- Role status (
Info/Success), or alert (Warning/Error) when the banner appears after the page loaded, so it's announced. A banner present from the start isn't announced; it's read in order. - Tone must not be conveyed by color alone: the default icon and the title/message carry it too (WCAG 1.4.1).
- The ✕ is a
CamoIconButtonlabelled "Dismiss".
4. Build steps
CamoBanner,BannerRenderer(default icons per tone), and the DebugSkin renderer.- Sample: the four tones, with and without title, actions and dismiss. A form-error summary above a
CamoForm. - Tests: an alert role for errors that appear later; the dismiss button; the default icon per tone.
Done when
- All four tones in three appearances render in light and dark, and are announced correctly.
5. Edge cases
| Case | Decided behavior |
|---|---|
| Long messages at 200% | The text wraps, and the actions move below the text. |
| Many actions | Up to two recommended. More wrap to a second row. |
| Sticky banners (top of the screen, global) | App layout: place the banner above the content in the page. It's not an overlay. |
BannerThemegainsaccentWidth,borderWidth(the Outline appearance),dismissIconandstrings;toneIconsis aToneIcons(info, success, warning, error)withofTone(tone), shared with the snackbar.BannerStyle.colorsFor(appearance, tone, theme)returnsBannerColors(container, content, accent, border?): Soft the tone's container, Solid its strong fill, Outline the surface with a tone border.- Ghost and Link buttons among the actions take the accent the renderer provides around them (core overrides their colors in a nested provider), so a Retry on a Solid error banner is readable. Apps pass plain Ghost buttons, no tone.
- The ✕ is a field action, its own accessibility node; the texts and icon read as one node.
- Fluent's MessageBar draws a light intent border.
Implementation
1. Why
An inline message with a tone, an optional title, actions and a dismiss button. Kotlin's specifics: the actions wrap below the text when space runs out (FlowRow), and a banner that appears later (a sync error) is announced with a live region.
2. Shape
3. API
@Composable
public fun CamoBanner(
message: String,
modifier: Modifier = Modifier,
tone: Tone = Tone.Info,
title: String? = null,
icon: (@Composable () -> Unit)? = null, // null → BannerTheme.toneIcons for the tone
actions: @Composable RowScope.() -> Unit = {},
onDismiss: (() -> Unit)? = null,
appearance: Appearance? = null,
)
- Icon:
style.toneIconsgives anIconSourceper tone, drawn withCamoIcon; passingicon = {}shows none. - Actions: laid out in a
FlowRowbelow the texts; at wide widths the renderer may place them at the end of the row (a skin choice). Buttons inherit the tone's content color throughProvideContentStyle. - Semantics: the banner merges its texts; for
Tone.Error/Tone.Warningit setsliveRegion = LiveRegionMode.Politeso a banner inserted after first composition is read. The dismiss button isCamoIconButton(contentDescription = "Dismiss"). - Accent border:
style.accentBorderdraws a start-edge bar withdrawBehind, mirrored in RTL.
4. Build steps
BannerTheme/Style(withtoneIcons),CamoBanner, the DebugSkin renderer.commonTest: default icon per tone;icon = {}hides it; actions wrap at 200% font scale; the live region on a late Error banner; dismiss calls back.
Done when
- Trial, sync-error and form-summary banners render in each tone and appearance, and a late error banner is announced.
5. Edge cases
| Case | Decided behavior |
|---|---|
| Banner shown from the first frame | Not announced as an alert (it's part of the page); it's read in reading order. |
| Many actions | Wrap to more rows; guidance stays two. |
actions: (@Composable RowScope.() -> Unit)?; Minimal and Fluent lay them out in aFlowRowbelow the texts.