Code Components with Basic CSS
Add to favorites
Create Basic Code Components with CSS in Framer
Play video

Master No-Code Web Design with Framer
1
Complete Beginner-Friendly Framer Course
7:09
2
Create Your First Layout in Framer
13:47
3
Generate Layout with AI in Framer
7:26
4
Basic Layout and Interactive Elements
15:28
5
Text and Vector Animations
18:14
6
UI Design from Figma to Framer
13:16
7
Adaptive Layout with Stacks and Constraints in Framer
12:03
8
Responsive Layout with Breakpoints and Min Max
13:55
9
Button Components, Variables and Variants
11:01
10
Appear, Hover, Press, Loop and Drag Effects
11:17
11
Scroll Speed and Transform in Framer
15:15
12
Scroll Variants and Stick Element
12:13
13
Copy Components, Custom Cursors and 3D Embeds
10:00
14
Grid and Bento Layout
11:26
15
Icon Animation, Menu and Overlay
11:00
16
Code Components with Basic CSS
12:11
17
Property Controls in Framer
9:23
18
Code Overrides in Framer
13:23
19
CMS Collection Page and Detail
14:22
20
Search and Navigation
14:25
Why Code Component
In Framer, code components are supercharged bits that let you bring your designs to life with real, interactive elements. They're built using React, which means you're essentially using cutting-edge web tech to create or customize interactive UI components. Best practices? Keep it clean and reusable. Think modularly, so you can tweak without a complete redo, and always, always comment your code for clarity.
To implement background blur on hexagon shapes in Framer, which are currently vector graphics lacking standard frame styling options, let's consider a few things:
- Recognize the limitation: Vector graphics in Framer don't support background blur due to their nature, missing out on typical layout or frame styling options.
- Opt for CSS: To achieve the desired effect and add uniqueness to your design, turning to CSS is the recommended approach. CSS allows for more flexibility and customization, especially for complex shapes.
- Learn to create a code component: Framer supports the creation of code components, enabling you to incorporate custom CSS. This method allows for the implementation of background blur on hexagon shapes by utilizing CSS's advanced styling capabilities.
Create Code Component
- Cmd + Shift + K to create a code component. Name it Hexagon.
- This will open in the Assets section and show the code file Hexagon.tsx.
Default Code
When diving into a React component, it helps to break it down into manageable chunks. Here's a quick guide on making sense of it all:
- Import Essentials: Kick off with bringing in the components you need.
- Adjust Sizes: Make sure it fits well on any screen with size settings.
- Structure It: Understand the layout and how your component is built.
- Styling: Swap in your CSS for a personalized look, skipping the default styles.
- Clean Up: Get rid of extra bits like unnecessary code, comments, and
div
styles to keep it neat.
Basic Code Component with CSS
Starting from scratch with code components, especially in React, introduces a blend of design and functionality. Here's a simplified breakdown:
- Using Styled Components: We're kicking things off with Styled Components, a library that marries the power of CSS with the flexibility of Sass for more dynamic styling capabilities. Importing
styled
from 'styled-components' is step one, setting the stage for real CSS coding with extra features like nesting. - Creating the Component: Next up, we're crafting our actual component. By declaring a constant (let's call it
Hexagon
), we're essentially defining a new piece that we can style and manipulate as we please. - Styling with Sass: Inside this component, we're leveraging Styled Components to declare styles in a Sass-like manner, allowing for a more organized and powerful way to handle CSS. For instance, creating a
div
styled as aHexagon
serves as our canvas, much like a frame in Figma. - Translating Design to Code: The magic happens when we start to translate design directly from tools like Figma into our component. By extracting CSS properties from a design element (like a hexagon shape) in Figma, we directly apply these styles to our component, ensuring our code mirrors our design vision.
- Bringing it to Life: With just a few lines of code—defining the component, setting its properties, styling it, and rendering it—we've crafted a basic yet functional code component. This approach not only simplifies the development process but also bridges the gap between design and code seamlessly.
import styled from "styled-components"
export default function Hexagon() {
const Component = styled.div`
width: 141px;
height: 148px;
background: red;
`
return <Component />
}
Hexagon CSS
To style a hexagon in React using Styled Components, follow these steps after setting up your basic component structure:
Copy Layout from DevMode: Start by examining a hexagon in your design tool (like Figma) and enter DevMode to access the CSS code. Copy the layout properties, which usually include width and height, to establish the size of your hexagon component.
Apply Basic Style: Replace the initial basic component styling with the layout properties you've copied. This step ensures your component matches the design specifications in terms of size.
Add Styling Details:
- Backdrop Filter: Implement a backdrop filter for a background blur effect, enhancing the visual depth of your component.
- Box Shadow: Use box shadow for an inner glow effect, adding a subtle highlight inside your hexagon.
- Stroke (Outline): Define the stroke for your hexagon, creating a clear outline or border around it.
- Fill Color: Set a low-opacity white fill color for the base appearance of your hexagon, making it visually coherent with your design.
import styled from "styled-components"
export default function Hexagon() {
const Component = styled.div`
width: 175px;
height: 151px;
flex-shrink: 0;
fill: rgba(255, 255, 255, 0.04);
stroke-width: 1px;
stroke: rgba(225, 246, 255, 0.30);
box-shadow: 0px 30px 30px 0px rgba(255, 255, 255, 0.05) inset;
backdrop-filter: blur(10px);
`
return <Component />
}
Masking with Clip-Path
To achieve a hexagon shape in your React component with Styled Components, leveraging the clip-path
CSS property is a creative and powerful solution. This property allows you to mask your component into a specific shape, in this case, a hexagon. Here’s a quick guide on how to do it:
- Find the SVG Shape: Look for the hexagon shape in SVG format. SVGs define shapes with a
path
element, where thed
attribute contains a series of coordinates and commands that outline the shape. - Copy Path Coordinates: Inside the SVG code, locate the
path
element and copy the entire string of coordinates found in thed
attribute. These coordinates precisely define the hexagon's outline. - Apply Clip-Path: In your styled component, after setting up any foundational styles like the backdrop filter, introduce the
clip-path
property. Use it as follows:clip-path: path('your_copied_coordinates_here');
. Replace'your_copied_coordinates_here'
with the string of SVG path coordinates you copied. This clips your component's visible area into a hexagon shape, masking anything outside this path. - Finalize Styling: Once the
clip-path
is applied, your component now visually represents a hexagon. You can then proceed to apply additional styles as needed, such as background color, shadows, or borders, to enhance the hexagon's appearance.
The use of clip-path
with SVG path data is a testament to the versatility and power of CSS, enabling you to craft intricate shapes and visual effects that go beyond basic rectangular or circular designs.
clip-path: path('M171.095 70.4863C172.892 73.5872 172.892 77.4128 171.095 80.5137L133.139 146.014C131.351 149.1 128.054 151 124.487 151H48.5129C44.9459 151 41.649 149.1 39.8606 146.014L1.90532 80.5137C0.108386 77.4128 0.108386 73.5872 1.90532 70.4863L39.8606 4.98625C41.649 1.89999 44.9459 0 48.5129 0H124.487C128.054 0 131.351 1.89999 133.139 4.98625L171.095 70.4863Z')
Using the Code Component
To incorporate Code Components into your Framer designs, utilize Quick Actions by pressing CMD + K, or simply drag and drop them from the Assets Library. This approach enables you to go beyond the standard framework elements, offering more versatility in your design process. By using Code Components, you unlock a wider array of options, allowing for more customized and dynamic design solutions.
- In Content → Hexagons → Hexagon for Uber, Insert Hexagon from the Quick Actions (Cmd + K).
- Place the Hexagon code component underneath the existing Hexagon graphic.
- That's it! Now you are using real CSS instead of a strictly Framer element.
Import From Figma
We're planning to bring the Customers page design over from Figma into Framer and give it a bit of a makeover. The idea is to tweak the layout so it looks great on any device, making it super flexible and custom-tailored.
- Open Figma and select the Customers section.
- Copy to HTML for Framer.
- Open Framer and create a new page named "customers."
- In Framer, set the page layout to Desktop with dimensions 1400x1440 pixels.
- Paste the copied section from Figma onto the new page.
- Set the background to Position Absolute and center.
- Set the background's z-index to 0.
- Locate and adjust any missing elements, such as hexagons, to Position Absolute and center them.
Adaptive Layout
To make your design responsive across devices, you're working on adding breakpoints for tablet and phone. Here’s a simplified overview of the process:
- Add breakpoints for tablet and phone views.
- Select Customers and set to Width 100%, Distribute Center.
- Adjust padding for Customers to 100, 40, 100, 40. Set 30 (L, R) for Tablet and 20 (L, R) for Mobile.
- Lock Background to allow for easier selection.
- Select Content and set to width Fill and Layout align center. Set Max width to 652.
- Change Title and Testimonial frames width to Fill for flexibility across devices. Same for Testimonial text.
- In Phone view, set Title to vertical alignment and adjust gap to 20.
- Set Desktop height to Fit.
Conclusion
In wrapping up our exploration of code components within Framer, we've embarked on a journey through the foundational aspects of utilizing CSS to enhance our designs. From the basics of crafting a hexagon shape to implementing a sophisticated background blur, we've uncovered the potential of CSS to transform our components into visually stunning elements.
Here's a quick recap of the key takeaways:
- Styled Components: We kicked off with Styled Components to inject real CSS into our React components, allowing for dynamic styling and the use of advanced CSS features like Sass for nesting and more.
- Clip-Path for Shapes: By leveraging the
clip-path
CSS property, we learned how to mask components into complex shapes, such as hexagons, using SVG path data. This trick enables us to create designs that are not natively supported by Framer, showcasing the versatility of CSS. - Background Blur: The backdrop filter property came into play for adding depth and texture to our components, illustrating how subtle CSS effects can significantly enhance the user experience.
- Integration with Design Tools: We saw the power of integrating designs from tools like Figma, demonstrating that with basic CSS knowledge, you can bring sophisticated design concepts into your Framer projects seamlessly.
This exploration underscores the limitless creativity CSS offers to developers and designers alike, enabling us to bridge the gap between design and development. By harnessing these techniques, we can elevate our Framer projects, creating engaging, interactive, and visually appealing components that stand out. Whether you're a seasoned developer or a designer venturing into the world of code, these tips and tricks serve as a foundation for experimenting with and mastering code components in Framer.
Templates and source code
Download source files
Download the videos and assets to refer and learn offline without interuption.
Design template
Source code for all sections
Video files, ePub and subtitles
Assets
Videos
1
Complete Beginner-Friendly Framer Course
4-hour free course to create beautiful, modern interfaces. Dark mode and glass designs, from Figma to Framer, using stack and grid layouts
7:09
2
Create Your First Layout in Framer
Master the basics of layout creation in Framer with this comprehensive step-by-step guide for beginners. Start building your designs today!
13:47
3
Generate Layout with AI in Framer
Create stunning websites with ease using Framer's AI-powered layout generator
7:26
4
Basic Layout and Interactive Elements
Learn how to create a user-friendly layout with interactive elements to enhance the user experience and engagement on your website or app
15:28
5
Text and Vector Animations
Transform your content with captivating text and vector animations
18:14
6
UI Design from Figma to Framer
Mastering the art of transitioning your UI design projects seamlessly from Figma to Framer with expert tips and techniques
13:16
7
Adaptive Layout with Stacks and Constraints in Framer
Create responsive designs easily using stacks and constraints in Framer. Perfect for adaptive layouts for web and mobile projects
12:03
8
Responsive Layout with Breakpoints and Min Max
Create a user-friendly website with responsive design, incorporating breakpoints and min-max values to ensure optimal display on all devices
13:55
9
Button Components, Variables and Variants
Explore different button components, variables, and variants to enhance the functionality and aesthetics of your projects
11:01
10
Appear, Hover, Press, Loop and Drag Effects
Mastering Framer Effects: Create interactive sites with Appear, Hover, Press, Loop, Drag Effects
11:17
11
Scroll Speed and Transform in Framer
Learn how to create dynamic Framer sites with advanced features for interactive designs
15:15
12
Scroll Variants and Stick Element
Enhance User Navigation with Sticky Elements and Scroll Variants in Framer
12:13
13
Copy Components, Custom Cursors and 3D Embeds
Learn how to incorporate Framer's interactive elements into your designs
10:00
14
Grid and Bento Layout
Enhancing Your Designs with Grid and Bento Layouts in Framer
11:26
15
Icon Animation, Menu and Overlay
Web Design User Experience with Icon Animation, Menus, and Overlays in Framer
11:00
16
Code Components with Basic CSS
Create Basic Code Components with CSS in Framer
12:11
17
Property Controls in Framer
Mastering Property Controls for Interactive Framer Components
9:23
18
Code Overrides in Framer
Enhancing Your Framer Elements with Code Overrides
13:23
19
CMS Collection Page and Detail
Integrating Figma Designs with Framer and CMS
14:22
20
Search and Navigation
Enhancing User Experience: Search, Navigation, and Footer Integration
14:25
Meet the instructor
We all try to be consistent with our way of teaching step-by-step, providing source files and prioritizing design in our courses.
Meng To
I design, code and write
Meng To is the author of Design+Code. Meng started off his career as a self-taught designer from Montreal and eventually traveled around the world for 2 years as his US VISA was denied. During his travels, he wrote a book which now has 35,000 readers.
40 courses - 186 hours

