Skip to content

Card: Add variant="condensed" for compact card layout#7923

Open
dylanatsmith wants to merge 13 commits into
mainfrom
dylanatsmith/dats-card-compact
Open

Card: Add variant="condensed" for compact card layout#7923
dylanatsmith wants to merge 13 commits into
mainfrom
dylanatsmith/dats-card-compact

Conversation

@dylanatsmith
Copy link
Copy Markdown
Member

@dylanatsmith dylanatsmith commented Jun 4, 2026

Overview

Adds a variant="condensed" prop to the Card component that provides a compact layout:

  • Condensed spacing — tighter gap and padding using --stack-gap-condensed / --stack-padding-condensed
  • No icon background — removes the background container and fixed dimensions from Card.Icon
  • Smaller title — heading font-size reduced to 14px (--text-body-size-medium)
Screen.Recording.2026-06-04.at.16.36.16.mov

Changelog

New

  • Card now accepts variant="condensed" for a compact card layout

Changed

None

Removed

None

Rollout strategy

  • Patch release
  • Minor release
  • Major release
  • None

Testing & Reviewing

  • Unit tests added for the data-variant attribute on both slot-based and custom-content cards
  • CSS uses :where([data-variant='condensed']) scoped within module classes for zero-specificity styling

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Storybook)
  • Changes are SSR compatible
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

dylanatsmith and others added 2 commits June 4, 2026 15:40
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>
@github-actions github-actions Bot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Jun 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

To publish a canary release for integration testing, apply the Canary Release label to this PR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 4, 2026

🦋 Changeset detected

Latest commit: b6780ad

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

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>
@github-actions github-actions Bot requested a deployment to storybook-preview-7923 June 4, 2026 14:49 Abandoned
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot requested a deployment to storybook-preview-7923 June 4, 2026 14:57 Abandoned
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>
@github-actions github-actions Bot requested a deployment to storybook-preview-7923 June 4, 2026 15:03 Abandoned
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dylanatsmith
Copy link
Copy Markdown
Member Author

I notice some discrepancies with variant naming. Banner uses layout="compact" so we might want to implement that way instead? I have no preference, happy to follow the system convention.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 variant prop to Card and surfaced it as data-variant on 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

Comment thread packages/react/src/Card/Card.module.css Outdated
Comment on lines +33 to +40
&[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);
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit of a misnomer but the normal padding variant applies padding: var(--stack-padding-spacious); and we need the 16px value.

Comment thread packages/react/src/Card/Card.module.css Outdated
width: 100%;
height: auto;

:where([data-variant='condensed']) & {
Comment thread packages/react/src/Card/Card.module.css Outdated
justify-content: flex-start;
color: var(--fgColor-muted);

:where([data-variant='default']) & {
Comment thread packages/react/src/Card/Card.module.css Outdated
display: grid;
gap: var(--stack-gap-normal);

:where([data-variant='condensed']) & {
Comment thread packages/react/src/Card/Card.module.css Outdated
color: var(--fgColor-default);
margin: 0;

:where([data-variant='condensed']) & {
dylanatsmith and others added 2 commits June 4, 2026 16:52
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>
@github-actions github-actions Bot requested a deployment to storybook-preview-7923 June 4, 2026 16:01 Abandoned
@github-actions github-actions Bot temporarily deployed to storybook-preview-7923 June 4, 2026 16:11 Inactive
@liuliu-dev liuliu-dev self-requested a review June 4, 2026 16:11
Copy link
Copy Markdown
Member

@jonrohan jonrohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

Very Nice

@jonrohan jonrohan added the Canary Release Apply this label when you want CI to create a canary release of the current PR label Jun 4, 2026
@primer primer deleted a comment from primer-integration Bot Jun 4, 2026
@liuliu-dev
Copy link
Copy Markdown
Contributor

I notice some discrepancies with variant naming. Banner uses layout="compact" so we might want to implement that way instead? I have no preference, happy to follow the system convention.

I'd lean toward layout="compact", it matches Banner/SelectPanel and describes the change more accurately.

@liuliu-dev liuliu-dev added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jun 4, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-7923 June 4, 2026 17:40 Inactive
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jun 4, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-7923 June 4, 2026 17:55 Inactive
Copy link
Copy Markdown
Contributor

@liuliu-dev liuliu-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@francinelucca francinelucca removed their request for review June 4, 2026 19:58
@dylanatsmith dylanatsmith enabled auto-merge June 5, 2026 11:21
@primer primer Bot disabled auto-merge June 5, 2026 17:16
@primer primer Bot enabled auto-merge June 5, 2026 17:17
@primer primer Bot disabled auto-merge June 5, 2026 17:18
@primer primer Bot enabled auto-merge June 5, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Canary Release Apply this label when you want CI to create a canary release of the current PR integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants