Learn How to Add SVGs to Your Webflow Project With Webflow's Dom Element

Published on
October 18, 2023

How to Add SVGs to Your Webflow Project

In this tutorial, we will learn how to add SVGs to our Webflow project using Webflow's Dom element. This feature allows us to style individual paths within our SVG and even animate them.

  1. Copy the SVG code and head over to Webflow.

First, let’s start by copying the SVG code that we want to add to our Webflow project. Once we have the code, we can head over to Webflow.

  1. Launch the Webflow unsplash app and add an image to the page.

By launching the unsplash app in Webflow, we gain access to the Dom element. We will add an image to the page, which provides us with the ability to use Webflow's Dom element.

  1. Convert the image to an SVG element.

Remove the class from the image and remove any attributes that were attached to it. Change the tag type to be SVG.

  1. Set the viewbox attribute.

The SVG code typically includes a viewbox attribute that sets the ratio on the SVG. We can create an attribute of viewbox on the SVG element and set its value.

  1. Create path elements within the SVG.

Inside the SVG element, create path elements that correspond to the paths in the SVG code. Each path element will have an attribute of “D” that specifies its value.

  1. Set the fill color for the paths.

To set the color for the paths, add an attribute of fill to the SVG element. Set the value to "currentColor" to link it to the section font color. If it was an outlined SVG, stroke could be used instead of fill.

  1. Customize individual paths.

Individual paths within the SVG can be customized by changing their fill color to match a specific brand variable, for example.

  1. Style the SVG element.

Add a class to the SVG element and specify its width and bottom margin to fit the design layout.

  1. Link the SVG to component fields.

If the SVG is within a component, we may want to link its attributes to component fields to allow for flexibility and dynamic changes. For example, we can link the viewbox and each path to relevant component fields.

  1. Copy the SVG for different components.

To use the SVG in different components, we can just copy the SVG and change the specific attributes that need to be different, such as the viewbox and path values.

  1. Link the SVG styles to component fields.

In addition to linking the viewbox and paths, we can also link the inline styles, such as the fill color, to component fields for further customization in different instances of the component.

Overall, these steps demonstrate how to add SVGs to a Webflow project using Webflow's Dom element. This functionality provides great flexibility and control over styling and animating SVGs directly within the Webflow platform.