Repository navigation
chore: Adds internal style api v2 to container - #5192
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5192 +/- ##
=======================================
Coverage 97.73% 97.73%
=======================================
Files 996 998 +2
Lines 32224 32289 +65
Branches 11910 11939 +29
=======================================
+ Hits 31495 31559 +64
- Misses 684 685 +1
Partials 45 45 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Classic decoration overrides and stacked corner handling remain incomplete.
2 open issues
What changed in this PR
Adds internal Style API v2 support to Container, with root, header, and footer slots while keeping styleClassNames outside the public props interface.
Changes:
- Wires slot classes and documents supported styling properties.
- Shares custom corner radii across container surfaces and adjusts backgrounds and dividers.
- Adds slot-wiring tests, documentation snapshots, and a styled demo page.
| File | Description |
|---|---|
src/internal/styles/forms/mixins.scss |
Parameterizes the container radius, retaining its default. |
src/container/styles.scss |
Defines slots and updates backgrounds, dividers, and corners. |
src/container/internal.tsx |
Applies internal slot classes to container elements. |
src/container/__tests__/style-api.test.tsx |
Tests class placement and DOM prop filtering. |
src/__tests__/snapshot-tests/__snapshots__/style-docs.test.ts.snap |
Records Container’s styling documentation. |
pages/container/style-api-v2.scss |
Demonstrates generated slot mixins. |
pages/container/style-api-v2.page.tsx |
Adds styled Container examples. |
Review effort: Balanced
| @include style-api.docs( | ||
| 'root', | ||
| $tokens, | ||
| $properties: (background, border, box-shadow), |
There was a problem hiding this comment.
Classic is out of scope for Style API v2: the classic theme is deprecated and v2 targets visual refresh, where the root paints its own border and has no shadow. Listed under known limits in the description.
| .root.variant-stacked:not(:last-child) > .content-wrapper > .header, | ||
| .root.variant-stacked:not(:last-child) > .content-wrapper > .footer { | ||
| border-end-start-radius: 0; | ||
| border-end-end-radius: 0; | ||
| } | ||
| .root.variant-stacked + .root.variant-stacked > .content-wrapper > .header { | ||
| border-start-start-radius: 0; | ||
| border-start-end-radius: 0; | ||
| } |
There was a problem hiding this comment.
Added the stacked reset for the fit-height clipping wrapper, since it would otherwise clip a footer background to a rounded corner at the junction. The media image's corners at a stacked junction are unchanged from main and out of scope here.
8f1a3ea to
fd22b46
Compare
919582d to
2c35aba
Compare
2c35aba to
40c4239
Compare

Description
Adds the internal Style API v2 to Container with three slots.
root, the container box: propertiesbackground,border,box-shadow; token--awsui-style-border-radius, which also rounds the header, footer and media corners. Adjoining corners of stacked containers stay square.header, rendered whenheaderis set: propertiesbackground,border(the block-end side is the divider between the header and the content).footer, rendered whenfooteris set: propertiesbackground,border(the block-start side is the divider between the content and the footer).Header and footer have their own
backgroundbecause a consumer element inside the section (withdisable*Paddings) cannot match the container's rounded corners without knowing the radius. Padding stays with the consumer throughdisable*Paddings; the content area has no slot since the root background covers it.CSS changes that make the slots work:
top-navigationcontext, where only the content token is overridden, a non-sticky header takes the content colour.fitHeightwrapper, which clips to the box already.none, so a header border set through the mixin draws there too.container-stylemixin takes the radius as a parameter (default unchanged); the fit-height wrapper and media corners read the same radius chain as the root.Known limits, unchanged from main: in the classic theme the root border and shadow are painted by pseudo-elements, so the root
borderandbox-shadowproperties do not replace them there; the media image keeps its rounded corners at a stacked junction.The
styleClassNamesprop is internal and not part of the publicContainerProps. Design-token values and the v1 inline styles are unchanged.Tracker section: P3d34KdbCd6o.
How has this been tested?
npm run build; unit tests forsrc/container,src/cards,src/expandable-section,src/tabs, the table and sticky-header tests, and the style-docs snapshot; prettier, stylelint, eslint.src/container/__tests__/style-api.test.tsx: each slot class lands on its element in the default and stacked variants and with media, unknown keys are ignored, the prop does not reach the DOM.pages/container/style-api-v2styled only through the generatedcontainer.root(),container.header()andcontainer.footer()mixins: every row, media on top, two stacked containers, header and footer only, and a header filled by a consumer element withdisableHeaderPaddings. Checked in the browser (light, dark, classic) that header and footer backgrounds stay inside the rounded corners and stacked junctions are square. Not in the visual regression suite yet, like the otherstyle-api-v2pages.