Getting rid of padding in Material UI SwipeableViews in React

Seeking assistance with the React Tabs/SwipeableViews component. I used the MaterialUI Tabs as a reference and it mostly works fine. However, I am facing a minor issue with padding in the content section.

Current outcome:
Current Outcome

The buttons function correctly with smooth animations. Yet, upon inspecting the page, there is a 24px padding on the content section (The padding was initially on the buttons as well, but I managed to resolve it by overriding the style). The content of the SwipeableViews component is causing the issue.

Desired outcome:
Desired Outcome

I have attempted various solutions, including using a -24px margin as a workaround. However, this resulted in breaking the tabs. Any assistance on resolving this matter would be greatly appreciated. I hope the provided information is sufficient!

Wishing you a wonderful day.

Answer №1

const Panel = (props) => {
  const { children, value, index, ...other } = props;

  return (
    <div
      role="tabpanel"
      hidden={value !== index}
      id={`tab-${index}`}
      aria-labelledby={`tab-${index}`}
      {...other}
    >
      {value === index && (
        <Box style={{ padding: 0 }}>
          <Typography>{children}</Typography>
        </Box>
      )}
    </div>
  );
}

It seems like the padding caused an issue in your function. Make sure to remove the padding from the Box component within the Panel function.

The problem might have occurred because you assigned the p={3} prop, which adds default padding.

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

Can you explain the meanings of <div class="masthead pdng-stn1"> and <div class="phone-box wrap push" id="home"> in more detail?

While working on styling my web pages with CSS and Bootstrap, I came across a few classes like "masthead pdng-stn1" and "phone-box" in the code. Despite searching through the bootstrap.css file and all other CSS files in my folders, I couldn't find a ...

The argument passed cannot be assigned to the parameter required

Currently, I am in the process of transitioning an existing React project from JavaScript to TypeScript. One function in particular that I am working on is shown below: const isSad = async (value: string) => { return await fetch(process.env.REACT_AP ...

I am experiencing a CSS display issue on the mobile version of my map leaflet where only the header and footer are visible

I am experiencing a display issue on Android and iPhone due to conflicting css commands. Here's what's happening: I am using React + React Leaflet with a header, main, and footer all set to width 100% within a parent div with body set to width an ...

Setting the initial state for a React toggle custom hook

After clicking a chevron button, an accordion component below it expands to display its children components. The goal is to ensure that each chevron button operates independently so that only the clicked button expands its related accordion. Upon initial ...

What is the reason for the difference in width between Bootstrap-5 row and regular div blocks?

My code may seem simple, but I have encountered an issue with it: <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="99fbf6f6edeaedebf8e9d9acb7abb7a9">[email protected]</a ...

The deployment of the Heroku React-Express App is facing challenges

After successfully deploying my GitHub branch, I encountered an issue when trying to access the deployed web app - it displayed an "Invalid Host Header" error message. Upon reviewing the logs, here's what I discovered: 2023-09-17T10:17:43.000000+00:0 ...

Why is my table shifting when I go into fullscreen mode? Any ideas?

Can anyone explain why my project appears like this on a small tab, check image linked here But when it's full-screened, it looks like this: check image linked here The CSS for my grid is as follows: .table{ position: absolute; margin-top: 37em; ...

Issues with loading SCSS modules in NextJS

I'm experiencing some uncertainty regarding the issue at hand, as I have successfully completed this task multiple times in the past without any complications. It's possible that I made an error somewhere along the way. Here are the Product.js co ...

What is the reason behind the change in size and shape of the text when using "overflow: hidden"?

Check out this interactive demo using the provided HTML and CSS: You can view the demo by clicking on this link. /*CSS*/ .header { margin: 0px; padding: 0px; width: 100%; } .headertable { padding: 0px; margin: 0px; width: 100%; border-sp ...

Expanding Side Menu with Material UI Drawer

Can someone provide guidance on implementing a Drawer with expandable menu items using Material UI, similar to the one featured on the material-ui.com website? Here is an example of the desired layout: https://i.sstatic.net/8VqMi.png I am looking for ass ...

Importing images in Typescript is a simple and effective

I came across a helpful solution at this Stackoverflow thread However, I encountered an error: [ts] Types of property 'src' are incompatible. Type 'typeof import("*.png")' is not assignable to type 'string | undefined& ...

How do Box and Grid components differ in Material-UI?

Can you please explain the distinction between Box and Grid in Material-UI? How do I know when to use each one? I'm struggling to understand their differences. ...

Velocity.js causing a slowdown in animated performance

Currently, I am attempting to animate spans, and while the animation is functional, it appears to be somewhat choppy and lacks smoothness. https://codepen.io/pokepim/pen/JBRoay My assumption is that this is due to my use of left/right for animation purpos ...

How can I eliminate the black border-color that appears when the React Material Button outline is clicked, even though I have not explicitly set it?

import React from 'react'; import Button from '@material-ui/core/Button'; export default function NoElevationButton() { return ( <Button variant="contained" color="primary" disableElevation > Disable elevation < ...

Encountering a 404 error when trying to navigate to the next route using the Link component

Having issues with my login route. I've added a Link to the login route inside a button tag in my Navbar component, but when I try to access the route, I'm getting a 404 error page. --app ----pages ------component --------Navbar.js ----- ...

Having trouble with the WordPress style file not functioning properly

I'm currently facing an issue while trying to upload a CSS file and a JavaScript file to a custom theme on WordPress. When I open the webpage, nothing appears and there are no elements displayed. However, when I delete the functions.php file, the webp ...

Getting the external IP address in an Axios request with NodeJS

Is there a way to retrieve the resolved IP address of a remote URL in Node.js by using axios? Please refer to the comment provided below. Thank you in advance! axios.get('http://www.example.com') .then(function (response) { // *** Lookin ...

When creating a list of children in a React app, make sure to assign each child a unique "key" prop for proper rendering

Currently, I am in the process of developing a React Notes application with an API integration. While most functionalities are working flawlessly, I encountered a warning message upon adding a new note: Each child in a list should have a unique "key&q ...

The combination of Electron and MLab creates a powerful synergy that

I am intrigued by using mLab in conjunction with Electron. After reading this article, it appears that MongoDB cannot be packaged into an Electron application. I'm trying to understand what this means and whether mLab would serve the same purpose. Wh ...

What are some methods for testing enzyme, react-virtualized, and material-ui components?

I am facing a unique testing scenario where I need to interact with a component wrapped in TreeView from material-ui that is nested inside the List component from react-virtualized. Here is my approach: wrapper .find(TreeView) .dive() .find(AutoSiz ...