What is the best way to eliminate the left padding on a TimelineItem component?

When using the Timeline component to display information, there are three columns: TimelinItem, TimelineSeparator, and TimelineContent. I tried setting the padding of TimelineItem to 0 but it didn't work.

The <Trace/> component is a sub-component of <DialogContent> in TraceDialog.js.

In trace.js:

style={{margin:0,padding:0}}
    const useStyles = makeStyles((theme) => ({
      timeline: {
        padding: 0,
        margin: 0,
      },
      content: {
        padding: 0,
        margin: 0
      },
      secondaryTail: {
        backgroundColor: theme.palette.secondary.main,
      },
    }));

export default function Trace (props) {
  const classes = useStyles();
    return (
              details.map((row) => (
              <Timeline key={row.stamp} align="alternate">
                <TimelineItem style={{margin:0,padding:0}}>
                  <TimelineOppositeContent>
                    <Typography variant="caption" color="textSecondary">
                      {TimeFormat(row.time)}
                    </Typography>
                  </TimelineOppositeContent>
                  <TimelineSeparator>
                      <TimelineDot color={row.first ? "primary":"grey"}/>
                      {!row.last ? <TimelineConnector /> : null}
                  </TimelineSeparator>
                  <TimelineContent>
                      <Typography variant="caption" className={classes.content} align="justify">{row.remark}</Typography>
                  </TimelineContent>
                </TimelineItem>
            </Timeline>))
          );
}

In TraceDialog.js:

    const useStyles = makeStyles((theme) => ({
    root: {
        margin: 'auto',
        minHeight: '400px',
        maxHeight: '600px',
    },
  }));

    export default function TraceDialog(props) {
      const classes = useStyles();

    
      return (
        <div>
          <Dialog
            className={classes.root}
            open={openTrace}
            onClose={handleClose}
            scroll='paper'
            fullWidth={true}
            aria-labelledby="scroll-dialog-title"
            aria-describedby="scroll-dialog-description"
          >
            <DialogTitle id="scroll-dialog-title">{'运单号:' + waybillno}</DialogTitle>
            <TraceStepper status={status}/>
            <DialogContent ref={descriptionElementRef} classes={{ MuiDialogContent: '2px,2px' }}>
                <Trace waybillno={waybillno} type={type} extra={extra}/>
            </DialogContent>
            <DialogActions>
              <Button onClick={handleClose} color="primary">
                Exit
              </Button>
            </DialogActions>
          </Dialog>
        </div>
      );
    }

https://i.stack.imgur.com/AFk1E.png

Answer №1

try utilizing the following

<Timeline
         sx={{
          [`& .${timelineItemClasses.root}:before`]: {
              flex: 1,
               margin: 0,
                   },
                   }}> 

.....
</Timeline>

Answer №2

If you want to get rid of the left padding, you will need to customize your MUI styles within trace.js in the TimelineOppositeContent section.


   const useStyles = makeStyles((theme) => ({
         root: {
           flex: 0.2 
         }, 
         timeline: {
           padding: 0,
           margin: 0,
         },
         content: {
           padding: 0,
           margin: 0
         },
         secondaryTail: {
           backgroundColor: theme.palette.secondary.main,
         },
       }));
   
   export default function Trace (props) {
     const classes = useStyles();
       return (
                 details.map((row) => (
                 <Timeline key={row.stamp} align="alternate">
                   <TimelineItem style={{margin:0,padding:0}}>
                     <TimelineOppositeContent className={classes.root}>
   ...

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

Creating a custom `onSubmit` function with Formik, TypeScript, and hooks can be a powerful way

I'm currently creating form onSubmit functions utilizing the useCallback hooks specifically designed for use with the formik library. A sample structure of my component using formik would be as follows: import { useContactForm } from './useCon ...

Having trouble with @mui/icons-material/ShoppingCart in React?

I'm currently working on React version 18.2.0 and I've integrated @mui/icons-material/ShoppingCart into my project. However, I'm facing an issue where the shopping cart icon is not displaying as expected. Here's a snippet of my code: i ...

What exactly does a 'hoisted manifest' mean when it comes to using Yarn?

Encountering an issue while attempting to install a package using yarn, I am receiving the error message: expected hoisted manifest for \"myPackage#@material-ui/core#react-dom\" However, the concept of a 'hoisted manifest' is not entir ...

Do you know of a more streamlined approach to formatting this SCSS code?

Currently working on a Saleor Site and diving into the world of Django and SASS for the first time. While crafting my own styling rules in SCSS files, I've noticed some repetitive code that could potentially be streamlined. It seems like there should ...

Tips on preventing unnecessary rerenders caused by changes in dependencies within useCallback

Since transitioning my VideoPlayer component from a class to a functional component, the crop functionality is not working as expected. The VideoPlayer now utilizes useState for an isVideoPlaying state and includes a function called togglePlayPauseVideo: ...

Adaptable CSS triangle design

Hello I'm looking to create a responsive CSS triangle similar to the image linked below. I attempted using percentages with border width, but didn't achieve the desired outcome. Can anyone suggest a simple solution? https://i.stack.imgur.com/Yah ...

What is the best way to distinguish between various objects that are all in a single line?

After creating an array of objects with data such as name and id, I used the res.json() method to convert it into json format for browser use. However, when I input the array of object data, it looked like this: [ { id: 1, name: 'albany sof ...

Retrieve items within an array of objects in MongoDB using an array of IDs (using the $in operator in aggregation)

In my MongoDB database, I have a collection of stores [ { "_id" : ObjectId("6043adb043707c034d5363b7"), "shopId" : "shopid1", "appId" : "777", "shopItems" : [ { ...

Saving data for editing on a Laravel page can be achieved by leveraging the powerful features

I have implemented my create page using vue.js. I called the vue.js file using a component. Now, for the edit page, I followed the same procedure by calling the vue component in the blade. However, I am unsure how to save data for the edit page. Can anyone ...

Which takes precedence: the end of the script tag or the backtick?

Currently, I am working on developing a page builder widget. My goal is to save the entirety of the HTML code for the edited page to both local storage and a database. The PHP script will load the saved HTML from the database, while JavaScript will handle ...

Server-side rendering issue arises post updating to Material UI 5 (with Next.js)

After upgrading my app with server-side rendering (SSR) from version 4 to version 5 of MUI, I encountered an issue. Despite following the official migration guide, I found that when JavaScript was disabled, the page rendered as raw HTML without any CSS sty ...

What is the easiest way to set up a local server for deployment?

I am currently working on a research project with unique requirements that involve using private data which cannot be shared online. However, I need to create a demonstration where this data could potentially be accessed online as part of a proof of concep ...

Trouble with CSS table background display in Outlook

I am experiencing issues with an HTML table in an email template: <table id="x_formHeaderTable" style="width:100%; margin:0; padding:0; background-color:#FCE68D; border-style: solid; border-color: #000000;"> <tbody> <tr> &l ...

Using jQuery to dynamically change the CSS color based on the background-color of a checkbox label

When a checkbox is selected, the function below runs to change the text color to white or black based on the darkness of the background color. However, the third checkbox should trigger this change to white but currently does not. function isDark(color) { ...

Achieve the highest character count possible within HTML elements

Is it possible for a standard HTML element with defined width and height to manage characters using JavaScript, as shown in the code snippet below? <div id="text-habdler-with-width-and-height" ></div> <script> $("element& ...

extract the key identifier from the JSON reply

My JSON ResponseData example for form0 is provided below: { "MaterialType": "camera", "AssetID": 202773, "forms": [ { "release": "asyncCmd/accessCameraMulti", "action": "rest/Asset/202773/cameraAccessMultiple", ...

Implementing Object Value Assignment to an Element Using jQuery

I recently received a set of data via an API request: https://i.stack.imgur.com/YGe2D.jpg In order to display this data as selectable options, I included the following code snippet in my AJAX script: $.each($(value.routes), function(index, route){ $ ...

The last-of-type pseudo-class in Material-UI (MUI)

I'm attempting to apply a margin of 100px to the last <NotificationContainer> component. Unfortunately, the code snippet I have included is not achieving this desired effect. My project is being developed using MUI5. const Container = styled(&ap ...

The process of displaying a Login form on the Home page

Is it possible to display the React bootstrap login form on the same home page without redirecting to a new /login page? Basically, I want to disable all current page activities (like clicking and scrolling) when the user clicks on the Login link, and onl ...

Tips for Choosing a Tab in angular-ui: AngularJS

Is there a way to select the last tab without using ng-repeat? I want to avoid using ng-repeat but still need to select tabs. Any suggestions? If you'd like to see the code in action, you can visit: http://plnkr.co/edit/ZJNaAVDBrbr1JjooVMFj?p=preview ...