Master AI Prompting for Stunning UI
Learn how to leverage AI tools like Aura for creating beautiful designs, working with templates, and experimenting with advanced prompts. A concise guide for designers and developers to level up their skills.
2 hrs

Build SwiftUI apps for iOS 18 with Cursor and Xcode
In this course, we'll explore the exciting new features of SwiftUI 6 and Xcode 16 for building iOS 18 apps. From mesh gradients and text animations to ripple effects, you'll learn how to create polished, highly custom apps using the latest workflows. We'll also dive into using Cursor and Claude AI for AI-driven coding, helping you start strong and customize your apps.
5 hrs

Create your Dream Apps with Cursor and Claude AI
Learn to build your dream web apps from the ground up using Cursor, Claude AI, and a suite of powerful AI tools. This course covers everything you need, including React for frontend development, Firebase for backend integration, and Stripe for handling payments. You’ll also dive into advanced AI tools like Claude Artifacts, Galileo AI, v0.dev for UI, Ideogram for design generation, and Cursor Composer for full-scale development.
6 hrs

Build a React Site from Figma to Codux
In this course, you'll learn to build a website from scratch using Codux, starting with a Figma template. You’ll master responsive design, collaborate with developers on a real React project, export CSS from Figma using Locofy, set up breakpoints with media queries, add CSS animations, improve SEO, create multiple pages with React Router, and publish your site. By following best practices, you’ll bridge design and development, improve your web design skills.
2 hrs

