Sticky Footer
On short pages the footer hugs the viewport bottom; on long pages it follows normal document flow.
Also known as footer pin · footer to bottom · short-page footer
Demo · not production-ready code
Prompt for AI
Pick a stack, copy a ready prompt, paste into Cursor / Claude / ChatGPT.
Your stack
Shapes the prompt you copy
React + Tailwind + shadcn/ui · EN
Stack: React + Tailwind + shadcn/ui. Use React with Tailwind CSS and shadcn/ui patterns (Radix-based primitives, cn(), class-first styling).
Task: implement "Sticky Footer".
Make the footer stick to the viewport bottom on short pages: page wrapper is flex column with min-height: 100dvh (not height, not 100vh), main gets flex: 1, footer follows in normal flow. On long pages it must scroll away—this is not position: fixed. Add safe-area padding if the footer has actions.
Anatomy:
- flexible main: main { flex: 1 } pushes the footer down.
- min-height: 100dvh: Use min-height, not height, so long content can grow.
Preferred API / pattern: `flex min-h-dvh flex-col + flex-1 main`
Keep scope minimal: only this UI pattern, match existing project style.Acceptance checks
- ○Avoid: Using height
- ○Avoid: position
- ○Avoid: flex
- ○Avoid: 100vh on mobile
In plain wordsHow people search for it
AnatomyOpen for part names
- flexible main
- main { flex: 1 } pushes the footer down.
- min-height: 100dvh
- Use min-height, not height, so long content can grow.
How to write itOpen for stack patterns
flex column + main { flex: 1 } / min-height: 100dvhflex min-h-dvh flex-col + flex-1 mainVStack { content; Spacer(minLength: 0); footer } in a full-height frame<Layout style={{ minHeight: '100vh' }}> + Content flex growNotes
Not the same as a fixed footer that always floats over content. Sticky footer only pins when content is short; long pages scroll past it naturally. Modern recipe: flex column, min-height: 100dvh, main flex: 1. Grid variant: rows auto 1fr auto. height: 100vh is the classic bug—content overflows or double-scrolls; use min-height and prefer dvh on mobile.
Common mistakesHumans and models trip here
- Using height: 100vh: long content overflows; min-height is the keyword.
- position: fixed by mistake: that is a floating chrome footer that always covers content.
- flex: 1 on the footer: the footer expands instead of the main region.
- 100vh on mobile: browser chrome changes leave a gap—use dvh.
More failure symptoms on AI broke it.
Related patterns
Spotted a wrong name or missing pattern?