Skip to content

Vanilla JS quick start

  1. Import classes:

    import {
    SvgImage, // Basically implements SVG sprites
    SvgIcon, // Basic SVG icon that uses SvgImage class internally
    } from "vite-awesome-svg-loader/vanilla-integration";
  2. Import images:

    import imageSrc from "@/path/to/image.svg";
  3. Display images:

    new SvgImage(imageSrc, "#my-container"); // Create an image and mount it to the element with "my-container" id.
    new SvgIcon(imageSrc, "#my-container") // Create an icon and mount it to the element with "my-container" id.
    .setSize("24px") // Set 24px size
    .setColor("red") // Set red color
    .setColorTransition("0.3s ease-out"); // Set color transition