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.

Is there a way to center the text of the snackbar?

See original GitHub issue

Hi there, I am trying to replicate this snackbar:

image

but setting text-align or justify-content doesn’t do the work. I also tried adding a Text tag as children but the result doesn’t change. Is there a way to achieve this?

This is the code for my snackbar and styles:

image image image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
lukewalczakcommented, May 18, 2021

Hey @SantyLorenzo, you can do that by passing Text component with style: {{textAlign: 'center'}} as a children into Snackbar. Please look at the snack example.

2reactions
Karemhzcommented, Mar 7, 2022

@SantyLorenzo This snack appears to be working. Have a look. The material design specs specify that the text should be left aligned, thats propbably why this library does not provide a simple option to center the text.

Didn’t work on android

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Snackbar TextAlignment in Center - Stack Overflow
Try following code it's work for set snackbar text in center: Snackbar snackbar = Snackbar.make(main_layout, "This is snack", Snackbar.
Read more >
align center mdl-snackbar - CodePen
Adding Classes. In CodePen, whatever you write in the HTML editor is what goes within the <body> tags in a basic HTML5 template....
Read more >
Center Text On Snack Bar - StackBlitz
Editor Preview Both. Sign in. Project. Search. Settings. Switch to Light Theme. Enter Zen Mode. Project. Download Project. Info. Center Text On Snack...
Read more >
How To Create a Snackbar / Toast - W3Schools
Click on the button to show the snackbar. It will disappear after 3 seconds. Show Snackbar. Some text some message.. Create a Snackbar....
Read more >
React Snackbar component - Material UI - MUI
In wide layouts, snackbars can be left-aligned or center-aligned if they are consistently placed on the same spot at the bottom of the...
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