New

April 28, 2025

Updated at April 29, 2025

code snippet
code override

Fix Mobile Layout Issues in Framer with 100dvh and 100svh

Struggling with mobile layouts getting cut off in Framer? Find out how switching from 100vh to 100dvh or 100svh solves the problem, and grab a ready-to-use code override to apply it easily.

David McBacon

Created by

David McBacon
Fix Mobile Layout Issues in Framer with 100dvh and 100svh

Overview

If you have ever noticed buttons getting cut off on mobile when usingheight: 100vh, it is becausevh does not adjust when the browser UI changes. Things like the address bar and tab bar can shrink or expand the visible area, but 100vh stays the same.

The fix is to use one of the new viewport units: 100dvh or 100svh.

  • 100dvh matches the visible height at all times, even when the browser UI collapses as you scroll.
  • 100svh stays fixed to the smallest possible viewport height, even if the browser UI hides. This helps avoid layout jumps — especially useful in animated sections or when devices are in low-power mode.

Framer doesn't support these units out of the box, so I built a code override that adds both. Copy the code below, create a new override file in Framer, and apply it to any layer where you want100dvh or 100svh.

import { forwardRef, type ComponentType } from "react"

// -------------------------------------------------- //
// DVH OVERRIDE
// -------------------------------------------------- //
export function withDvh(Component): ComponentType {
    return forwardRef((props, ref) => {
        const { style, ...restProps } = props

        return (
            <Component
                ref={ref}
                {...restProps}
                style={{
                    ...style,
                    height: "100dvh", // CHANGE THE VALUE HERE IF NEEDED
                }}
            />
        )
    })
}

// -------------------------------------------------- //
// SVH OVERRIDE
// -------------------------------------------------- //
export function withSvh(Component): ComponentType {
    return forwardRef((props, ref) => {
        const { style, ...restProps } = props

        return (
            <Component
                ref={ref}
                {...restProps}
                style={{
                    ...style,
                    height: "100svh", // CHANGE THE VALUE HERE IF NEEDED
                }}
            />
        )
    })
}

Show more

Sign up for the newsletter_

Get notifications about the latest Framer components or templates from BACHOFF Studio directly to your inbox.