Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/calm-moons-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Button: Fixes the style override issue when size is explicitly specified as medium
8 changes: 8 additions & 0 deletions src/Button/Button.dev.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ export const TestSxProp = () => {
const count = 4
return (
<div style={{display: 'flex', flexDirection: 'row', gap: '1rem'}}>
<Button
size="medium"
sx={{
color: 'deeppink',
}}
>
Medium Pink
</Button>
<Button
size="small"
sx={{
Expand Down
2 changes: 1 addition & 1 deletion src/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function generateCustomSxProp(
providedSx: BetterSystemStyleObject,
) {
// Possible data attributes: data-size, data-block, data-no-visuals
const size = props.size ? `[data-size="${props.size}"]` : ''
const size = props.size && props.size !== 'medium' ? `[data-size="${props.size}"]` : '' // medium is a default size therefore it doesn't have a data attribute that used for styling
const block = props.block ? `[data-block="block"]` : ''
const noVisuals = props.leadingIcon || props.trailingIcon || props.trailingAction ? '' : '[data-no-visuals="true"]'

Expand Down