Skip to content

Commit 071f0e0

Browse files
authored
fix: keep SVG viewBox so icons scale instead of clipping (#715)
1 parent 87bc673 commit 071f0e0

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

.changeset/keep-svg-viewbox.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@aragon/gov-ui-kit": patch
3+
---
4+
5+
Keep the `viewBox` on bundled SVG icons so they scale correctly when rendered below their intrinsic 16px size (e.g. `size-3` in small buttons) instead of being clipped.

rollup.config.mjs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,19 @@ export default [
5252
],
5353
}),
5454
images({ include: ['**/*.png', '**/*.jpg'] }),
55-
svgr(),
55+
svgr({
56+
// Keep the viewBox so icons scale instead of getting clipped when
57+
// rendered at a size other than their intrinsic 16px (e.g. size-3 in
58+
// small buttons). SVGO's preset-default removes it by default.
59+
svgoConfig: {
60+
plugins: [
61+
{
62+
name: 'preset-default',
63+
params: { overrides: { removeViewBox: false } },
64+
},
65+
],
66+
},
67+
}),
5668
terser(),
5769
],
5870
},

0 commit comments

Comments
 (0)