Override Examples
There are a few common use cases for Overrides, below you’ll find examples on how to implement them. The code will vary slightly in your specific usage.
Custom IDs and Attributes
You can also use overrides to add custom IDs and data attributes to elements. For example if you want to add a data-xx
or id
tag to elements.
We don’t recommend to override core attributes like class
or className
as Framer relies on those and it will result in breaking styling. If you must, we recommend concatenating with the existing class
value.
Click Tracking
A popular use-case for Overrides is click tracking, you can do this quite simply. This depends on your tracking setup, but generally includes a call to a tracking API on click. Another way to do tracking is to add a data attribute to the layer (see above example) and adding a head script to your page in the Custom Code that performs the tracking.
Text Content
Sometimes you want to dynamically replace text contents for any text element. You can use the text
property to pass in any text content. The preview or published site will now show “Hello World”. However in many cases you can use Fetch for this instead.