question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[docs] Horizontal centering example doesn't work in codesandbox

See original GitHub issue

In the documentation, the example for “Horizontal centering” apparently works there, but if you try it on Codesandbox or Stackblitz, the text is left-justified.

The problem can be corrected by adding style={{display:"flex"}} to the surrounding div tag, or replacing it with <Box display="flex">. I found that out in a Medium post.

In general, it is a confusing issue of why mx="auto" works in some places and not others, and some explanation would be helpful.

I have been able to use the align property of <Grid>, but it does not seem be documented; presumably it’s just a synonym for alignItems.

While I’m at it, there was no obvious option for documentation issues, so I submitted it here.

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

The “Centered element” text is not centered if you follow the Codesandox link from the doc page above. I had the same experience with the “Edit in Stackblitz.”

Expected Behavior 🤔

It should be centered.

Steps to Reproduce 🕹

Steps:

  1. Use links above.

Context 🔦

Trying to center a button within a Grid item, and various other centering problems.

Your Environment 🌎

Running in Chrome browser.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
viditrv123commented, Apr 16, 2021

I have made few changes that might be correct. Please check #25787

0reactions
natkuhncommented, Jan 27, 2021

Oddly, when I go to the example now, the background of every example has changed, so that the rectangular box no longer appears.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[docs] Horizontal centering example doesn't work in ... - GitHub
I am trying to bring to your attention that the the margin auto demonstration that you provide do not work in the Codesandbox...
Read more >
Centering a block or Image - CodeSandbox
Center the div or other block-level-elements with Content inside it ... Create a banner and align items (vertical + horizontal) inside it to...
Read more >
How to align primary and secondary text horizontally and not ...
I managed to get the desired output using a few other elements and referring the material-ui documentation. here is a working example: ...
Read more >
Material UI AppBar - React Navbar Examples
See the above example. Material UI's Toolbar component. The AppBar doesn't actually set any of the properties of the children to make them...
Read more >
How to use Tailwind CSS in React to configure Create React ...
We demonstrate how to get Tailwind CSS working inside a CRA-based React project without having to eject Create React App.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found