Bulma: Buttons: request: a way to align text contents within the button

Created on 4 Dec 2018  Â·  4Comments  Â·  Source: jgthms/bulma

This is about Bulma button elements as per : https://bulma.io/documentation/elements/button/

Feature request

Overview of the problem

I would like to be able to be able to _align the text within buttons, to the left or right_.

Expected behavior

Buttons would have a documented method to align the contents of the button.
Suggestion: Perhaps, buttons could respond to the helper/modifier CSS classes .has-text-left and .has-text-right.

Actual behavior

Button text can't be aligned using the normal text align helper classes because the text is also centered using flexbox justify-content — at least, not in any documented way that I have found (apologies if I missed it somewhere).

Most helpful comment

Thanks @Lawzy93 I ended up making a quick helper class much like you suggested but specifically targeting the flexbox alignment. I just thought I'd steer clear of modifying the bulma classes for now.

.justify-content-start {
  justify-content: flex-start;
}

All 4 comments

If you add the following CSS, you should be able to make it work.

.button.has-text-left {
    justify-content: flex-start;

}

.button.has-text-right {
    justify-content: flex-end;
}

_DISCLAIMER: I have not fully tested this, and it may break other aspects_

You can use buttons is-right:

<nav class="buttons is-right">
  <a class="button">One</a>
  <a class="button">Two</a>
  <a class="button">Three</a>
</nav>

buttons is-right will align the group of buttons to the right.
It will not, however align the text inside a button to the right.

Ideally, the typography modifier has-text-right would do this, however it does not currently effect flex items.

Thanks @Lawzy93 I ended up making a quick helper class much like you suggested but specifically targeting the flexbox alignment. I just thought I'd steer clear of modifying the bulma classes for now.

.justify-content-start {
  justify-content: flex-start;
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

fundon picture fundon  Â·  3Comments

guillecro picture guillecro  Â·  3Comments

NurdinDev picture NurdinDev  Â·  3Comments

Yard8 picture Yard8  Â·  3Comments

JenCant picture JenCant  Â·  3Comments