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

How can I fix the issue where Sx is not converting the styles to CSS format for the fill property exclusively?

The primary-main is supposed to change color to something like #abcdefg, but it seems to be stuck displaying primary-main as is. I am working with angular MUI + React ...

Is it possible to utilize the same database connection for multiple routes in an

I have taken inspiration from Express's route-separation example and created a Node.js app. Now, I aim to enhance it by integrating the MongoDB driver Mongoose for listing Users and Kittens. var express = require('express'); var app = expre ...

Show only the items in bootstrap-vue b-table when a filter is actively applied

How can I set my bootstrap-vue b-table to only show items when a filter is applied by the user (i.e., entered a value into the input)? For example, if "filteredItems" doesn't exist, then display nothing? This is primarily to prevent rendering all rows ...

What exactly does the <cbn-root> HTML element signify, and how can it be parsed using Java programming language?

I attempted to develop a Java program to monitor the availability of reserved spots on this website: However, when I examine the page source using Chrome or Edge, only <cbn-root></cbn-root> is displayed in the body section. Yet, utilizing Chro ...

What is the process for appending a component to window.location.href?

I am working on implementing unique custom URLs for each item based on user interaction. After a user clicks "View Item", I want to redirect them to a URL that includes the item's name and ID, like this: "http://localhost:3000/item-1/-MC_xbIMm8zctEWRJ ...

Difficulty: Issue with displaying Backbone collection using Mustache template

I'm new to backbone js and Mustache. I want to load a backbone collection on page load from rails json object to avoid making an extra call. However, I'm facing issues when trying to render the backbone collection using a mustache template. Here ...

What causes the difference in behavior of nodejs function arguments when explicitly called?

As I refactor my nodejs application to improve code readability, I encountered an issue when calling a function directly. The following code works perfectly: router.route('/').get(({ query }, res, next) => { ItemsLogic.getItems(query) .the ...

clicking on internal links in the bootstrap side menu causes it to jump

Im trying to add a side menu to a help page. The menu and internal links are functioning properly, but when clicked, the side menu partially goes behind the navbar. As a beginner, I'm not sure how to resolve this issue. Can someone offer some guidan ...

Error: The function named 'setValues' has already been declared

Looking for some guidance with an error message that involves the 'setValues' declaration in my code. I've come across similar questions and answers, but I'm still unsure about what changes I need to make. Your input would be highly app ...

The shadows and bottom of Material-ui Card component are cut off if placed inside a GridList

I have been working on creating a grid layout with material-ui Cards using the Grid List component. Unfortunately, when I try to place the card within it, the bottom and shadow of the card get cut off. It seems like a simple CSS issue, but I'm having ...

React components are failing to display data as expected

I need to display certain data based on the id provided in the url. When I use console.log() with res.json, I can see the data but I'm unsure how to pass it to the 'articleComponent'. const Articles = () => { const query = (id) => ...

Displaying a mouse cursor using an A-frame function

I am presently working on a scene using A-frame () in which I have hidden the mouse pointer. Is there a way for me to set it up so that when a specific function is triggered, the mouse pointer will show, and when another function is executed, the mouse poi ...

Encountered an error with NEXT JS: npm ERR! - error code ERR_SOCKET

npm ERR! code ERR_SOCKET_TIMEOUT npm ERR! network Socket timeout npm ERR! network This issue is related to problems with your network connectivity. npm ERR! network Typically, being behind a proxy or having incorrect network settings can cause this error. ...

Creating clones of <li> elements using JQuery and appending them to the end of a <ul> list

I have a regular ul li list and I am looking to add an additional li based on the first one in the list. Here is the HTML: <div id="gallery"> <ul> <li>Point Nr 1<p>lol</p></li> <li>Point Nr 2</li> <li> ...

When using Node.js, you may encounter the error message: "TypeError: brevo.ApiClient is not a constructor

My goal is to set up an automatic email sending system that, upon receiving details like name and email, will send a confirmation email to the provided email address with the message "subscribed." I've been working on this task for about 7 hours strai ...

Generate checkboxes by utilizing the JSON data

Here is a snippet of my JSON data: [ { "type": "quant", "name": "horizontalError", "prop": [ 0.12, 12.9 ] }, { "type": "categor", "name": "magType", "prop": [ ...

The simple method for incorporating line feed in <s:textarea>

Hey there, I'm currently utilizing struts 2 UI and I seek a means to restrict the number of characters in each row to only 16. Additionally, I want to impose a maximum length limit of 32 characters. Despite my attempts using the 'row' and &a ...

Is it possible to execute custom Javascript code when navigating forwards or backwards on a webpage?

My main goal is to recreate the back button functionality using AJAX without needing to add #uglyhashes to every URL, as many solutions currently do. (Just to clarify, I am completely okay with a solution that doesn't support Internet Explorer at all ...

Tips on automatically changing the background image every few seconds

As a newcomer to Angular and programming in general, I am facing an issue with changing the background image of my Page using the setInterval method. The intended behavior is for it to change every second, but for some reason, it changes much faster than t ...

Guide on extracting data from an HTML table column and saving it to a JavaScript array with the help of JQuery

Suppose there is a table column containing 10 rows, each with <td id="num"> and some text value. Is there a way to utilize JQuery in order to iterate through every row within the column and store the values in a JavaScript array? I attempted the co ...