Create 3D UI for iOS and visionOS in Spline
Comprehensive 3D Design Course: From Basics to Advanced Techniques for iOS and visionOS using SwiftUI
3 hrs

Master No-Code Web Design with Framer
In this free Framer course, you'll learn to create modern, user-friendly interfaces. Start with dark mode and glass designs, then move from Figma to Framer, using vectors and auto layout for responsive websites. Add animations, interactive buttons, and custom components with code. Finally, you'll craft a design system suitable for teamwork or solo projects, all in a straightforward and practical approach.
4 hrs

Build SwiftUI Apps for iOS 17
In this course, we’ll be exploring the fresh and exciting features of SwiftUI 5! As we craft a variety of iOS apps from the ground up, we'll delve deep into the treasure trove that is SwiftUI's user interface, interactions, and animations.
4 hrs

Build Beautiful Apps with GPT-4 and Midjourney
Design and develop apps using GPT-4 and Midjourney with prompts for SwiftUI, React, CSS, app concepts, icons, and copywriting
4 hrs

Build SwiftUI apps for iOS 16
Create animated and interactive apps using new iOS 16 techniques using SwiftUI 4 and Xcode 14
5 hrs

Build a 3D Site Without Code with Framer
Design and publish a responsive site with 3D animation without writing a single line of code
3 hrs

