Skip to content

feat(element-theme): support element list inside cards - #2745

Open
kfenner wants to merge 2 commits into
mainfrom
kaspar-fenner-cards-with-lists
Open

feat(element-theme): support element list inside cards#2745
kfenner wants to merge 2 commits into
mainfrom
kaspar-fenner-cards-with-lists

Conversation

@kfenner

@kfenner kfenner commented Sep 8, 2026

Copy link
Copy Markdown
Member

Follow-up to #2742 (base branch kaspar-fenner-deprecate-list-group). That PR deprecates the Bootstrap .list-group; this one makes the Element .list a working replacement inside .card, and migrates the remaining examples and docs.

The library change is purely additive — no .list-group rule is removed or altered, so existing markup is unaffected.

_card.scss

Two things were missing for .list in a card.

1. Rounded corners. A .list as first/last child now gets the card's inner radius, and the outer corners of the first/last item inherit it, so the background of a hovered, filled or outlined item no longer paints over the card's rounded corners.

The per-corner rules are written as > :first-child { &, > .list-item { ... } } because .list-item sits either on the <li> itself or on a wrapped <button class="list-item list-item-action">. Specificity works out: .card > .list > :first-child > .list-item is (0,4,0) and beats .list.list-filled .list-item at (0,3,0).

2. Focus ring. .list was added to the existing .card-header + :is(...) rule that switches the focus outline to an inset offset. That half alone is a regression, so it is paired with the z-index treatment that .list-group already has — extending the precedent from ec3d92f (fix(theme): fix card spacing for focus outline).

Focus-visibility bug

A scrollable list following a .card-header draws its focus ring inside itself. Without the pairing, any item background paints over it. This is not a filled/outline edge case — plain .list-divider items are transparent at rest but paint $si-sys-background-hover on hover, and hovering the top row of a scrollable list in a card is ordinary interaction.

.list-divider, first item hovered — before / after:

.list-filled, focused — before / after (previously the ring survived only in the gap between items):

Verified across all six states (list-divider/list-filled/list-outline, each focused and focused+hovered) — all show an unbroken ring after the change.

Note the rule targets > li rather than .list-item. z-index only applies to positioned elements and flex items; in a .list the flex items are the <li> children, so a .list-item rule would silently no-op for the wrapped-button shape. Pushing the li back takes any wrapped button with it. z-index: 0 on the container scopes the negative children to the list instead of letting them sink behind the card background.

si-card is not affected

The Angular si-card component projects [body] into a .content-container that already sets overflow: hidden; border-radius: inherit, so .card > .list never matches projected content. Its header is <si-card-header>, not .card-header. These rules only affect native .card markup.

Examples

Five examples still used .list-group and were migrated. Slot mapping: .list-item-indicator replaces the my-n4 me-5 / ps-4 spacing hacks, .list-item-title carries h5 typography (so si-h5 is dropped), .list-item-primary-action replaces manual action alignment.

Two needed more than a class swap — both had long runs of hand-duplicated markup, partly mangled by prettier into the </li\n> form, which is not reasonably editable by hand:

  • si-fixed-height-layout-side-panel — 16 near-identical <li> blocks → @for over a listItems array
  • si-list-widget-css — 6 blocks → @for over a buildings array

These are template restructures, not scope creep. In si-list-widget-css the rows were all literally labelled "Building B"; they are now B–G. That example is not VRT-covered, so the rename is safe.

si-weather-widget-configurable also had invalid HTML — a <button> as a direct child of <ul> — now wrapped in an <li>.

Docs

cards.md — all three card+list snippets and surrounding prose rewritten; no list-group references remain. list.md — new "List in a card" section. The migration table from the base branch is deliberately untouched.

Verification

  • Dev server compiles the demo app cleanly (covers the @for conversions and both .ts changes)
  • stylelint and prettier clean over all touched files
  • Focus/radius behaviour verified by screenshot across list variants

VRT snapshots are not regenerated in this PR — only si-card/si-card and si-fixed-height-layout-side-panel are snapshot-covered, and both change visually as intended. They need a run in the Docker image.


Documentation.
Examples.
Dashboards Demo.
Playwright report.

Coverage Reports:

Code Coverage

kfenner and others added 2 commits September 8, 2026 15:47
The Bootstrap based list group is superseded by the Element list. Remove the
list group documentation page and mark the styles and Sass variables as
deprecated. The styles, the example and its tests stay in place so existing
applications keep working, the list group is just no longer recommended.

DEPRECATED: The list group styles are deprecated, use the Element list (`.list` / `.list-item`) instead. The list group is only a bordered container and has no notion of the list anatomy, so migrating means restructuring the markup, it is not a plain class rename.

| Deprecated | Replacement |
| --- | --- |
| `.list-group` | `.list`, optionally with `.list-divider`, `.list-filled` or `.list-outline` |
| `.list-group-item` | `.list-item`, wrap the content in slot classes such as `.list-item-title` and `.list-item-description` |
| `.list-group-item-action` | `.list-item-action` on a `<button>` or `<a>` inside the `.list-item` |
| `.list-group-flush` | `.list`, the list has no outer border |
| `.list-group-md`, `.list-group-lg` | No replacement, the height of a list item follows its content |
| `.list-group-horizontal*` | No replacement, use flex or grid utilities |
| `.list-group-numbered` | No replacement, use an ordered list |
| `.list-group-item-secondary`, `.list-group-item-success`, `.list-group-item-warning`, `.list-group-item-caution`, `.list-group-item-danger`, `.list-group-item-info` | No replacement, use background and text utilities, or a list item indicator |
| `.list-header` | No replacement, use a heading element |
| `$list-group-*` Sass variables | No replacement |

Before:

    <ul class="list-group">
      <li class="list-group-item">Item</li>
    </ul>

After:

    <ul class="list">
      <li class="list-item">
        <span class="list-item-title">Item</span>
      </li>
    </ul>

The deprecated styles remain available and there is no removal planned at this point, so applications can keep using them. They will not receive further design updates and may be removed in a future major version. See the list documentation for the full migration guide.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add card styling for the new element `.list` component so it can be used in
place of the deprecated Bootstrap `.list-group`.

The list inherits the rounded corners of the card, so the background of a
hovered, filled or outlined item no longer paints over them. It is also
pushed behind the inset focus ring that a scrollable list gets when it
follows a `.card-header`, which previously left the ring broken as soon as
an item had a background.

Migrate the remaining examples and the card and list documentation to
`.list`.

NOTE: The change is purely additive. Existing `.list-group` markup inside
cards keeps its current styling.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kfenner
kfenner requested review from a team as code owners September 8, 2026 14:27
@kfenner kfenner added this to the 51.0.0 milestone Sep 9, 2026
@kfenner kfenner modified the milestones: 51.0.0, 51.x Sep 9, 2026
Base automatically changed from kaspar-fenner-deprecate-list-group to main September 10, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant