Hide the scrollbar in MUI Grid, all while maintaining the ability to scroll seamlessly

I am attempting to achieve the same outcome as mentioned in this post, but within a MUI Grid container/item. However, I am facing an issue where I do not see a scrollbar and am unable to scroll. Could there be a problem with my implementation?

Here is the sandbox link

Thank you in advance for your help.

Update: It seems the links are functional now, so I am updating this post with the relevant links and code.

Links:

  1. Hide scroll bar, but while still being able to scroll
  2. https://codesandbox.io/p/sandbox/scrollable-grid-8jrc3n?file=%2Fsrc%2FScrollableGrid.tsx

Code:

const ScrollableGrid: React.FC = () => {
  return (
    <Grid
      container
      sx={{ overflow: "hidden", maxHeight: "300px", border: "1px solid green" }}
    >
      <Grid
        item
        xs={12}
        sx={{
          overflowY: "auto",
          height: "100%",
          boxSizing: "content-box",
          border: "1px solid red",
          margin: "10px",
        }}
      >
        <div>Text 1</div>
        <br />
        <div>Text 2</div>
        <br />
        <div>Text 3</div>
        <br />
        <div>Text 4</div>
        <br />
        <div>Text 5</div>
        <br />
        <div>Text 6</div>
        <br />
        <div>Text 7</div>
        <br />
        <div>Text 8</div>
        <br />
        <div>Text 9</div>
        <br />
        <div>Text 10</div>
        <br />
        <div>Text 11</div>
        <br />
        <div>Text 12</div>
        <br />
      </Grid>
    </Grid>
  );
};

Answer №1

My previous comment successfully addressed this, so I'm sharing this for the benefit of other users.

If you wish to hide the scrollbar without compromising the functionality, you can do so using the following CSS:

.HideScrollbar {
  -ms-overflow-style: none; /* Specific to IE and Edge */
  scrollbar-width: none; /* Applicable to Firefox */
}
.HideScrollbar::-webkit-scrollbar {
  display: none;
}

Find more details and example code in this link for a forked version of the Code Sandbox.

Answer №2

To remove the scrollbar from view, simply insert the code below into your index.css file or your primary CSS document.

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

/* Conceal scrollbar for IE, Edge, and Firefox */
.example {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

Make sure to apply the CSS class name to your div element.

<div className="example">
  <-- Your content here -->
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to modify the floating label color using Bootstrap 5

I'm currently utilizing bootstrap 5 to craft a form featuring floating input functionality. Below is an example of the input I am utilizing: <div class="form-floating mx-auto mb-3 w-25"> <input type="text" class=" ...

Adjusting CSS to switch up the color scheme

Is there a way to allow users to change the background color of pull quotes by using the input type="color tag within a form element? Below is my current HTML structure: <form action="change.php" method="post"> name: <input type="text"> ...

A step-by-step guide on utilizing jQuery to cyclically change the background color of elements upon clicking, and resetting the colors upon clicking another element

So I've been working on a solution to change the background color for accessibility purposes on a client's website. To achieve this, I have a set of div elements with different background colors and I'm using jQuery to update the body backgr ...

Arrange content within DIVs using Bootstrap-4

I'm having trouble figuring out how to align and organize my div content using Bootstrap. I'm a bit confused about how it all fits together align-items- * text-* align-self- * justify-items- * justify-self- * I'm attempting to structure my ...

Struggling with lag in MaterialUI TextFields? Discover tips for boosting performance with forms containing numerous inputs

Having some trouble with Textfield in my MateriaUI project. The form I created has multiple inputs and it's a bit slow when typing or deleting values within the fields. Interestingly, there is no lag in components with fewer inputs. UPDATE: It appear ...

`Responsive Site with Centered Image Overlay`

I've been attempting to center a small image within a larger one, both of which are contained within a Bootstrap Column. <div className="row justify-content-center my-5 "> <div className="col-xs-10 col-sm-6 my-auto mx-auto" ...

Unexpected output from Material UI Textfield

When attempting to print a page of my React app using window.print(), everything prints correctly except for the Textfield component from Material UI. It works fine when there are only a few lines of text, but when there is a lot of text, it appears like t ...

What is the best method for arranging drop-down menu options in alphabetical order?

Is there a way to organize the options alphabetically in the dropdown menu of Material-UI? I understand that arrays can be sorted easily using arr.sort(). However, when I try const options = [...].sort(), I still see unsorted values in the dropdown menu. ...

Adjusting the width of a select box to match the size of its child table using CSS

Within my Vue application, I've implemented a select box that contains a table component. When the select box is clicked, the table becomes visible in a container. However, I'm facing an issue where I can't dynamically adjust the width of th ...

Rotate a div using CSS by 10 degrees while spanning the full width

I stumbled upon the website recently, particularly noticing the Social News section on the side. I am curious about how to create rotated divs (around 10 degrees) that span the full width of a webpage. Is it possible to make this responsive so that it wor ...

Customizing the active link color in Bootstrap dropdown menus

Is there a way to customize the color and background of an active link in a boostrap's dropdown menu? Despite trying to override bootstrap's @dropdownLinkColorActive and @dropdownLinkBackgroundActive variables, the changes don't seem to tak ...

What is the recommended way to include an image in a v-for loop in Vue.js?

I have attempted various online solutions, but I am still unable to display images on the screen. Could it be a simple mistake? The file names and folders are accurate. When providing the path, I aim to retrieve the image associated with the sub-club name ...

jQuery iScroll: The scrolling feature does not stop when reaching the end of the content

Recently, I've been utilizing iScroll for horizontal scrolling on a list. At first, everything seems to be working fine, but as I scroll towards the end (right to left), the content reaches its conclusion yet the scrolling continues beyond that. I&apo ...

Fixing the Material UI upgrade error: "Make sure you have the right loader for this file type."

As a beginner in React, Webpack, Babel, and web development, I have been tasked by my company to upgrade the material-ui version for a dropdown search component. The current version used in the project is "1.0.0-beta.43", and I decided to start by upgradin ...

I'm encountering difficulties with customizing the root styling of material-ui's DialogActions

Check out the two buttons in a DialogActions just like this. This is the JSX snippet I'm working with: <DialogActions classes={{ root: classes.dialogActionsLeft }}> <Button autoFocus onClick={() => { setOpen(false); }} ...

Strange border adjustment for customized-height input[type=button] in Internet Explorer 6 and Firefox 3

Upon my discovery, I encountered a peculiar issue in IE6/FF3 when trying to set a custom height (even if it matches the default) on a button. The following code illustrates that although both buttons have the same height, their padding differs inexplicably ...

Examples of how to specify a child class in CSS

Presented here is the following structure: <article class="media media--small 48"> <a href="#"> <img src="" class="media__img" alt=""> <i class="s s--plus"></i></a> <div class="media__body"> < ...

Issue with Mui Select not correctly displaying options from an array

I am attempting to utilize the MUI Select (with a chip) within a list, specifically with multiple selects based on certain data. It may be somewhat challenging to explain. I have the capability to add or remove an individual select. function SelectTe ...

Using React and Material UI to customize the required label in a text field

In my React application, I am incorporating Material-UI. My goal is to modify the default label "Please fill out this field" of a text-field when setting the required attribute. I attempted to utilize setCustomValidity with inputProps, but unfortunately, ...

Struggle between Angular and fundamental CSS principles

Upon following the steps below, I aim to achieve my desired grids: How to set auto-margin boxes in flexible-width design using CSS? The solution provided is effective when implemented outside of Angular. However, when inserted inside an Angular component ...