2 min read
The hidden issue with this Framer feature
It's crazy that Framer still does this the wrong way.
Adam Bárta

Framer lets you create incredible websites without ever touching code, but sometimes it has very glaring limits that break real production websites.
Some of these issues can be fixed with simple workarounds, but others require custom code to work properly.
After publishing several production websites over the past year, this is the bit that I ended up reusing through all of them.
The problem
If you have ever tried opening a website on different mobile browsers or devices, you have likely encountered this issue.
Each browser handles its UI differently. Some display a top bar, some a bottom bar, some both. Sometimes the bar gets hidden when scrolling, sometimes it doesn't.
This is why viewport units were introduced. They let you track the viewport's height so your UI doesn't overflow the screen.
In most cases, you will encounter “VH” (viewport-height) units for tracking height, which will currently return the height of the viewport along with the displayed browser UI (more here).
But that’s the issue. You instead want to use “DVH” (dynamic-viewport-height), which excludes UI elements.

Why Framer does it wrong
In Framer, you can use viewport units to measure screen height, but unfortunately, Framer uses VH units to track it.
This results in height not being tracked properly in some mobile browsers.
This is especially important with mobile menus. If you get the height wrong, you risk content overflowing outside of the screen.

The Fix
As you might have already guessed, the fix is very simple.
Just use DVH!
Simply apply this as a code override to any component where you need to scale height properly.
import type { ComponentType } from "react"
export function FullViewportHeight(Component): ComponentType {
return (props) => (
<Component
{...props}
style={{
...props.style,
minHeight: "100dvh",
height: "100dvh",
}}
/>
)
}Most often, I use this to fix the height of mobile menus to make sure no content is overflowing.