Card: Add variant="condensed" for compact card layout#7923
Card: Add variant="condensed" for compact card layout#7923dylanatsmith wants to merge 13 commits into
variant="condensed" for compact card layout#7923Conversation
The condensed variant uses tighter spacing, removes the icon background container, and renders a smaller (14px) title. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🦋 Changeset detectedLatest commit: b6780ad The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The icon sits beside the body with an 8px gap, while the heading, description, and metadata stay vertically stacked within the body. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ba66ce3 to
dfecaee
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
I notice some discrepancies with variant naming. Banner uses |
There was a problem hiding this comment.
Pull request overview
This PR adds a new variant="condensed" option to the experimental Card component to support a more compact, list-friendly layout while keeping the existing default presentation unchanged.
Changes:
- Added a
variantprop toCardand surfaced it asdata-varianton the root element. - Implemented condensed-layout styling in
Card.module.css(spacing/layout, icon container behavior, and heading sizing). - Added unit tests and Storybook updates (playground control + a new “Condensed” feature story) plus a changeset for a minor release.
Show a summary per file
| File | Description |
|---|---|
| packages/react/src/Card/Card.tsx | Adds variant prop (defaulting to default) and applies data-variant on the Card root for styling hooks. |
| packages/react/src/Card/Card.module.css | Adds new condensed variant rules affecting layout, spacing, icon container styling, and heading typography. |
| packages/react/src/Card/Card.test.tsx | Adds tests asserting data-variant behavior for default, condensed, and custom-content cards. |
| packages/react/src/Card/Card.stories.tsx | Adds a variant control to the Playground story so condensed can be previewed interactively. |
| packages/react/src/Card/Card.features.stories.tsx | Adds a dedicated “Condensed” feature story example. |
| .changeset/card-condensed-variant.md | Declares a minor release for the new variant="condensed" API. |
Copilot's findings
- Files reviewed: 6/6 changed files
- Comments generated: 5
| &[data-variant='condensed'] { | ||
| display: flex; | ||
| align-items: flex-start; | ||
| gap: var(--stack-gap-condensed); | ||
|
|
||
| /* stylelint-disable-next-line primer/spacing */ | ||
| padding: var(--stack-padding-normal); | ||
| } |
There was a problem hiding this comment.
It's a bit of a misnomer but the normal padding variant applies padding: var(--stack-padding-spacious); and we need the 16px value.
| width: 100%; | ||
| height: auto; | ||
|
|
||
| :where([data-variant='condensed']) & { |
| justify-content: flex-start; | ||
| color: var(--fgColor-muted); | ||
|
|
||
| :where([data-variant='default']) & { |
| display: grid; | ||
| gap: var(--stack-gap-normal); | ||
|
|
||
| :where([data-variant='condensed']) & { |
| color: var(--fgColor-default); | ||
| margin: 0; | ||
|
|
||
| :where([data-variant='condensed']) & { |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Prevents the variant styles from leaking into nested Cards rendered inside a condensed Card. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
I'd lean toward |

Overview
Adds a
variant="condensed"prop to the Card component that provides a compact layout:--stack-gap-condensed/--stack-padding-condensedCard.Icon--text-body-size-medium)Screen.Recording.2026-06-04.at.16.36.16.mov
Changelog
New
Cardnow acceptsvariant="condensed"for a compact card layoutChanged
None
Removed
None
Rollout strategy
Testing & Reviewing
data-variantattribute on both slot-based and custom-content cards:where([data-variant='condensed'])scoped within module classes for zero-specificity stylingMerge checklist