Maintain Stroke Width Across Sizes (SVG vector-effect)

Keep SVG stroke width constant while scaling the icon

Ever scaled an SVG and watched the strokes get thicker? The fix is the SVG attribute/CSS property vector-effect="non-scaling-stroke", which keeps the visual stroke width constant even when the icon scales. Modern browsers support it broadly; Internet Explorer does not.

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

Export & prepare your SVG in IconVectors

  1. Open or create your icon:
    • File → Open… (Ctrl+O) or New Icon (Ctrl+N). Work on a square grid (e.g., 24×24).
    • Use currentColor for fill/stroke to theme in code.
    Preparing an SVG icon in IconVectors
    Export a minified SVG via File → Export → Export Minified (Ctrl+M). Then View → Source Code (F3) to add vector-effect if needed.

Apply non‑scaling stroke (inline attribute or CSS)

  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>

    Putting it on <g> applies to all child shapes. Scale the SVG (CSS size or transforms) and the stroke remains visually 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)

For very small exports (e.g., favicon‑sized UI), live strokes may produce fractional alignment and anti‑alias blur. In those cases, outline the stroke to a fill and tweak nodes at whole‑pixel coordinates.

Troubleshooting

Start Making SVG Icons Today with IconVectors

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

Version 1.10 - September 17, 2025