Skip to content

Commit d3b48b1

Browse files
Change button to accept string in count (#5725)
Co-authored-by: Josh Black <joshblack@github.com>
1 parent 402bc75 commit d3b48b1

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

.changeset/yellow-trainers-arrive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": minor
3+
---
4+
5+
Allow button count prop to accept a number or a string, to allow for human format, like 3.2k

packages/react/src/Button/Button.features.stories.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ export const TrailingCounter = () => {
6363

6464
export const TrailingCounterWithNoText = () => <Button aria-label="Comments" leadingVisual={CommentIcon} count={3} />
6565

66+
export const TrailingCounterWithHumanFormat = () => (
67+
<Button aria-label="Comments" leadingVisual={CommentIcon} count="3.2k" />
68+
)
69+
6670
export const TrailingCounterAllVariants = () => {
6771
const [count, setCount] = useState(0)
6872
const onClick = () => {

packages/react/src/Button/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export type ButtonProps = {
8686

8787
children?: React.ReactNode
8888

89-
count?: number
89+
count?: number | string
9090
} & ButtonBaseProps
9191

9292
export type IconButtonProps = ButtonA11yProps & {

0 commit comments

Comments
 (0)