Framer Prototypes
Framer now comes with Design + Code + Collaborate features, meaning you can create your prototype directly inside Framer, developing a fully functional prototype without any third-party software and without any coding skills. Here, I’ll teach you how to use simple Framer code without any prior knowledge of coding required. This isn’t an extensive guide to remote user testing. It is a quick-step guide to using Hotjar for remote user testing Framer prototypes. If you want info on the former, then check out these great books: Remote Research or Just Enough Research. Framer has come a long way from being viewed as a super-advanced prototyping with code tool to now a design tool with prototyping capabilities. There are a couple of ways you can prototype a hover state in Framer X. We are going to go over the code override method because that's more unique to Framer and it’s not too complex.
On this page, you’ll find some examples of how you can use the iOS 13 Segmented Control component in your prototypes.
Current option
This simple demo shows how to get the control’s currently selected option.
The component has an event callback property: onValueChange()
. A function passed to that property will be called every time the selected segment changes.
The example function below is simple: It just saves the current option
in appState.currentOption
…
… which in turn will update the text
of the text block:
Current index
The onValueChange()
callback is always called with two parameters: option
(as used above), but also index
, the number of the selected tab.
Depending on what you want to accomplish, you can use one or the other.
Properties demo
In this next prototype, three segmented controls are used to change the properties of the fourth segmented control at the bottom.
As a reminder, these are this component’s properties:
Property | Type | Description |
---|---|---|
mode | boolean | Light or Dark mode |
options | string[] | Names of the (max. 5) segments |
setCurrentBy | boolean | Whether to set the selected segment by index or name |
currentIndex | number | Index of the selected segment |
currentOption | string | Name of the selected segment |
onValueChange() | function | Event callback property that shares the selected segment’s option name and index number |
And here’s the code: There’s a data object, called appState
, in which the current mode
, options
and currentIndex
are saved:
Those values are passed to the bottom segmented control:
(The setCurrentBy
property is simply set to true
because we’re changing the selection by index number.)
When the mode
switches to Dark Mode, we want the frame under the segmented control to be dark as well. That happens with this override:
The frame’s background
color will be white when appState.mode
is true
, and black when it’s not.
The three segmented controls at the top have overrides that use the onValueChange()
callback property to update the corresponding values in appState
.
1. Changing the mode
2. Changing the options
3. Changing the currentIndex
Maps
When switching to the Satellite view in Apple’s Maps app, the interface will transition to Dark Mode, even when your phone is currently in Light Mode.
The mode
property of the segmented control is a Boolean, in which true
stands for Light Mode, and false
for Dark Mode.
There’s a data object with the current mode
and the opacity values of the screens (which are just images):
(The first screen, Map, is placed underneath the other two, so it never needs to be hidden.)
Those opacity values are passed, in turn, to the animate
property of the screens:
And then the screens are faded in or out depending on the current index
of the segmented control:
Framer X Windows Release Date
Note that in this same override the segmented control’s mode
is bound to appState.mode
, and that the mode
will always be true
, except when switching to the Satellite screen.
Framer Prototype
By the way, this prototype also uses the Status Bar component from Framer’s Example Kit.
This status bar switches between its light and dark style with an appearance
property that expects a string: 'dark'
or 'light'
.
So when appState.mode
is true
we pass it a 'dark'
, and when it’s not, a 'light'
:
Steps
Next up: the Steps detail screen in the iPhone Health app.
We’re animating two things simultaneously: the number of steps above the chart and the chart itself. The steps count has a simple opacity animation, but the chart also has a width animation (scaleX
) when fading in.
For the day, week, month, and year numbers, I used simple opacity values:
… which I applied to the corresponding images (in an animate
, so that they will fade in and out):
But the charts, on the other hand, have a variants animation…
… with these variant labels:
The animation to 'hidden'
has a duration
of 0
, so it happens instantly. It also makes the chart invisible (zero opacity
) and a bit wider (a scaleX
of 120%).
Sharing Framer Prototypes
When animated to 'visible'
, the chart will shrink back to its real size while fading in.
The charts each get the chartVariants
object as their animation variants
, and the current variant label to animate
to (in variantChartDay
, variantChartWeek
, etc.).
When the selection of the segmented control changes, I first hide all numbers and charts:
Framer X For Windows
… but directly after that, I show the correct amount and chart: