Non-Scaling Stroke for SVG Icons

By the Axialis Engineering team ·

Non-Scaling Stroke for SVG Icons

Scale a stroked SVG icon up and its outline gets visibly heavier, because the browser multiplies stroke-width by the same factor as the geometry. Set vector-effect="non-scaling-stroke" on the path or its group and the stroke is rendered in screen pixels after the transform, so a 2px line stays 2px at 16px, 24px, or 96px.

This is a presentation attribute defined in SVG 2, also settable as the CSS property vector-effect. Chrome, Edge, Firefox, and Safari have shipped it for years; Internet Explorer never supported it, and a few PDF/print pipelines ignore it (see the trade-offs below).

Pros and cons of vector-effect="non-scaling-stroke"

Prepare your SVG in IconVectors

  1. Open or create your icon:
    • File -> Open... (Ctrl+O) or New Icon (Ctrl+N), working on a square grid such as 24x24 so stroke widths land on whole-pixel coordinates.
    • Set fill and stroke to currentColor so the icon inherits its color from CSS once it ships.
    A stroke-built camera icon open on the IconVectors canvas at 600% zoom with the live pixel and vector preview panel
    Export a minified SVG via File -> Export -> Export Minified (Ctrl+M), then open View -> Source Code (F3) to add the vector-effect attribute.

Apply non-scaling stroke (inline attribute or CSS)

You can set the effect two ways. Use the inline attribute when you want it baked into the icon file; use SVG-scoped CSS when you would rather toggle it with a class.

  1. Inline attribute (path or group)
    <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
      <g vector-effect="non-scaling-stroke"
         stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round">
        <path d="M4 12 9 17 20 6"/>
      </g>
    </svg>

    On the <g> it covers every child path. Size the SVG with CSS (width/height) or a transform: scale() and the rendered stroke stays at 2px.

  2. SVG-scoped CSS
    <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
      <style>
        .ns { vector-effect: non-scaling-stroke; }
      </style>
      <path class="ns" d="M4 12 9 17 20 6"
            stroke="currentColor" stroke-width="2" fill="none"/>
    </svg>

When to convert strokes to paths (tiny sizes)

Below about 16x16, a live stroke can sit between device pixels and blur at the caps and joins even with non-scaling-stroke on. When you need that crispness, outline the stroke to a filled shape and place its nodes on whole-pixel coordinates.

Troubleshooting

Related guides

Start Making SVG Icons Today with IconVectors

Download the fully-functional 30‑Day Free Trial and unlock your icon design workflow.

Version 1.70 for Windows and macOS