Create 3D Site with Spline and React
Design and code a landing page with an interactive 3D asset using Spline and CodeSandbox
1 hrs

Build an Animated App with Rive and SwiftUI
Design and code an iOS app with Rive animated assets, icon animations, custom layouts and interactions
3 hrs

Build a SwiftUI app for iOS 15 Part 3
Design and code a SwiftUI 3 app with custom layouts, animations and gestures using Xcode 13, SF Symbols 3, Canvas, Concurrency, Searchable and a whole lot more
4 hrs

Build a SwiftUI app for iOS 15 Part 2
Design and code a SwiftUI 3 app with custom layouts, animations and gestures using Xcode 13, SF Symbols 3, Canvas, Concurrency, Searchable and a whole lot more
3 hrs

Build a SwiftUI app for iOS 15
Design and code a SwiftUI 3 app with custom layouts, animations and gestures using Xcode 13, SF Symbols 3, Canvas, Concurrency, Searchable and a whole lot more
4 hrs

React Livestreams
Learn how we can use React Hooks to build web apps using libraries, tools, apis and frameworks
4 hrs

Design Founder Livestreams
A journey on how we built DesignCode covering product design, management, analytics, revenue and a good dose of learning from our successes and failures
2 hrs

SwiftUI Advanced Handbook
An extensive series of tutorials covering advanced topics related to SwiftUI, with a main focus on backend and logic to take your SwiftUI skills to the next level
4 hrs

iOS Design Handbook
A complete guide to designing for iOS 14 with videos, examples and design files
2 hrs

SwiftUI Handbook
A comprehensive series of tutorials covering Xcode, SwiftUI and all the layout and development techniques
7 hrs

Build a web app with React Hooks
Learn how we built the new Design+Code site with React Hooks using Gatsby, Netlify, and advanced CSS techniques with Styled Components.
4 hrs

