Skip to the content

Svg

Svg renders a vector from a viewBox and an array of paths, with uniform sizing (size, dimensions) and color (fill, fillAll, error). Use it for logos, illustrations and any custom vector outside the icon set.
Typography & Media

When to use

Use when
  • You render a logo, illustration or custom vector from path data.
  • The vector needs a non-square aspect ratio (dimensions.ratio).
  • The vector must turn the danger color in an error state (error).
Avoid when
  • The glyph is in the icon set — use Icon.
  • The image is raster — use Image.

Usage

<Svg viewBox="0 0 100 100" paths={[{ d: 'M50 5 L95 95 L5 95 Z', fill: 'currentColor' }]} size={120} />
  • paths: each item has d and an optional fill. fillAll ignores every path's own fill.
  • fill: color of the inner <g> the paths inherit; defaults to the theme's main color. error paints it danger.
  • Without size or dimensions the vector renders at 1em × 1em.

Sizing

size renders a square and takes precedence over dimensions. dimensions sets width with either an explicit height or a ratio that derives the height from the width.

<Svg {...logoProps} dimensions={{ width: 300, ratio: 16 / 9 }} />
<Svg {...logoProps} dimensions={{ width: '300px', height: '80px' }} />

A ratio with a string width computes the height only for px values; any other unit falls back to height: auto. When the size resolves to a number, width and height are also emitted as native <svg> attributes, so the browser reserves the space before the CSS loads.

Accessibility

  • Pass title for a meaningful graphic: it renders as the SVG <title>.
  • For a decorative graphic, pass aria-hidden="true"; native <svg> attributes are forwarded.

Properties

See also