Drawer in Material-UI has whitespace remaining at the corners due to its rounded edges

While using the Material UI drawer, I attempted to round the corners using CSS:

  style={{
    borderRadius: "25px",
    backgroundColor: "red",
    overflow: "hidden",
    padding: "300px"
  }}

Although it somewhat works, the corners appear white instead of transparent.

https://i.sstatic.net/nEBp2.png

Any suggestions on how to properly round off the corners? The code can be found in this codesandbox link:

https://codesandbox.io/s/material-demo-q3n14

Answer №1

Cause

The content within your SwipeableDrawer is enclosed by a <Paper /> component. The Material-UI paper component comes with shadows and a solid background.

Resolution

Instead of using classnames, opt for using styles. To address this issue, adjust the SwipeableDrawer paperProps as follows:

PaperProps={{ elevation: 0, style: { backgroundColor: "transparent" } }}
  • Elevation set to 0 eliminates shadows
  • Setting backgroundColor to 'transparent' removes any background except your own

Note: To control the borderRadius, apply it directly to the Paper component rather than wrapping it in a div using the same prop:

PaperProps={{ square: false }}

Remove the borderRadius from the div element.

Utilizing classNames

If you prefer using classNames (refer to the documentation), you can assign a specific className to the paper component by utilizing the classes prop:

classes={{ paper: classes.someClassName }}

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

Apollo Client's useQuery function is causing unnecessary refetches when using Next.js' router.push method

Currently, I'm facing an issue where a query within a useQuery Apollo Client hook is being re-run unnecessarily every time Next.js's router.push function is triggered. The problem code snippet looks like this: const Parent = () => { useQuery ...

Fixing My Code with JQuery Tabs and Hyperlinking

I have come across a problem while using multiple pages with jQuery tabs. Let's consider Page1.html with #tab1 and #tab2, and Page2.html with #tab3 and #tab4. Here are the issues I am facing: 1) Within the tab content of Page1.html#tab2, there is a h ...

Preventing blank text entries in a task management application

Is there a way to determine if the text input provided by the user is empty or contains some text? I'm in the process of developing a TO-DO app and I'd like it so that if a user fails to enter anything into the text area and clicks on "add", the ...

Indicating that jQuery is not recognized despite the jQuery file being successfully loaded

Currently, I am working on an angular.js application where I have included the jQuery file. However, despite this inclusion, I am encountering an error message. Error Uncaught ReferenceError: jQuery is not defined(anonymous function) @ popup.js:1 File ...

Is it possible to transfer data from a JavaScript file to the Express server without relying on a form submission?

As a newcomer here, I apologize if I overlook any best practices. Currently, I am in the process of developing a sudoku game using express, JavaScript, HTML, and mongoDb. My current challenge involves setting up a statistics system. My goal is to send da ...

The div inside an iframe is not displaying the desired background color as intended from the parent page

The code snippet below is included in the <head> section of the main page: <script type="text/javascript"> $(document).ready(function () { $('#innerframe').load(function () { $(this).contents().find($(".TitleB ...

Can I securely hand off a JavaScript callback to an FFI function that executes it in a separate thread?

I need to use a C function that takes a callback and executes it on a separate thread: void execute_in_new_thread(void (*callback)()) { // create a new thread and run `callback` in it ... } To accomplish this from JavaScript using Node-FFI, I have to ...

What strategies can be used to effectively manage multiple asynchronous requests?

I have two requirements: one is to load an image (which will take a long time on the backend server), and the other is to perform an AJAX request. I would like it to be structured like this: $.when( [perform image loading] [perform ajax request] ).t ...

What causes the Material UI CheckBox to show up twice upon initial rendering?

I'm experiencing a strange issue with my checkboxes that I just can't seem to solve. When the component initially loads, each checkbox is duplicated. However, on subsequent loads everything works as expected. Below is the code snippet in question ...

What is the best approach for extracting dynamically generated content from this particular website?

Looking to scrape data from this website Attempting to extract "timestamp" using Python and store it in a variable for customized parsing. Tried using scrapy for scraping the "timestamp", but faced limitations due to javascript-generated data not being s ...

Ways to Determine the Height and Width of an Image Once it has been Adjusted for a View

Is there a way to retrieve the height and width of an image after it has been resized for a view? I have images that may vary in original dimensions, but users can resize them as needed. For example, this code from the console gives the client height: do ...

By pressing the "showMore" button, the page dynamically pulls in a json list from a file

Currently, my focus is on a dropwizard-Java project. My task involves retrieving and showcasing the first 10 items from a json list in a mustache view. If the user clicks on the "show more" link, I should retrieve the next 10 elements from the list and d ...

Error: Material UI search bar doesn't refresh interface

I implemented Material UI's auto complete component to create a dynamic select input that can be searched. The component is fed options in the form of an array consisting of strings representing all possible choices. <Grid item xs = {props.xs} cla ...

Delete an entry in a singular mapping in a one-to-one connection [TypeORM]

Is there a way to remove an index from a one-to-one relationship in TypeORM? @OneToOne(() => Customer, { cascade: true }) @JoinColumn({ name: 'customer', referencedColumnName: 'uid' }) customer: Customer I searched the d ...

If I include the Next.js Image component within a React hook, it may trigger the error message "Attempting to update state on an unmounted component in React."

My UI layout needs to change when the window width changes. However, when I add an Image (Nextjs component) in my hook, I encounter an error message. I am not sure why adding Image (Nextjs component) is causing this problem. The error message is display ...

Using Typescript: A guide on including imported images in the output directory

typings/index.d.ts declare module "*.svg"; declare module "*.png"; declare module "*.jpg"; tsconfig.json { "compilerOptions": { "module": "commonjs", "target": "es5", "declaration": true, "outDir": "./dist" }, ...

Transferring array data between two distinct click actions

Is there a way to transfer values between click events in jQuery? For example, on the first click event I want to add or remove values from an array based on whether a checkbox is checked. Then, on the second click I would like to iterate through all the ...

Utilizing JavaScript for parallax horizontal scrolling (identifying optimal 50% of screen)

I have successfully implemented this code for vertical scrolling: $('.flapleftclass').css('top',(0+(scrolled*0.5))+'px'); This method works well because I am referencing to the top position. However, when it comes to horizon ...

My Tailwind CSS toggle button disappears in dark mode, why is that happening?

<button aria-label="Toggle Dark Mode" type="button" className="lg:inline-flex lg:w-40 md:w-screen p-3 h-12 w-12 order-2 md:order-3" onClick={() => setTheme(theme === 'dark' ? &ap ...

Angular.js: Navigating through HTML content

I am attempting to display a list of HTML data using angular.js and would like to implement ngInfiniteScroll. Here is the template I created: update: <div class="scroll" id="antTalkList" talk-type="total" view-type="total" infinite-scroll=' ...