Framer
  • Support
  • Using Framer
Framer
  • Why Framer
  • Teams
  • Learn
    • Tutorials
    • Examples
    • Templates
    • Sessions
    • Speedruns
  • Pricing
  • Blog
  • Updates
  • Support
  • Support
  • Using Framer

Related Articles

  • Deprecated Code Component Width and Height Props
  • Using an external code editor with the desktop app
  • Code Editor
  • What are these common Framer terms?
  • Handoff

Using Code Overrides

Code overrides are JavaScript functions that are executed the moment you render your prototype, which is exactly what happens when you use the Preview to preview your prototype.

They allow you to control your elements and add logic to them, for instance to create simple interactions or more advanced communication between elements.

Overriding the color of a frame

Overriding the color of a frame

You can find a common example below. This code override will reset the color of a Frame to red, regardless of the background you set on the canvas. If the code syntax is new to you, be sure to check out our Framer Guide to React and API Documentation too.

import { Override } from "framer";
export function MakeRed(): Override {
return {
background: "red"
}
}

Setting a code override

You can write code overrides yourself in code and apply them to any Frame or component in your canvas. These functions allow you to override visual properties like opacity and fill, and allow for interactivity and animation.

Framer will provide you with a couple default code overrides that you can directly apply to any frame on your canvas.

Follow these steps to set one of the default code override on a frame:

  1. Draw a frame on the canvas, and draw another frame within it
  2. Select your inner blue frame
  3. On the right-hand properties panel, collapse the Overrides property
  4. Under the File property, select the Examples file
  5. Select the Hover override from the options under the Override property that just showed up

Note: Can’t find the overrides property? Ensure you have code enabled in your project

Now preview your screen and hover the inner frame. Our code override causes the frame to scale down when hovered, which is the effect of our Code Override JavaScript function.

From the Overrides property in the properties panel, you can press the Edit Code button to play around with the code yourself.

Helpful?Was this article helpful?

0

0

Framer

  • Why Framer
  • Teams
  • Pricing
  • Blog
  • Updates
  • Motion

Platforms

  • Web
  • macOSbeta
  • WindowsBeta
  • iOS
  • Android
  • Figma Importing
  • Sketch Importing

Learn

  • Tutorials
  • Examples
  • Templatesnew
  • Sessions
  • Speedruns

Resources

  • Packages
  • API
  • State of Prototyping
  • Desktop Prototyping
  • Prototyping Tool
  • Mockup Tool
  • Wireframing Tool
  • UI/UX Design Tool
  • Graphic Design Tool
  • User Testing

About

  • Loupe
  • Community
  • Company
  • Careers
  • Legal
  • Security

Support

  • Using Framer
  • Accounts
  • Contact

  • Twitter
  • Discord
  • Dribbble

Copyright © 2021 Framer B.V.

  • Security
  • Terms of Service
  • Privacy Statement