svgweb-applicationsviewbox

What is the optimal SVG viewBox size for web applications?


Background

While creating SVG icons for my web application, I noted that the two most common viewBox sizes others seem to design around are 0 0 20 20 (for solid icons) and 0 0 24 24 (for outline icons).

Ideally, I would like to like to standardize on one viewBox size for my app and am trying to understand any best practices that already exist.

Is there a currently or generally accepted 'best practice' sizing for the viewBox when creating SVGs for web applications?


Solution

  • There is no best practice; the viewBox is your definition, the DOM element size will be the same

    example: It is up to you if you draw in viewBox="0 0 5 5" or viewBox="0 0 25 25" 'accuracy'