Skip to main content

Fixed Element

Make an element fix on scrolling:

import { ScrollContainer, FixedElement } from 'react-nice-scroll';
import 'react-nice-scroll/dist/styles.css';

const Index = () => {
return (
<ScrollContainer>
<section style={{ height: '300vh' }}>
<FixedElement left={10} top={10}>
<span>Fixed Elemet</span>
</FixedElement>
<h1>Hello World!</h1>
</section>
</ScrollContainer>
);
};

export default Index;

Demo

Check demo.

FixedElement Props

PropsValue TypeDefault Value
topnumber0
rightnumber | undefinedundefined
leftnumber | undefinedundefined