Framer: the canvas is the website¶
Exercise framer-first-page-annex.pdf · PDF
Picture a landing page on your phone: a big title, a button, three cards. Now shrink a browser window showing the same page, and the three cards stack by themselves. How many lines of code did it take to build that? None.
By the end of this page you can do the same: build a real web page for your own app, make it work at three widths, publish it, and open it on your phone. All of it in a browser, with nothing to install. There is a catch, though, and it is worth knowing before you fall in love.
What you will learn
- Define a visual editor that generates code, and place Framer next to NetBeans, Scene Builder and Figma Dev Mode
- Build a section of a page with stacks: direction, distribute, gap and padding
- Choose between the sizing modes Fixed, Relative, Fill and Fit Content, and justify the choice
- Make one page work at three breakpoints, and say what changes in each
- Publish a page and say who is really hosting it
- The trap: why Fill does not mean 100 % of the screen
The printing press¶
Keep one picture in your head for the whole page: a printing press.
In Figma you draw the poster, and someone else prints it. Framer is a press: the thing on the table is the poster, and the button at the top right sends it to the street.
| In the print shop | In Framer |
|---|---|
| The poster on the table | The canvas: the page itself |
| The columns and spacing rules of the type | Stacks and sizing modes |
| One poster cut for a wall, a bus stop and a leaflet | Breakpoints |
| Sending it to the street | Publish |
Editors that write code¶
A visual editor is a tool where you build an interface by placing and adjusting pieces on a canvas, instead of typing it. A visual editor that generates code also writes out, as text, what you drew.
You may have met the first two below in 1st year.
| Editor | You draw... | It writes... |
|---|---|---|
| NetBeans GUI Builder | A Swing window, dragging buttons from a palette | Java code, in grey blocks you are not allowed to edit |
| Scene Builder | A JavaFX window | An FXML file: XML that describes the window |
| Figma Dev Mode | Any screen, for any platform | Snippets, layer by layer: CSS for the web, SwiftUI for iOS, Compose for Android. You assemble them |
| Framer | A website, with real breakpoints | A whole live site that Framer itself hosts. You never receive the files |
A snippet is a small piece of code, not a whole program. So Figma gives you pieces to assemble, and Framer gives you a finished product you cannot take away. They sit at opposite ends, which is why you should know both.
Careful: you still need to read code
"If the editor writes the code, I do not need to learn the code." NetBeans' grey blocks already answered that one: the day the layout is wrong, you must read the code to know why. Reading and changing generated code is the next step: Generated code, assets and tokens.
A tour of Framer¶
Go to framer.com, sign up with Google or an email, skip the questionnaire, and create a new blank project. Do not start from a template: you want to build every layer, so you know what each one does. If you would rather not have an account, tell your teacher privately and you will agree an alternative.
It will feel familiar, because it was designed for people who come from Figma.
| Area | What it does | In Figma it was... |
|---|---|---|
| Canvas | The page itself, at each breakpoint, side by side | The canvas with frames |
| Layers (left) | The tree of the page: sections, stacks, text | The layers panel |
| Insert | Ready-made pieces: sections, forms, navigation, images | Assets and community files |
| Properties (right) | Position, size, layout, styles and effects of the selected layer | The Design panel |
| Preview and Publish | Try the page as a visitor; put it on the internet | Prototype mode; no equivalent |
Framer redesigns its panels often. If a word on your screen differs from this page, look for the idea, not the word.
Stacks: auto layout with another name¶
Draw a frame on the page, put a text and a button inside, and select the frame. In Layout, choose Stack.
A stack is a frame that arranges its children automatically, following a direction, a distribution, a gap and padding.
| Property | What it controls | In Figma |
|---|---|---|
| Direction | Children in a row or in a column | Direction |
| Distribute | How the free space is shared along the direction | Alignment |
| Gap | Space between the children | Gap |
| Padding | Space between the stack's edge and its children | Padding |
Seen those before? They are auto layout from Unit 1. Framer calls it a stack, and in the browser both ideas are the same CSS feature, flexbox: the browser's way of laying out items in a row or a column.
Sizing modes: as wide as what?¶
Every layer in a stack answers one question: how wide am I? Framer offers five answers.
| Mode | The layer is as wide as... | In Figma |
|---|---|---|
| Fixed | A number of pixels. It ignores everything else | Fixed |
| Relative | A percentage of its parent | No direct match |
| Fill | The space its siblings leave free inside the stack | Fill container |
| Fit Content | What it holds, plus its padding | Hug contents |
| Viewport | (Height only) The height of the browser window | No match |
The trap: Fill is not 100 % of the screen
Fill means the space my parent gives me. Put a Fill child inside a Fit Content parent and you have a circle: the parent asks the child how big it is, and the child asks the parent. It resolves to nothing. The same trap exists with Hug in Figma. If you want a percentage, that is Relative.
Building a landing page¶
A landing page is a single page whose job is to present one thing and make you want it. Yours has a hero (the big opening block: the app name, one sentence, a button) and a row of three feature cards. Here is the layout, and how to test each choice:
| Layer | Set it up like this | You got it right when... |
|---|---|---|
| The page | A vertical stack: hero, then features | Moving the hero in the layers reorders the page |
| Hero | Vertical stack, centred, gap 16, padding 80 top and bottom, height Fit Content | A longer sentence makes the hero taller, not cut |
| Button | Horizontal stack around the label, Fit Content both ways | A longer label makes the button wider |
| Features | Horizontal stack, gap 24, with three cards at Fill width | A wider window makes all three cards wider, equally |
| Sections | A max width of 1200, centred | On a very wide window, the text does not run edge to edge |
flowchart TB
P["<b>Page</b><br>vertical stack"] --> H["<b>Hero</b><br>vertical stack, Fit Content height"]
P --> F["<b>Features</b><br>horizontal stack, gap 24"]
H --> T["Title and sentence"]
H --> B["<b>Button</b><br>Fit Content both ways"]
F --> C1["<b>Card</b><br>Fill"]
F --> C2["<b>Card</b><br>Fill"]
F --> C3["<b>Card</b><br>Fill"]
When something misbehaves, it is usually one of these:
| What you see | The cause | The fix |
|---|---|---|
| A layer ignores the stack | You dragged it out: it is now in absolute position, pinned to one place | Drag it back into the stack in the layers panel |
| The cards do not grow with the window | They are Fixed: the gap grows, the cards do not | Set them to Fill |
| The hero's text overflows | The hero has a Fixed height | Set it to Fit Content |
Breakpoints: one page, three widths¶
You have seen a page rearrange itself on a phone. The idea has a name and a date: responsive web design, from Ethan Marcotte's article in A List Apart on 25 May 2010. A responsive page adapts to the width it is given.
A breakpoint is a window width at which the layout changes its arrangement, not just its size.
In the press, it is the same poster cut for a wall, a bus stop and a leaflet. This course uses Desktop 1200, Tablet 810 and Phone 390. That is a common choice among Framer users, not an official standard: if Framer proposes other numbers in your project, use Framer's.
The rules of inheritance are what make it work:
| You do this | What happens | Why |
|---|---|---|
| Change the title on Desktop | It changes everywhere | Desktop is the primary breakpoint, and the others inherit from it |
| Change the features stack to vertical on Phone | Only Phone changes | A change on a secondary breakpoint is an override for that width only |
The breakpoint you click on is the one you edit. If Desktop changed when you meant to change Phone, you selected the layer on the Desktop canvas.
So why only three? Drag the edge of a breakpoint: between 810 and 1200 the layout simply stretches. Fill and Fit Content do the work in between. You add a breakpoint only when the arrangement must change.
| Width | What the landing page does |
|---|---|
| Desktop | Cards in a row |
| Tablet | Cards still in a row, with less hero padding: 48 instead of 80 |
| Phone | Cards stacked vertically at Fill width, a smaller title (at least 28), a Fill-width button |
Two habits keep you out of trouble:
- Do not resize the cards by hand on Phone. Overrides pile up. The fix is one setting: direction vertical, width Fill.
- Test the widths in between. Open Preview and drag its width from 1400 to 360. A width where something breaks is a bug report, not a reason for a fourth breakpoint. The usual culprit is a Fixed width: find it and set Fill.
Careful: a breakpoint is not a device
"Phone" does not mean a phone. It means a width. A laptop window dragged narrow hits the Phone breakpoint too.
Publish: who is hosting this?¶
Press Publish at the top right, and Framer gives your site a free address on a Framer subdomain. Open it on your phone: scan a QR code made from the address, or just type it. You have shipped a web page.
Now look closer. Your page is sitting on Framer's servers.
| On the free plan | |
|---|---|
| Address | A Framer subdomain, with no custom domain |
| On the page | A small Framer badge |
| Time limit | None: it is not a trial, but it is meant for non-commercial use |
| Download the HTML | No. Framer offers no HTML export for self-hosting, on any plan |
That last line is the catch. You can read your page's code in the browser, but you cannot take it away. If Framer closes your account, the site goes with it.
| Figma | Framer | |
|---|---|---|
| Layout | Auto layout | Stack (and Grid) |
| Sizes | Fixed, Hug, Fill | Fixed, Relative, Fill, Fit Content, Viewport |
| Widths | One frame per width, drawn by hand | Breakpoints, with inheritance and overrides |
| Output | CSS snippets you assemble (Dev Mode) | A hosted, finished website |
| Good for | Apps you will build and maintain in code | A web page that must be online today |
Key takeaways¶
- A visual editor that generates code writes out what you draw. Figma Dev Mode gives you snippets to assemble. Framer gives you a finished site you cannot take away.
- A stack is auto layout under another name: direction, distribute, gap, padding. In the browser it is flexbox.
- Fill is the space the parent leaves free, Fit Content is what the layer holds, Fixed is a number of pixels, Relative is a percentage.
- A breakpoint is a width where the arrangement changes. Changes on the primary breakpoint are inherited; changes on the others are overrides.
- Fewer breakpoints are better: Fill and Fit Content cover the widths in between.
- Publishing puts your page on Framer's servers, with no HTML export.
Quick check¶
1. What makes Framer different from Figma Dev Mode?
- Framer produces a hosted website; Dev Mode gives you code snippets to assemble
- Framer gives you code snippets to assemble; Dev Mode produces a hosted website
- Framer only draws Java windows; Dev Mode only draws pages for the web browser
- Framer needs to be installed on a PC; Dev Mode only runs on a Framer subdomain
They sit at opposite ends. Dev Mode gives you pieces, layer by layer, for you to assemble. Framer gives you a whole live site that it hosts itself, and you never receive the files.
2. A horizontal stack holds a menu 240 pixels wide and a content area. The content must take whatever is left. Which sizing mode does the content area need?
- Fill
- Fixed
- Fit Content
- Viewport
Fill takes the space the siblings leave free, so the content area grows and shrinks with the window while the menu stays put. Fit Content would depend on what the area holds, and Viewport is for height only.
3. A Fill child sits inside a Fit Content parent. What is the problem?
- Each one waits for the other's size, so the width resolves to nothing
- The child grows to the full width of the screen and pushes its siblings out
- The parent becomes Fixed automatically and ignores any change in the content
- The stack changes its direction from a row to a column at every breakpoint
Fill means the space my parent gives me, and Fit Content means the size of what I hold. Put them together and each one asks the other. The same trap exists with Hug in Figma.
4. You reduce the hero's padding on the Tablet breakpoint. What happens to the hero on Desktop?
- Nothing: a change on a secondary breakpoint is an override for that width only
- It changes too: every change on any breakpoint is inherited by all of the others
- It breaks: a hero must have the same padding on each of the three breakpoints
- It asks: Framer shows a dialog so that you can pick the widths the change reaches
Desktop is the primary breakpoint, and the others inherit from it, not the reverse. A change made on Tablet or Phone is an override that stays at that width.
5. What does a breakpoint represent?
- A window width at which the layout changes its arrangement
- A device model for which the page gets a separate design
- A window width at which the browser reloads the whole page
- A percentage of its parent that a layer takes in the stack
A breakpoint is a width, not a device. A laptop window dragged narrow reaches the Phone breakpoint too, and between breakpoints Fill and Fit Content stretch the layout.
6. Your page breaks at a width of 600 pixels, between Phone and Tablet. What should you look for first?
- A Fixed width on some layer, which you can set to Fill
- A missing fourth breakpoint, which you can add at 600
- A missing Framer badge, which you can add in the footer
- A wrong page title, which you can change in the settings
Fill and Fit Content should cover the widths in between. A width where something breaks is a bug report, not a reason for another breakpoint, and the usual cause is a Fixed width that cannot adapt.
7. A shop asks you to build its website in Framer and later move it to its own server. What must you warn them about?
- Framer offers no HTML export, so the site cannot be moved out and self-hosted
- Framer's sites stop working after a trial period that ends once a site is moved
- Framer's sites cannot be opened on a phone until they are on the shop's own server
- Framer's sites have to be rebuilt in Figma before they can be sent to the shop's server
Framer hosts the site on its own servers. You can read the published code in the browser, but there is no HTML export for self-hosting. A site built there stays there.
Your page is on the street, printed by a machine. Next you open up what such a machine writes, and learn to fix it: Generated code, assets and tokens.