Skip to content

feat: add size option for Tag Buttons#2305

Open
Bracciata wants to merge 7 commits intodevelopfrom
feat/button-tag-size-prop
Open

feat: add size option for Tag Buttons#2305
Bracciata wants to merge 7 commits intodevelopfrom
feat/button-tag-size-prop

Conversation

@Bracciata
Copy link
Copy Markdown
Contributor

@Bracciata Bracciata commented Apr 6, 2026

Closes #1957

Summary

  • Adds a size prop ('default' | 'small') to Button (when variant="tag") and TagButton
  • Exports a shared TagSize type from the Tag component
  • Refactors ButtonProps into discriminated union types so size is only valid when variant="tag" (type error otherwise)
  • Adds screenshot tests for the small tag variant for both Button and TagButton
  • Adds documentation and examples for the new size prop in both Button.mdx and TagButton.mdx
  • Fixes autoprefixer converting :user-invalid to :invalid in select.css, which caused required selects to show error styling before user interaction
  • Fixes TextEllipsis[hideTooltip][maxLines=2] test to actually hover and assert no tooltip appears
  • Removes unnecessary dark mode screenshots for TextEllipsis[hideTooltip] tests (component has no dark mode styling)

Test plan

  • Button with variant="tag" and size="small" renders with Tag--small class
  • Button with non-tag variant and size prop produces a TypeScript error
  • TagButton with size="small" passes the size through to the underlying Button
  • Screenshot baselines match expected styling for small tag buttons
  • Required Select fields show no error border before user interaction
  • Required Select fields show error border after user interacts and leaves the field empty
  • TextEllipsis[hideTooltip] tests hover and verify no tooltip is shown

@Bracciata Bracciata requested a review from a team as a code owner April 6, 2026 19:50
Copilot AI review requested due to automatic review settings April 6, 2026 19:50
@Bracciata Bracciata requested a review from a team as a code owner April 6, 2026 19:50
@aws-amplify-us-east-1
Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-2305.d15792l1n26ww3.amplifyapp.com

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 support for rendering Button with variant="tag" at the smaller Tag size, aligning Button’s tag variant behavior with the existing Tag component sizing API (Issue #1957).

Changes:

  • Added a size prop to Button and TagButton and applied Tag--small styling when variant="tag" and size="small".
  • Added unit tests covering size="small" for both Button (tag variant) and TagButton.
  • Added Playwright component screenshot coverage and committed new baseline images for small tag buttons (light/dark).

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/react/src/components/TagButton/index.tsx Plumbs size through TagButton into Button.
packages/react/src/components/TagButton/index.test.tsx Adds a unit test asserting Tag--small is applied.
packages/react/src/components/Button/index.tsx Introduces size prop and toggles Tag--small class for tag variant.
packages/react/src/components/Button/index.test.tsx Adds unit test for small tag button class behavior.
packages/react/src/components/Button/screenshots.e2e.tsx Adds screenshot test for variant="tag" + size="small" states (light/dark).
e2e/screenshots/button-variant-tag-size-small-.png New baseline screenshot (light theme).
e2e/screenshots/dark--button-variant-tag-size-small-.png New baseline screenshot (dark theme).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/react/src/components/Button/index.tsx Outdated
Comment thread packages/react/src/components/TagButton/index.tsx Outdated
Comment thread packages/react/src/components/TagButton/index.tsx
chornonoh-vova
chornonoh-vova previously approved these changes Apr 8, 2026
Copy link
Copy Markdown
Contributor

@frankensteinke frankensteinke left a comment

Choose a reason for hiding this comment

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

I think we'd probably want to add this new prop to the docs for Button and TagButton. Here's what Claude told me that would involve:

  • docs/pages/components/Button.mdx — add a size entry to the ComponentProps at line ~119 (noting it's only valid when variant="tag"), and optionally a new example under the Tag section (~line 81) showing <Button variant="tag" size="small">Small Tag</Button>.
  • docs/pages/components/TagButton.mdx — add a size entry to the ComponentProps array at line 30, and optionally an example alongside the one at line 15.

Both use the shared <ComponentProps> component, so it's just an object append like:

{
  name: 'size',
  type: ['default', 'small'],
  defaultValue: 'default',
  description: '...'
}

Other than that, I just left some minor pieces of feedback. Thanks for contributing!

Comment thread packages/react/src/components/Button/index.tsx
Comment thread packages/react/src/components/Button/screenshots.e2e.tsx Outdated
Comment thread packages/react/src/components/Button/index.tsx Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Weird that these screenshot file names end with a hyphen, but I don't think it's related to anything in this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Maybe we open new issue?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

#2329 done!

Co-authored-by: Tevin Steinke <51126809+frankensteinke@users.noreply.github.com>
Bracciata and others added 2 commits April 17, 2026 11:08
Co-authored-by: Tevin Steinke <51126809+frankensteinke@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@frankensteinke frankensteinke left a comment

Choose a reason for hiding this comment

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

Looks good! Just left some nits about other test .getByText calls that could be changed to .getByRole.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

#2329 done!

Comment on lines +595 to +596
setActive(component.getByText('Active'));
await component.getByText('Focus').focus();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: there are some other .getByText calls that could be updated to .getByRole.

Comment on lines +54 to +56
await component.getByText('Hover').hover();
setActive(component.getByText('Active'));
await component.getByText('Focus').focus();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: more .getByText calls that could be updated to .getByRole.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Button variant="tag" to support the Tag size prop

4 participants