bulma-helpers
v0.4.3
Published
Library with missing Functional / Atomic CSS classes for Bulma framework.
Downloads
10,682
Maintainers
Readme
bulma-helpers
Library with missing Functional / Atomic CSS classes for Bulma framework, which doesn't require Bulma framework to work
- bulma-helpers
No installation (CDN)
You can use Bulma Helpers without installation directly from cdnjs. Just import file bulma-helpers.min.css
:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma-helpers/0.4.0/css/bulma-helpers.min.css" integrity="sha512-U6ELnUi7oqVEjkLmFw5r5UR5LEtvpImS/jUykBKneVhD0lxZxfJZ3k3pe003ktrtNZYungd9u3Urp2X09wKwXg==" crossorigin="anonymous" />
Link to library on cdnjs:
https://cdnjs.com/libraries/bulma-helpers
Quick install
Installation is nearly the same as pure Bulma framework.
NPM
npm install bulma-helpers
or
Yarn
yarn add bulma-helpers
Import
After installation, you can import the CSS file into your project using this snippet:
import 'bulma-helpers/css/bulma-helpers.min.css'
Compatibility with Bulma
Bulma-helpers library complies with Bulma convention of naming classes. Most of classes are of the is-*
and has-*
type. Example:
.is-borderless
or
.has-padding-top-5
One exception are pure Flexbox classes, which names just reflect modifiers. Example:
.flex-row
or
.align-center
Compatibility with other CSS frameworks
You can use Bulma-helpers with any other CSS framework or even as a standalone library, if you want to write Functional / Atomic CSS code. Keep in mind that Bulma-helpers library bases on Sass, so you will need basic knowledge of Sass to customize the library.
CSS only
Bulma-helpers, equally to Bulma, is a CSS library. As such, the sole output is a single CSS file: bulma-helpers.css
You can either use that file, "out of the box", or download the Sass source files to customize the variables or choose which modules do you want to use.
There is no JavaScript included.
Browser Support
Bulma-helpers, equally to Bulma, uses autoprefixer to make (most) Flexbox features compatible with earlier browser versions. According to Can I use, Bulma is compatible with recent versions of:
- Chrome
- Edge
- Firefox
- Opera
- Safari
Internet Explorer (10+) is only partially supported.
Customization
All modules are toggled on and all variables have some values by default. You can customize these values by assigning your values to variables, defined in the library. All available variables you can find in corresponding files in variables
directory. Toggling off media queries (variables for this you can find in sass/helpers/variables/media-queries.sass
, for example $enable-flex-media-queries
) will decrease size of the library dramatically.
Instruction
- Make sure you have
node-sass
installed. If not, install it. (npm install node-sass --save-dev
) - Create script for compiliting
SCSS
toCSS
, i.e."customize-css": "node-sass --omit-source-map-url ./src/scss/bulma-helpers-customization.scss ./src/css/bulma-helpers-customization.css"
. Add this script toscripts
section inpackage.json
. As you can see in script, our file in which we will customizebulma-helpers
is calledbulma-helpers-customization.scss
. The resultCSS
output will be inbulma-helpers-customization.css
(notice the different extension of file). - Create
SCSS
file in which you will customizebulma-helpers
variables (i.e.scss/bulma-helpers-customization.scss
) - Define variables which you want to override, before importing
bulma-helpers
in created file.
Example content of file with customization:
@charset "utf-8";
$sizing-range-start: 1;
$sizing-range-end: 666;
$sizing-interval: 6;
@import "../../node_modules/bulma-helpers/bulma-helpers.sass";
- Run compiling script to build new
css
file, i.e.npm run customize-css
- Import result file (in this example -
bulma-helpers-customization.css
) in your scss file, i.e.@import "css/bulma-helpers-customization.css";
Customizing unit
Default unit in code and in this README is px
, but you can change it to any unit, for example em
or rem
. Change will be global for all helpers.
$default-unit: 'px' !default
Customizing ranges of generated classes
For all generated classes (such as has-margin-bottom-*
, where *
is value from given range) there is a simple way to change range and interval of generated classes. You can change the following variables in corresponding sass files. All variables follow the same pattern, shown below.
$sizing-range-start: 50 !default
$sizing-range-end: 400 !default
$sizing-interval: 50 !default
We've got name of customized value
, such as sizing
or spacing
, then variable's meaning, such as range-start
, range-end
and interval
.
For media queries, the rule is the same. The only difference is that rest of variable's name is preceded by mq
.
$mq-sizing-range-start: 50 !default
$mq-sizing-range-end: 400 !default
$mq-sizing-interval: 50 !default
Customizing media queries
You can decide whether you want to include media queries in your project or not. In variables/media-queries.sass
file you can find variables which allows you to customize your Bulma-helpers. All of defined variables are built on top of the following pattern:
$enable-media-queries: true !default
This variables enables/disables all media queries in the project.
For choosing certain modules, such as max/min width/height sizing media queries, you can assign a value to variables such as:
$enable-sizing-max-min-width-height-media-queries: true !default
Customizing breakpoints
Breakpoints are same as default breakpoints in Bulma. If you want to change them, then just override the same breakpoint variables as in Bulma, for example:
$tablet: 800px
Customizing spacing units
Units for the spacing and media query spacing helpers are using pixels by default. If you want to generate classes for additional units (such as rem or em), override the list of unit variables, which allows for a single unit or list of units. For example:
$additional-spacing-units: 'rem' 'em'
Generated spacing and media query classes for the above configuration will result in new spacing classes appended with -rem
or -em
. For example, has-margin-5-rem
and has-margin-5-em
.
Choosing modules
By default, all modules are included in result build. Even so, you can decide on your own which modules do you want to use in your project.
To achieve this, you have to remove unwanted sass modules imports from main _all.sass
files in helpers directory or remove single file imports from _all.sass
in corresponding modules directories.
Documentation
All customization variables
// --- MEDIA QUERIES
// ALL
$enable-media-queries: true !default // set to false if you don't want to include media queries at all
// spacing - MARGIN / PADDING
$enable-spacing-media-queries: true !default // set to false if you don't want to include ALL MARGIN / PADDING media queries
// sizing - WIDTH / HEIGHT
$enable-sizing-media-queries: true !default // set to false if you don't want to include ALL WIDTH / HEIGHT media queries
$enable-sizing-width-height-media-queries: true !default // set to false if you don't want to include WIDTH / HEIGHT
$enable-sizing-max-min-width-height-media-queries: true !default // set to false if you don't want to include MAX-WIDTH / MAX-HEIGHT / MIN-WIDTH / MIN-HEIGHT
$enable-sizing-misc-media-queries: true !default // set to false if you don't want to include OTHERS
// flex
$enable-flex-media-queries: true !default // set to false if you don't want to include FLEXBOX media queries
$enable-flex-core-media-queries: true !default // set to false if you don't want to include FLEXBOX CORE
$enable-flex-align-self-items-media-queries: true !default // set to false if you don't want to include ALIGN-SELF / ALIGN-ITEMS
$enable-flex-align-justify-media-queries: true !default // set to false if you don't want to include ALIGN-CONTENT / JUSTIFY-CONTENT
// --- BREAKPOINTS - Default values of responsiveness breakpoints. They are equal to Bulma v0.7.2 breakpoints.
// The container horizontal gap, which acts as the offset for breakpoints
$gap: 64px !default
// 960, 1152, and 1344 have been chosen because they are divisible by both 12 and 16
$tablet: 769px !default
// 960px container + 4rem
$desktop: 960px + (2 * $gap) !default
// 1152px container + 4rem
$widescreen: 1152px + (2 * $gap) !default
$widescreen-enabled: true !default
// 1344px container + 4rem
$fullhd: 1344px + (2 * $gap) !default
$fullhd-enabled: true !default
// --- WIDTH / HEIGHT
$sizing-range-start: 50 !default // from this value WIDTH / HEIGHT classes will be generated (i.e. has-width-50)
$sizing-range-end: 400 !default // to this value will be generated WIDTH / HEIGHT classes (i.e. has-height-400)
$sizing-interval: 50 !default // this will be gap between previous and next class (i.e. has-width-50, has-width-100, has-width-150 and so on)
$sizing-max-min-width-height-range-start: $sizing-range-start !default // from this value MAX / MIN WIDTH / HEIGHT classes will be generated (i.e. has-max-width-50)
$sizing-max-min-width-height-range-end: $sizing-range-end !default // to this value will be generated WIDTH / HEIGHT classes (i.e. has-min-height-400)
$sizing-max-min-width-height-interval: $sizing-interval !default // this will be gap between previous and next class (i.e. has-min-width-50, has-min-width-100, has-min-width-150 and so on)
$mq-sizing-range-start: $sizing-range-start !default // from this value WIDTH / HEIGHT classes will be generated for media queries (i.e. .has-width-50-mobile)
$mq-sizing-range-end: $sizing-range-end !default // to this value will be generated WIDTH / HEIGHT classes (i.e. has-height-400-tablet)
$mq-sizing-interval: $sizing-interval !default // this will be gap between previous and next class (i.e. has-width-50-mobile, has-width-100-mobile, has-width-150-mobile and so on)
$mq-sizing-max-min-width-height-range-start: $sizing-max-min-width-height-range-start !default // from this value MAX / MIN WIDTH / HEIGHT classes will be generated for media queries (i.e. has-max-width-50-tablet)
$mq-sizing-max-min-width-height-range-end: $sizing-max-min-width-height-range-end !default // to this value will be generated WIDTH / HEIGHT classes (i.e. has-min-height-400-fullhd)
$mq-sizing-max-min-width-height-interval: $sizing-max-min-width-height-interval !default // this will be gap between previous and next class (i.e. has-min-width-50-fullhd, has-min-width-50-fullhd, has-min-width-50-fullhd and so on)
// --- MARGIN / PADDING
$spacing-range-start: 5 !default // from this value MARGIN / PADDING classes will be generated (i.e. has-margin-5)
$spacing-range-end: 150 !default // to this value will be generated MARGIN / PADDING classes (i.e. has-padding-150)
$spacing-interval: 5 !default // this will be gap between previous and next class (i.e. has-padding-5, has-padding-10, has-padding-15 and so on)
$mq-spacing-range-start: $spacing-range-start !default // from this value MARGIN / PADDING classes will be generated for media queries (i.e. .has-margin-5-mobile)
$mq-spacing-range-end: $spacing-range-end !default // to this value will be generated MARGIN / PADDING classes (i.e. has-padding-150-tablet)
$mq-spacing-interval: $spacing-interval !default // this will be gap between previous and next class (i.e. has-padding-5-mobile, has-padding-10-mobile, has-padding-15-mobile and so on)
$additional-spacing-units: () !default // this can be configured with additional unit type(s) to use for the spacing and media query spacing helpers
All values are represented by pixels with the exception for the spacing helpers, which allows for configuration of additional units, so e.g. has-max-width-50
class means that this element's maximal width is 50px.
Spacing
Margin
Margin
.has-margin-5
gives
margin: 5px !important
Margin for one side
.has-margin-top-5
gives
margin-top: 5px !important
All available sides
- top
- right
- bottom
- left
Default available spacing values
(5, 10, 15, ..., 150)
Padding
In the same way as above for margin.
Padding
.has-padding-5
Padding for one side
.has-padding-top-5
All available sides
- top
- right
- bottom
- left
Default available spacing values
(5, 10, 15, ..., 150)
Sizing
Width
.has-width-50
gives
width: 50px !important
Height
.has-height-50
Default available sizing values
(50, 100, 150, ..., 400)
Max / min width / height
Max width
.has-max-width-50
gives
width: 50px !important
Min height
.has-min-height-50
gives
min-height: 50px !important
Default available sizing values
(50, 100, 150, ..., 400)
Fraction width / height
Full width
.is-full-width
gives
width: 100% !important
.is-half-height
gives
height: 50% !important
Default available sizing values
full (100%), half (50%), quarter (25%)
Full page width / height
Full page width
.has-page-width
gives
width: 100vw !important
Default available sizing values
full (100vw/vh), half (50vw/vh), quarter (25vw/vh)
Media queries
By default, media queries for sizing and spacing are toggled on. You can use media queries in exactly the same as in Bulma framework. Just add postfix to classname with breakpoints name, such as -mobile
or -widescreen-only
.
Default breakpoints
There are few defined breakpoints - mobile, tablet, tablet-only, touch, desktop, desktop-only, widescreen, widescreen-only, fullhd. Everything as in Bulma! You can read more here.
$gap: 64px !default
$tablet: 769px !default
$desktop: 960px + (2 * $gap) !default
$widescreen: 1152px + (2 * $gap) !default
$widescreen-enabled: true !default
$fullhd: 1344px + (2 * $gap) !default
$fullhd-enabled: true !default
Margin
Margin
.has-margin-5-mobile
Margin for one side
.has-margin-top-5-tablet
All available sides
- top
- right
- bottom
- left
Default available spacing values
(5, 10, 15, ..., 150)
Padding
In the same way as above for margin.
Padding
.has-padding-5-fullhd
Padding for one side
.has-padding-top-5-widescreen
All available sides
- top
- right
- bottom
- left
Default available spacing values
(5, 10, 15, ..., 150)
Flex
For all flex classes you can do all the responsive things. For example:
.flex-mobile
.justify-center-desktop
Sizing
Width
.has-width-50-touch
Height
.has-height-50-mobile
Default available sizing values
(50, 100, 150, ..., 400)
Max / min width / height
Max width
.has-max-width-50-desktop
Min height
.has-min-height-50-mobile
Default available sizing values
(50, 100, 150, ..., 400)
Fraction width / height
Full width
.is-full-width-tablet
.is-half-height-widescreen
Default available sizing values
full (100%), half (50%), quarter (25%)
Full page width / height
Full page width
.has-page-width-mobile
Default available sizing values
full (100vw/vh), half (50vw/vh), quarter (25vw/vh)
Flex
Names of classes reflect modifiers. There are modifiers for:
- row
- column
- align-content
- justify-content
- align-self
- align-items
- wrap
Examples:
Row
.flex-row
Column
.flex-column
Align content start
.align-start
Justify content center
.justify-center
Align self baseline
.align-self-baseline
Align items flex-end
.align-items-flex-end
Nowrap
.nowrap
Border
Borderless
.is-borderless
Completely borderless
Makes cascade of borderless (applies lack of border to all tr, td and th in the table).
.is-completely-borderless
Border width
.has-border-width-3
gives
border-width: 3px !important
Border width for one side
.has-border-top-width-3
gives
border-top-width: 3px !important
All available sides
- top
- right
- bottom
- left
Default available sizing values
(1, 2, 3, ..., 10)
Cursor
Cursor's style
.has-cursor-pointer
gives
cursor: pointer !important
All available cursors
- pointer
- grab
- help
- wait
- crosshair
- not-allowed
- zoom-in
- default
Misc
Blur
.is-blurred
gives
filter: blur(15px) !important
Blur medium
.is-blurred-medium
gives
filter: blur(40px) !important
Blur hard
.is-blurred-hard
gives
filter: blur(75px) !important
Default values for blurs
(15px, 40px, 75px)
Copyright and license
Code copyright 2018 Jędrzej Maczan. Code released under the MIT license. README bases on Bulma README file.