What are Code Overrides?
Code Overrides are small functions that you can use to modify the properties or functionality of any layer in Framer. They are applied to the layer on the canvas, however they are only active in the preview and on your published site.
You might not need Code Overrides
Overrides give you control over the rendering of any Layer in Framer, which in turn means it can be easy to unintentionally break the built in functionality of Framer. Recently, many of the common use cases for Overrides have been replaced by first class features which are optimised by default and less likely to break things.
Animating Text & Layers -> Effects
User Interactions -> Components
Using Dynamic Data -> Fetch
Getting Started
You can create Code Overrides directly inside Framer. Go to the properties panel and create a new file under the Code Overrides section. This will create an Examples file by default where you can see examples of common Code Overrides.
A Basic Override
The is the basic code for any Override, which is essentially a normal React Higher Order Component. The example below modifies the opacity
property of the element it is applied to. Framer uses TypeScript types to detect your overrides, hence the ComponentType
. It is important to always apply the existing props, otherwise you may break the appearance or functionality of your Layer.
Now that you have your new Override, you can apply it to any element on the canvas from the same section in the property panel. If you now preview or publish your site, the element will have an opacity of 0.5.