Commit 3b277b3
committed
fix: keep SVG viewBox so icons scale instead of clipping
SVGR (via @svgr/rollup) runs SVGO's preset-default, which strips the viewBox
from icons that carry width/height attributes. Without a viewBox, rendering an
icon below its intrinsic 16px (e.g. size-3 in small buttons) crops the drawing
to the smaller viewport instead of scaling it. Edge-to-edge glyphs like PEN
visibly clip.
Override removeViewBox in the rollup build so the viewBox is preserved and
icons scale at any size.
Note: Storybook uses vite-plugin-svgr, which does not run SVGO by default
(only the jsx plugin), so it already preserves the viewBox and needs no change.1 parent 87bc673 commit 3b277b3
2 files changed
Lines changed: 18 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
56 | 68 | | |
57 | 69 | | |
58 | 70 | | |
| |||
0 commit comments