Sticky allows an element to become fixed in its parent container when it reaches a top, left, bottom, or right threshold.
You are responsible for giving it a top-x, left-x, bottom-x or right-x position to stick to.
Sticky allows an element to become fixed in its parent container when it reaches a top, left, bottom, or right threshold.
<div className="mt-14 h-80 overflow-y-auto rounded-lg border"> <div className="h-10" /> <Sticky className="top-0 bg-green-500">This sticks</Sticky> <div className="h-40" /> <p>Some content</p> <div className="h-40" /> <Sticky className="top-0 bg-emerald-500">This also sticks</Sticky> <div className="h-40" /> <p>Some more content</p> <div className="h-40" /></div>Here's the <Sticky /> component in action.
Some content
Some more content