A Code Component is an advanced type of component. It is similar to a designed Component, except that its primary is written in code.
Creating a Code Component
Creating a new code component
To create a brand new code component, ensure that the code features are enabled in your project by going to the Menu → Code → Always show code.
- Next to the Layers panel, click Code
- To the bottom left, click the blue Create Code File button
- Name your code component and continue
- You're now given a new templated code component, where you can start editing it freely
Your code component should show up in the bottom-left Components panel within the canvas UI, and in the Insert Menu. If it does not show it means there is likely an error in your code component.
Using an instance of a code component
Using Code Components
Framer includes a default set of Code Components that you can find in the Insert Menu. Many of Framer's community Packages also include Code Components.
Using the insert menu to insert a code component
Like Design Components, Code Components can expose Property Controls that change certain properties in the component. If a Code Component has Property Controls, then the Properties Panel will list these inputs in a section with the component's name as its header.
Setting properties on a code component
A Code Component's Property Controls are written in code by the component's author. The controls themselves may be more complex than those found in Design Components, and it's up to the component's author to determine how their values are used.
To learn more about a Code Component's properties, open the Insert Menu and select the component to read its description.
Learn more in our article on using Property Controls with Code Components.