Buttons

Star
The Trowel project is abandonned. Trowel core and the Trowel components are no more maintained or supported. More infos

Download

You can fetch Trowel Buttons with npm, yarn or bower.

# With bower
$ bower install --save trowel-buttons

# With npm
$ npm install --save trowel-buttons

# With yarn
$ yarn add trowel-buttons

You can also download a zip archive right here.

Installation

SCSS

The main scss file to include to your main .scss file is located at the ./src/scss/buttons.scss. As a Trowel Component, it also requires two dependencies to compile the scss code. Here an scss installation snippet.

// Trowel core (need to be imported first)
@import './path/to/dependencies/trowel-core/src/trowel';

// Trowel Component Buttons
@import './path/to/dependencies/trowel-buttons/src/scss/buttons';

Usage

Tags

You can put the .btn classes <a>, <button> and <input> DOM elements.

Link
<a class="btn btn--default" href="#" role="button">Link</a>
<button class="btn btn--default" type="submit">Button</button>
<input class="btn btn--default" type="button" value="Input">
<input class="btn btn--default" type="submit" value="Submit">

Sizes

By default you have 4 sizes availables :

Here, the sizes are just made with the `$button--font-size` variable : we create a default value, and 3 modifiers flags value. Padding are made with `em` units, so it scales to the font-size value.

  <button class="btn btn--default btn--lg">button lg</button>
  <button class="btn btn--default">button md</button>
  <button class="btn btn--default btn--sm">button sm</button>
  <button class="btn btn--default btn--xs">button xs</button>

Themes

By default you have 6 different themes for the .btn.

The themes are designed with the variables $button--color, $button--border-color and $button--background-color.

<button class="btn btn--default">default</button>
<button class="btn btn--primary">primary</button>
<button class="btn btn--success">success</button>
<button class="btn btn--warning">warning</button>
<button class="btn btn--danger">danger</button>
<button class="btn btn--link">link</button>

Block

You can make the button size equal to its container size with the .btn--block class.

this class is designed with a modifier flag on two trowel variables : ` $button--display` as `block`, and `$button--width` as `100%`.

<button class="btn btn--primary btn--block">btn block</button>

Btn group

You can group button by just wrapping them in a .btn-group DOM element

The btn-group is design with flexbox. Check out the btn-groups variables to custom its behavior.

<div class="btn-group">
  <button class="btn btn--default">first button</button>
  <button class="btn btn--default">second button</button>
  <button class="btn btn--default">third button</button>
</div>

Sass reference

Syntax variables

You can override the global syntax config for a specific component with the following variables

VARIABLE DEFAULT VALUE DESCRIPTION
$button--syntax null syntax config for .btn

Enables

You can avoid the generation of some css with the following variables

VARIABLE DEFAULT VALUE DESCRIPTION
$buttongroup--enabled true enable the generation of style rules for the .btn-group block

Component variables

VARIABLE DEFAULT VALUE DESCRIPTION
 $button--vertical-align  middle sets the vertical-align property 
 $button--float  null sets the float property 
 $button--display  (
  'default': inline-block,
  '-block': block,
)
sets the display property 
 $button--border-width  1px sets the float property 
 $button--padding  0.65em 1.65em sets the padding property 
 $button--width  (
  '-block': 100%,
)
sets the padding property 
 $button--margin  null sets the margin property 
 $button--height  null sets the height property 
 $button--color  (
  'default': rgb(31, 13, 51),
  '-primary': rgb(255, 255, 255),
  '-success': rgb(255, 255, 255),
  '-warning': rgb(255, 255, 255),
  '-danger': rgb(255, 255, 255),
)
sets the color property 
 $button--border-color  (
  'default': currentColor,
  '-primary': transparent,
  '-success': transparent,
  '-warning': transparent,
  '-danger': transparent,
  '-link': transparent,
)
sets the border-color property 
 $button--background-color  (
  'default': (
    'default': rgb(255, 255, 255) darken(rgb(255, 255, 255), 10%),
    '[disabled="true"': rgb(255, 255, 255) rgb(255, 255, 255),
  ),
  '-primary': (
    'default': rgb(31, 13, 51) darken(rgb(31, 13, 51), 10%),
    '[disabled="true"': rgb(31, 13, 51) rgb(31, 13, 51),
  ),
  '-success': (
    'default': rgb(55, 211, 189) darken(rgb(55, 211, 189), 10%),
    '[disabled="true"': rgb(55, 211, 189) rgb(55, 211, 189),
  ),
  '-warning': (
    'default': rgb(255, 176, 0) darken(rgb(255, 176, 0), 10%),
    '[disabled="true"': rgb(255, 176, 0) rgb(255, 176, 0),
  ),
  '-danger': (
    'default': rgb(253, 65, 100) darken(rgb(253, 65, 100), 10%),
    '[disabled="true"': rgb(253, 65, 100) rgb(253, 65, 100),
  ),
  '-link': (
    'default': (transparent, transparent),
  )
)
sets the background-color property 
 $button--opacity  (
  '[disabled="true"': 0.5,
)
sets the opacity property 
 $button--font-size  (
  'default':  1rem,
  '-lg': 1.2rem,
  '-sm': 0.8rem,
  '-xs': 0.65rem,
)
sets the font-size property 
 $button--text-decoration  (
  'default': none,
  '-link': (
    ':hover': (
      'default': underline,
      '[disabled="true"': none,
    ),
  )
)
sets the text-decoration property 
$button--line-height 1.2 sets the line-height property
$button--text-align center sets the text-align property
$button--font-family 'Open Sans', verdana, sans-serif sets the font-family property
$button--font-weight null sets the font-weight property
$button--text-transform null sets the text-transform property
$button--letter-spacing null sets the letter-spacing property
$button--border-radius 0.2em sets the border-radius property
$button--border-style solid sets the border-style property
$button--box-shadow null sets the box-shadow property
$button--transition null sets the transition property
$button--cursor null sets the cursor property

Btn-groups

VARIABLE DEFAULT VALUE DESCRIPTION
 $buttongroup--justify-content  null sets the justify-content property on block .btn-group 
 $buttongroup-item--flex-grow  null sets the flex-grow property on a .btn inside a .btn-group block