Skip to content

Apply dynamic sizing for octicons#3109

Closed
iansan5653 wants to merge 2 commits into
mainfrom
fix/octicons-sizing
Closed

Apply dynamic sizing for octicons#3109
iansan5653 wants to merge 2 commits into
mainfrom
fix/octicons-sizing

Conversation

@iansan5653

@iansan5653 iansan5653 commented Jul 20, 2026

Copy link
Copy Markdown

What are you trying to accomplish?

Octicons are currently hardcoded to 16px dimensions due to svg element height and width attributes. This prevents them from changing in response to changes in base font size, even when everything else on the page does change, making them look disproportionately small or large if the base font size is overidden to anything other than the default.

What approach did you choose and why?

The simple fix is to apply base-size Primer tokens here, which are rem based and will adjust in response to base font size changes.

What should reviewers focus on?

Not much to see here really, it's pretty straightforward.

Can these changes ship as is?

  • Yes, this PR does not depend on additional changes. 🚢

Copilot AI review requested due to automatic review settings July 20, 2026 19:59
@iansan5653
iansan5653 requested review from a team as code owners July 20, 2026 19:59
@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 05a44fb

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

This PR includes changesets to release 1 package
Name Type
@primer/css Patch

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

Copilot AI left a comment

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.

Pull request overview

This PR aims to make Octicon sizing respond to base font-size changes by overriding their inline width/height attributes with rem-based Primer --base-size-* tokens, improving consistency when root font size is customized.

Changes:

  • Adds CSS sizing rules for .octicon to use --base-size-16 instead of relying on hardcoded SVG attributes.
  • Documents the rationale for overriding inline SVG dimensions.
Show a summary per file
File Description
src/base/octicons.scss Overrides Octicon SVG sizing via CSS variables to support dynamic scaling with base font-size changes.

Review details

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread src/base/octicons.scss
Comment on lines +6 to +11
/* Icon svg elements have `height="16" width="16"` set, hardcoding their dimensions to 16px.
This is useful for sizing in case CSS is missing/not yet loaded, but prevents icons from
responding to changes in font size/zoom. Using base-size applies the same size by default
but allows for dynamic sizing when base font size changes. */
height: var(--base-size-16);
width: var(--base-size-16);
@iansan5653

Copy link
Copy Markdown
Author

Hmm on second thought this is probably the wrong fix; it would work for most icons but would break custom icon size and non-square icons.

@iansan5653 iansan5653 closed this Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants