Skip to main content

Command Palette

Search for a command to run...

Hide Scrollbar From Browser

Updated
β€’1 min read
Hide Scrollbar From Browser
S

I am Senior Frontend Engineer and post daily tips about Web Dev

My goal is to encourage more people to get into tech.

There are many times when we need to hide the scrollbar from the HTML elements. The uses can vary from person to person. It is opinionated topic to keep the scrollbar or not based on User Interactions(UI)/User ,Experience(UX).

Most of the time, I don't like to show the scrollbar to the user because of design practices I follow.

To achieve this, you just need to tickle with CSS to add some pseudo selectors for hiding it based on Browser's stylings

For Chrome:

/* Hide scrollbar for Chrome, Safari and Opera */
::-webkit-scrollbar {
    display: none;
}

.element::-webkit-scrollbar { width: 0 !important }

For Firefox / Edge: (Checkout the firefox output and then GTG)

html {
    scrollbar-width: none;
}

Important Points to be considered before hiding the scroll bar:

  1. Preferably Hide scrollbars only when if all content is visible else user may skip the content
  2. Avoid horizontal scrolling on Web pages and do not hide horizontal scroll bar as they can make content difficult to read

Checkout the Codepen here πŸš€

🌟 Twitter πŸ‘©πŸ»β€πŸ’» suprabha.me 🌟 Instagram
D

A website I visited a few days back (name, I can't remember) had a button that said: "Don't click this button". Soon after clicking it, my cursor disappeared for that specific website. I could not recreate that trick, can you help to code something like that?