Android — Material 3
JS behaviour
Top app bar
The three official top app bar heights — small, medium and large — in a phone frame that collapses on scroll: the big title settles onto the bar line while the surface colour appears the moment you move.
Real scenarios
The component as it is used in a product — not a specimen grid.
A bar that folds on scroll
Scroll the list — the 152 px large title settles onto the bar line at 22 px, the surface colour fills in and the level-2 shadow appears the moment you move. The ⋮ menu works.
The other two heights
Small — 64 px, title beside the icon — and medium — 112 px, title settled at the bottom; the collapsed bar above ends its life as the small one.
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| height | px | '64 · 112 · 152' | The official heights of the small, medium and large bars. |
| scroll | behaviour | 'collapse' | On scroll the large bar collapses to small and gains the level-2 surface shadow. |
| actions | count | '≤ 2' | At most two action icons plus the overflow menu. |
Snippet
<header class="m3bar" data-size="large">
<button class="m3bar-icon">☰</button>
<h1 class="m3bar-title">کتابخانهٔ من</h1>
<button class="m3bar-icon">🔍</button>
</header>
<style>
.m3bar { display: flex; align-items: center; gap: 8px; padding-inline: 16px;
transition: block-size .3s cubic-bezier(.2,0,0,1); }
.m3bar[data-size='large'] { block-size: 152px; align-items: end; padding-block-end: 28px; }
.m3bar-title { font: 400 28px/1.2 Roboto; transition: font-size .3s; }
.m3bar[data-size='small'] { block-size: 64px; background: #F7F2FA; }
.m3bar[data-size='small'] .m3bar-title { font-size: 22px; }
</style>