How do you design responsive layouts for foldable devices?

Design foldable layouts by making the ordinary single-viewport layout work first, then add a two-segment arrangement when the browser exposes a hinge or fold. A foldable is not simply a wider phone. Its usable area may be split into separate regions with an occluded gap between them.
Keep reading order and keyboard order logical in the document. A dual-pane layout can place navigation in one segment and detail content in the other, but CSS positioning should not reverse the DOM sequence. When only one segment is available, the same content should collapse into the established mobile or tablet layout.
Viewport segment media features can detect multiple horizontal or vertical regions, while env(viewport-segment-width 0 0) and related variables expose their geometry. Add fallback values or place the entire enhancement inside a supporting media query because segment variables are defined only when the viewport is actually split.
@media (horizontal-viewport-segments: 2) {
.app-shell {
display: grid;
grid-template-columns:
env(viewport-segment-width 0 0)
env(viewport-segment-width 1 0);
column-gap: calc(
env(viewport-segment-left 1 0) –
env(viewport-segment-right 0 0)
);
}
}
Do not place buttons, text or drag handles across the fold. Treat the hinge gap as unavailable space and give each pane its own padding. Modals should fit one segment unless their purpose genuinely spans both. A full-width backdrop can cover the viewport while the dialog panel remains in a predictable region.
Test flat, partially folded and rotated states when the device and browser expose posture information. Also test a normal wide monitor because the fallback must not depend on fold-specific variables. Validate touch targets near the hinge, text zoom, virtual keyboards and transitions between one pane and two without losing state.