---
title: Spacing helpers
layout: documentation
doc-tab: helpers
doc-subtab: helpers-spacing
breadcrumb:
- home
- documentation
- helpers
- helpers-spacing
shortcuts:
margin: m
padding: p
directions:
top: t
right: r
bottom: b
left: l
horizontal: x
vertical: y
values:
0: 0
1: 0.25rem
2: 0.5rem
3: 0.75rem
4: 1rem
5: 1.5rem
6: 3rem
customShortcuts:
margin: mg
customHorizontal: h
customValues:
small: 10px
medium: 30px
large: 60px
---
{% include elements/new-tag.html version="0.9.0" %}
Bulma provides margin m*
and padding p*
helpers in all directions:
-
*t
for top
-
*r
for right
-
*b
for bottom
-
*l
for left
-
*x
horizontally for both left and right
-
*y
vertically for both top and bottom
You need to combine a margin/padding prefix with a direction suffix. For example:
- for a
margin-top
, use mt-*
- for a
padding-bottom
, use pb-*
- for both
margin-left
and margin-right
, use mx-*
Each of these property-direction
combinations needs to be appended with one of 6 value suffixes:
To use these classes, simply append them to any HTML element:
{% highlight html %}
Because every developer has their own preferences, and to satisfy Bulma's customization features, it's possible to specify your own class name shortcuts as well as the spacing values.
For example, if you wanted:
-
margin to be abbreviated to
mg
-
padding to be totally excluded
-
horizontal to be abbreviated to
h
-
vertical to be excluded as well
-
and to only have 3 values: "small" at
10px
, "medium" at 30px
, and "large" at 60px
You can simplify the CSS output by customizing these SCSS variables:
{% highlight scss %}{{ custom }}{% endhighlight %}
{% include
components/spacing-table.html
values=page.customValues
shortcuts=page.customShortcuts
directions=page.directions
horizontal=page.customHorizontal
%}
By customizing the output, you've narrowed down the list of spacing helpers from 84 to only 15.