UI Design Handbook
A comprehensive guide to the best tips and tricks for UI design. Free tutorials for learning user interface design.
2 hrs

Figma Handbook
A comprehensive guide to the best tips and tricks in Figma
6 hrs

SwiftUI for iOS 14
Build a multi-platform app from scratch using the new techniques in iOS 14. We'll use the Sidebar and Lazy Grids to make the layout adaptive for iOS, iPadOS, macOS Big Sur and we'll learn the new Matched Geometry Effect to create beautiful transitions between screens without the complexity. This course is beginner-friendly and is taught step-by-step in a video format.
3 hrs

SwiftUI Livestreams
This is a compilation of the SwiftUI live streams hosted by Meng. Over there he talks and teaches how to use design systems, typography, navigation, iOS 14 Design, prototyping, animation and Developer Handoff.
19 hrs

UI Design Livestreams
This is a compilation of the UI live streams hosted by Meng. Over there he talks and teaches how to use design systems, typography, navigation, iOS 14 Design, prototyping, animation and Developer Handoff.
26 hrs

UI Design for Developers
In this course we'll learn how to use design systems, set up break points, typography, spacing, navigation, size rules for adapting to the iPad, mobile and web versions, and different techniques that translate well from design to code.
3 hrs

Build an app with SwiftUI Part 3
This course was written for designers and developers who are passionate about design and about building real apps for iOS, iPadOS, macOS, tvOS and watchOS. SwiftUI works across all of those platforms. While the code is not a one-size-fits-all, the controls and techniques involved can apply to all platforms. It is beginner-friendly, but it is also packed with design tricks and cool workflows about building the best UIs and interactions.
4 hrs

Build an app with SwiftUI Part 2
This course was written for designers and developers who are passionate about design and about building real apps for iOS, iPadOS, macOS, tvOS and watchOS. SwiftUI works across all of those platforms. While the code is not a one-size-fits-all, the controls and techniques involved can apply to all platforms. It is beginner-friendly, but it is also packed with design tricks and cool workflows about building the best UIs and interactions.
4 hrs

Build a full site in Webflow
Webflow is a design tool that can build production-ready experiences without code. You can implement CSS-driven adaptive layouts, build complex interactions and deploy all in one tool. Webflow also comes with a built-in content management system (CMS) and Ecommerce for creating a purchase experience without the need of third-party tools.
3 hrs

Advanced Prototyping in ProtoPie
ProtoPie is a cross-platform prototyping tool that creates prototypes nearly as powerful as those made with code, with half of the efforts, and zero code. It's perfect for designers who want to quickly experiment with advanced interactions using variables, conditions, sensors and more.
3 hrs

Build an app with SwiftUI Part 1
This course was written for designers and developers who are passionate about design and about building real apps for iOS, iPadOS, macOS, tvOS and watchOS. SwiftUI works across all of those platforms. While the code is not a one-size-fits-all, the controls and techniques involved can apply to all platforms. It is beginner-friendly, but it is also packed with design tricks and cool workflows about building the best UIs and interactions.
4 hrs

React Native for Designers Part 2
React Native is a popular Javascript framework that builds on top of React by using native components to create a real mobile app indistinguishable from one made using Xcode or Android Studio. The main difference with native development is that you get to use CSS, hot-reload, Javascript and other familiar techniques that the Web has grown over the past decades. Most importantly, you're building for both iOS and Android using the same codebase.
3 hrs

React Native for Designers
React Native is a popular Javascript framework that builds on top of React by using native components to create a real mobile app indistinguishable from one made using Xcode or Android Studio. The main difference with native development is that you get to use CSS, hot-reload, Javascript and other familiar techniques that the Web has grown over the past decades. Most importantly, you're building for both iOS and Android using the same codebase.
5 hrs

Design System in Figma
Learn how to use and design a collaborative and powerful design system in Figma. Design Systems provide a shared library of reusable components and guidelines and that will let you build products much faster
3 hrs

React for Designers
Learn how to build a modern site using React and the most efficient libraries to get your site/product online. Get familiar with Grid CSS, animations, interactions, dynamic data with Contentful and deploying your site with Netlify.
3 hrs

Swift Advanced
Learn Swift a robust and intuitive programming language created by Apple for building apps for iOS, Mac, Apple TV and Apple Watch
9 hrs

Learn Swift
Learn Swift a robust and intuitive programming language created by Apple for building apps for iOS, Mac, Apple TV and Apple Watch
4 hrs

Learn Sketch
Learn Sketch a design tool entirely vector-based and focused on user interface design
5 hrs

Learn iOS 11 Design
Learn colors, typography and layout for iOS 8
1 hrs