Tihi
Tihi

Reputation: 27

prevent scroll on body when disclosure panel is open

I'm using headless uis Disclosure to open a sidemenu. In a <Disclosure.Panel> I use "overflow-auto" to enable scrolling in the menu. However I want to disable the scroll on Body when I do this since otherwise I have two scrollbars for the y axis. Any tips on how to achieve this?

Upvotes: 1

Views: 1605

Answers (1)

davidtudorjohn
davidtudorjohn

Reputation: 16

Yes! Target the <body> or <html> element on the page and add overflow: hidden to prevent scrolling on the X or Y axis. You can do this with a class and toggle the class on when the panel is open and off when its closed to allow scrolling again.

Hope this helps!

Upvotes: 0

Related Questions