The ‘viewBox’ attribute in SVG is a fundamental aspect of scalable graphics. It defines the aspect ratio and coordinate system of the SVG canvas, essentially setting up a viewport where the graphic will be drawn. The attribute takes four values: min-x, min-y, width, and height. These values establish the user coordinate system for the viewBox.
Min-x and min-y define the upper left corner of the user coordinate system. Width and height set its dimensions. By manipulating these values, you can control how an SVG scales to fit different sized containers without distorting the image. For instance, if you increase the width while keeping the height constant, the SVG will stretch horizontally but not vertically.
It’s important to note that the viewBox does not affect the actual size of the SVG; it only changes the scale at which it’s displayed. This makes it a powerful tool for creating responsive designs that adapt to various screen sizes and resolutions.