Last active
November 11, 2025 19:39
-
-
Save wookiehangover/3ff553834bc4430ea4ab295aeab93116 to your computer and use it in GitHub Desktop.
A simple grid based scroll layout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { memo } from 'react'; | |
| export default function ScrollLayout() { | |
| return ( | |
| <div className="grid h-screen grid-rows-[auto_1fr_auto]"> | |
| <header className="h-20 bg-purple-500"></header> | |
| <div className="overflow-y-scroll"> | |
| <div> | |
| <Section /> | |
| <Section /> | |
| <Section /> | |
| <Section /> | |
| <Section /> | |
| <Section /> | |
| </div> | |
| </div> | |
| <footer className="h-40 bg-cyan-500"></footer> | |
| </div> | |
| ); | |
| } | |
| const Section = memo(() => { | |
| return ( | |
| <section className="my-10 flex h-full flex-col border-b bg-white pb-10 md:flex-row"> | |
| <div className="md:w-2/5 p-4"> | |
| <p className="sticky top-4"> | |
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do | |
| eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad | |
| minim veniam, quis nostrud exercitation ullamco laboris nisi ut | |
| aliquip ex ea commodo consequat. Duis aute irure dolor in | |
| reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla | |
| pariatur. Excepteur sint occaecat cupidatat non proident, sunt in | |
| culpa qui officia deserunt mollit anim id est laborum. | |
| </p> | |
| </div> | |
| <div | |
| className="md:w-3/5 bg-gray-100" | |
| style={{ | |
| height: `${Math.random() * 200 + 50}vh`, | |
| backgroundColor: `hsla(${Math.random() * 360}, 50%, 50%, 30%)`, | |
| }} | |
| > | |
| <div></div> | |
| </div> | |
| </section> | |
| ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment