I have a Stack of Avatars, with text:
<Stack>
<span><Avatar sx={{ float:'left', width: 30, height: 30, margin: 1, backgroundColor: '#c00500' }} variant="square">C</Avatar>Today</span>
<span><Avatar sx={{ float:'left', width: 30, height: 30, margin: 1, backgroundColor: '#05C000' }} variant="square">V</Avatar>Yesterday</span>
<span><Avatar sx={{ float:'left', width: 30, height: 30, margin: 1, backgroundColor: '#c00500' }} variant="square">C</Avatar>Yesterday</span>
</Stack>
I’d like to have a dotted line joining the boxes like this:
How can I achieve this effect?
2
Answers
I think you can’t really do this with MUI, maybe create a div inside the div containing everything, and make it be the dashed line, make position absolute and place it in the way you need, but make sure the container div has position relative.
The best way of achieving a similar result is by using the MUI Stepper component. See https://mui.com/material-ui/react-stepper/. The two modifications you’d need to make are:
orientation="vertical"
The approach to implement the custom component involves modifying the CSS of the pre-existing
<StepConnector />
element. A sample of the implementation is shown below (I also added the code to a sandbox for a better preview. See https://codesandbox.io/p/sandbox/verticaldashedmuistepper-5rnyr5. ):Upvote and accept the answer if it worked! Thanks 🙂