Skip to content

Card: Add borderRadius prop#7763

Open
liuliu-dev wants to merge 5 commits intomainfrom
liuliu/card-border-radius
Open

Card: Add borderRadius prop#7763
liuliu-dev wants to merge 5 commits intomainfrom
liuliu/card-border-radius

Conversation

@liuliu-dev
Copy link
Copy Markdown
Contributor

@liuliu-dev liuliu-dev commented Apr 16, 2026

Part of https://github.com/github/primer/issues/6561

Adds a borderRadius prop to the experimental Card component with 'medium' and 'large' options (defaults to 'large').

Changelog

New

Changed

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 16, 2026

🦋 Changeset detected

Latest commit: 21f2ce5

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

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Apr 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ 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.

@github-actions github-actions bot temporarily deployed to storybook-preview-7763 April 16, 2026 16:40 Inactive
@liuliu-dev liuliu-dev added the Canary Release Apply this label when you want CI to create a canary release of the current PR label Apr 16, 2026
@liuliu-dev liuliu-dev marked this pull request as ready for review April 16, 2026 22:04
@liuliu-dev liuliu-dev requested a review from a team as a code owner April 16, 2026 22:04
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

Adds a borderRadius prop to the experimental Card component to let consumers choose between 'medium' and 'large' corner rounding (defaulting to 'large'), aligning Card styling with selectable radius tokens.

Changes:

  • Introduces borderRadius?: 'medium' | 'large' on Card, defaulting to 'large', and exposes it via data-border-radius.
  • Updates Card CSS to apply radius based on data-border-radius rather than a fixed value.
  • Updates Storybook playground controls and generated docs metadata to include the new prop; adds a changeset.
Show a summary per file
File Description
packages/react/src/Card/Card.tsx Adds borderRadius prop with default and forwards it as data-border-radius on the root element.
packages/react/src/Card/Card.stories.tsx Extends the Playground story args/controls to include borderRadius.
packages/react/src/Card/Card.module.css Applies border-radius via [data-border-radius] selectors for 'medium'/'large'.
packages/react/src/Card/Card.docs.json Documents the new borderRadius prop for the docs pipeline.
.changeset/swift-grapes-warn.md Announces the API addition in release notes (currently marked as a patch).

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 2

Comment on lines +118 to +123
<div
ref={ref}
className={clsx(classes.Card, className)}
data-padding={padding}
data-border-radius={borderRadius}
{...rest}
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

New borderRadius behavior is not covered by unit tests. Since this component already asserts data-padding defaults/overrides in Card.test.tsx, please add similar assertions for data-border-radius (default 'large' and when borderRadius="medium").

Copilot uses AI. Check for mistakes.
Comment thread .changeset/swift-grapes-warn.md Outdated
@@ -0,0 +1,5 @@
---
'@primer/react': patch
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

This changeset marks the release as patch, but the versioning guide indicates that adding a prop is a minor bump ("Props → A prop is added → minor"). Please update the changeset to minor (or document why this is an exception).

Suggested change
'@primer/react': patch
'@primer/react': minor

Copilot uses AI. Check for mistakes.
@lukasoppermann
Copy link
Copy Markdown
Contributor

lukasoppermann commented Apr 17, 2026

@liuliu-dev somehow borderRadius is not loaded. Could it be that we are not loading primer.css and also not radius.css in storybook?

@lukasoppermann
Copy link
Copy Markdown
Contributor

I also don't understand why the car has those outdated fallback values:
CleanShot 2026-04-17 at 08 29 21@2x

They don't seem to be in your css module. 😕

@github-actions
Copy link
Copy Markdown
Contributor

Uh oh! @lukasoppermann, at least one image you shared is missing helpful alt text. Check #7763 (comment) to fix the following violations:

  • Images should have meaningful alternative text (alt text) at line 2

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

🤖 Beep boop! This comment was added automatically by github/accessibility-alt-text-bot.

@github-actions github-actions bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Apr 17, 2026
@primer-integration
Copy link
Copy Markdown

👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/18841

@primer-integration
Copy link
Copy Markdown

Integration test results from github/github-ui:

Passed  CI   Passed
Passed  VRT   Passed
Passed  Projects   Passed

All checks passed!

@primer-integration
Copy link
Copy Markdown

Integration test results from github/github-ui:

Running  CI   Running
Passed  VRT   Passed
Passed  Projects   Passed

@liuliu-dev
Copy link
Copy Markdown
Contributor Author

@lukasoppermann good catch! I imported radius.css in storybook, the radius should be loading now.

I asked copilot about the fallbacks:

Those fallback values (var(--color-canvas-default), var(--color-shadow-small)) aren't in the Card CSS,
they're added automatically by the postcss-preset-primer PostCSS plugin during build.
It injects legacy token fallbacks for backwards compatibility. Not something specific to the Card component.

@liuliu-dev liuliu-dev removed the request for review from hectahertz April 20, 2026 18:43
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants