Svg Reference

How to render an SVG?

To render a SVG, you can:

Options

Optimization

The svg are optimized

The following svg configuration are applied:

Sizing

Note that the optimization deletes the dimensions (width and height) so that the author or the parent container can control them via

  • tailwind class
  • or attribute.

Example:

  • Via tailwind class
jsx
<span className={"inline-block size-[12em]"}><Svg src="illustration.svg"/></span> // This example is simplistic, but you would need it if the icon name came from an external source
  • Via attribute on the Svg and Icon components
jsx
<Svg src="illustration.svg" width={100}/> <Icon src="icon.svg" size={24}/>

Import

On file import, the SVG are transformed as React Component with SvgR

Example:

  • With the below import statement, OpenAiIcon is a React component optimized
jsx
import OpenAiIcon from "bootstrap-icons/icons/openai.svg" export default function MyIcon() { return <OpenAiIcon width={24}/> }
  • or from a file
jsx
import Arrow from "./arrow-right-circle.svg" export default function svgPage() { return ( <Arrow width={10}/> ) }