Skip to content

Conversation

cheshire137
Copy link
Member

@cheshire137 cheshire137 commented Sep 4, 2025

This adds a new count prop to SegmentedControl.Button, modeled after the counter that UnderlineNav.Item has and the count that Button has.

screenshot of Storybook showing With Counter Labels story for SegmentedControl

cc @francinelucca with whom I talked about adding such a prop

Changelog

New

Adds the count prop to SegmentedControl.Button to allow displaying a count label on the right side of the button.

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

The SegmentedControl > Features > With Counter Labels story and SegmentedControl > SegmentedControl.Button > Playground story have been updated to show off the new prop.

Merge checklist

Modeled after the counter in packages/react/src/UnderlineNav/UnderlineNavItem.tsx and how it's rendered in packages/react/src/internal/components/UnderlineTabbedInterface.tsx.
@cheshire137 cheshire137 self-assigned this Sep 4, 2025
@Copilot Copilot AI review requested due to automatic review settings September 4, 2025 14:08
@cheshire137 cheshire137 requested a review from a team as a code owner September 4, 2025 14:08
Copy link

changeset-bot bot commented Sep 4, 2025

🦋 Changeset detected

Latest commit: 175a276

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

This PR includes changesets to release 2 packages
Name Type
@primer/react Minor
@primer/styled-react Major

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 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 Sep 4, 2025
Copy link
Contributor

github-actions bot commented Sep 4, 2025

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

Copy link
Contributor

github-actions bot commented Sep 4, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 89.42 KB (-0.23% 🔽)
packages/react/dist/browser.umd.js 89.63 KB (+0.08% 🔺)

@github-actions github-actions bot requested a deployment to storybook-preview-6721 September 4, 2025 14:16 Abandoned
@primer-integration
Copy link

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

Copy link
Contributor

@Copilot 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 counter prop to SegmentedControl.Button to display count labels on the right side of buttons, following the same pattern as UnderlineNav.Item. This feature enables displaying numeric counts alongside segment labels, useful for scenarios like showing issue counts by label type.

  • Adds counter prop accepting number or string values to SegmentedControlButton
  • Implements counter rendering using the existing CounterLabel component with proper spacing
  • Updates Storybook stories and documentation to showcase the new functionality

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
SegmentedControlButton.tsx Adds counter prop type definition and conditional rendering logic
SegmentedControlButton.stories.tsx Updates Playground story to include counter control
SegmentedControl.module.css Adds CSS styling for counter positioning and alignment
SegmentedControl.features.stories.tsx Adds new "With Counter Labels" feature story
SegmentedControl.docs.json Documents the new counter prop in component metadata

@joshblack joshblack requested a review from langermank September 4, 2025 16:20
Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

Thanks so much for taking the time to submit a PR! Appreciate it a ton 🙏

Just left a couple of comments/suggestions, hope they make sense. I also tagged in @langermank on the design side to review 🔍

@@ -111,6 +111,12 @@
"defaultValue": "",
"description": "Whether the segment is selected. This is used for uncontrolled SegmentedControls to pick one SegmentedControlButton that is selected on the initial render."
},
{
"name": "counter",
Copy link
Member

Choose a reason for hiding this comment

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

Random question for you @langermank, do you know why for Button we call this count. but for UnderlineNav.Item it's counter? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there's any logical reason other than they were probably added at different times and by different people, and it would be nice if they matched 😄

Copy link
Member

Choose a reason for hiding this comment

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

@langermank do you have a preference for count or counter? Mine would be count, I think

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree on "count"!

Copy link
Member Author

Choose a reason for hiding this comment

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

I can update!

cheshire137 and others added 3 commits September 4, 2025 13:57
https: //github.com//pull/6721#discussion_r2322729732
Co-Authored-By: Josh Black <[email protected]>
https: //github.com//pull/6721#discussion_r2322722420
Co-Authored-By: Josh Black <[email protected]>
Copy link
Contributor

@langermank langermank left a comment

Choose a reason for hiding this comment

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

Some squishyness happening, I haven't taken a closer look to find a solution but happy to if needed!

Squishy

@cheshire137 if you wouldn't mind, could you add the new feature story you added to this file so it will create a VRT snapshot? No worries if not, we can add it in a followup!

@@ -111,6 +111,12 @@
"defaultValue": "",
"description": "Whether the segment is selected. This is used for uncontrolled SegmentedControls to pick one SegmentedControlButton that is selected on the initial render."
},
{
"name": "counter",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there's any logical reason other than they were probably added at different times and by different people, and it would be nice if they matched 😄

@github-actions github-actions bot temporarily deployed to storybook-preview-6721 September 8, 2025 14:04 Inactive
@joshblack joshblack added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 8, 2025
@joshblack joshblack requested a review from langermank September 8, 2025 16:44
@primer primer bot requested a review from a team as a code owner September 8, 2025 16:53
@github-actions github-actions bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 8, 2025
cheshire137 and others added 2 commits September 9, 2025 10:25
https: //github.com//pull/6721/files#r2330801548
Co-Authored-By: Katie Langerman <[email protected]>
Co-Authored-By: Josh Black <[email protected]>
@cheshire137 cheshire137 changed the title Add counter to SegmentedControlButton Add count to SegmentedControlButton Sep 9, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-6721 September 9, 2025 15:38 Inactive
Copy link
Contributor

@langermank langermank left a comment

Choose a reason for hiding this comment

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

I'm going to open a followup PR to fix the overflow problem 👍

@cheshire137
Copy link
Member Author

Oh heck, I forgot all about that comment, sorry about that and thank you @langermank! If you'd prefer, we could get it fixed in this branch.

@langermank
Copy link
Contributor

@cheshire137 no worries at all. I dug into it and its not really tied to the count addition, it's pre-existing. So I think it's probably better to fix it in a separate PR anyway!

@cheshire137
Copy link
Member Author

I'll get conflicts resolved.

@langermank langermank added this pull request to the merge queue Sep 15, 2025
Merged via the queue into main with commit d6378c2 Sep 15, 2025
42 of 43 checks passed
@langermank langermank deleted the seg-cont-count branch September 15, 2025 16:26
@primer primer bot mentioned this pull request Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

3 participants