Skip to content

fix(preset-icons): add custom icon handling without unit - #5279

Merged
zyyv merged 1 commit into
mainfrom
icon-unit
Aug 26, 2026
Merged

zyyv merged 1 commit into
mainfrom
icon-unit

Conversation

@zyyv

@zyyv zyyv commented Aug 26, 2026

Copy link
Copy Markdown
Member

close #4084, close #4060, close #4089

When iconify/utils parses SVG tags, if the width and height attributes exist in the tag, it will automatically add them to the props without performing any operations on the values.

<svg width='32' height='32' xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"></svg>

Will parsed:

{
  width: 32,
  height: 32,
}

If neither the width nor the height is present, iconify/utils will automatically parse or calculate the aspect ratio and add it using the default unit (em).

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"></svg>

Will parsed:

{
  width: 1em,
  height: 1em,
}

However, for UnoCSS output CSS styles, sizes without units are not considered valid.

This PR will handle this uniformly in the final parsed results, and will correct any invalid units.

@zyyv
zyyv requested a review from antfu as a code owner August 26, 2026 07:32
@netlify

netlify Bot commented Aug 26, 2026

Copy link
Copy Markdown

Deploy Preview for unocss ready!

Name Link
🔨 Latest commit ac4cc6e
🔍 Latest deploy log https://app.netlify.com/projects/unocss/deploys/6a8e96864834840007d223c9
😎 Deploy Preview https://deploy-preview-5279--unocss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Aug 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: ac4cc6e

@zyyv
zyyv merged commit 733e1bf into main Aug 26, 2026
12 checks passed
@zyyv
zyyv deleted the icon-unit branch August 26, 2026 07:37
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.

bug(presetIcons): custom SVG icon loads invalid width and height

1 participant

Sponsor
SponsoredKunjungi sekarang
Promo