Buttons
Creating Buttons
- Use a
<button>HTML element - Apply the
buttonclass to an<a>HTML element
Disabling Buttons
- Apply the disabled HTML attribute
<button disabled> - Apply the
disabledclass
A link styled as a button can only appear disabled by assigning the disabled class. The link will still work. HTML links do not support a disabled attribute.
ButtonGroup
Place a group of buttons in a buttonGroup container. ButtonGroup changes to a column layout responsively.
Further control of the button layout is possible with additional classes:
noGapcolumn(vertical layout)leftcenterright
When paired with an action button (ex: Cancel / Save), use a buttonGroup container, and make the red action a ghost or flat style button.
Place the committing action last (to the right/bottom).
BLUE Buttons: Non-Committing Actions; Links; Modal & Intermediary Steps
Use blue buttons for non-committing actions like links to products or other content. Think of a blue button as a regular link, but with more visual importance.
Calls to action like 'Buy This Product' or 'Sign Up' could be blue or green buttons. Use the following as a guide:
- Use a blue button if the button leads to a form or page with the product or sign up form
- Use a blue button if the button is a step in a process
- Use a blue button if the button commits and closes a modal window
- Use a green button on the page or form where the action is taken (the 'Add to Cart' or 'Join' button of the form)
Tiny
| Default | ||
|---|---|---|
| Ghost | ||
| Flat |
Small
| Default | ||
|---|---|---|
| Ghost | ||
| Flat |
Regular
| Default | ||
|---|---|---|
| Ghost | ||
| Flat |
Large
| Default | ||
|---|---|---|
| Ghost | ||
| Flat |
GREEN Buttons: Primary & Committing Actions
Use green buttons for commiting actions like adding an item to a cart, submitting a form, or completing a task. Generally, tapping a green button will lead to a result like a confirmation page, results of a report, or a next step.
A page should usually only have one green button. Modal windows are committed with a blue button. Semantic submit buttons should always be green.
Calls to action like 'Buy This Product' or 'Sign Up' could be blue or green buttons. Use the following as a guide:
- Use a blue button if the button leads to a form or page with the product or sign up form
- Use a blue button if the button is a step in a process
- Use a blue button if the button commits and closes a modal window
- Use a green button on the page or form where the action is taken (the 'Add to Cart' or 'Join' button of the form)
Tiny
| Default | ||
|---|---|---|
| Ghost | ||
| Flat |
Small
| Default | ||
|---|---|---|
| Ghost | ||
| Flat |
Regular
| Default | ||
|---|---|---|
| Ghost | ||
| Flat |
Large
| Default | ||
|---|---|---|
| Ghost | ||
| Flat |
RED Buttons: Cancel or Destructive Actions
Use red buttons for canceling, aborting, or deleting actions. A user should approach a red button with caution.
When paired with an action button (ex: Cancel / Save), use a buttonGroup
Tiny
| Default | ||
|---|---|---|
| Ghost | ||
| Flat |
Small
| Default | ||
|---|---|---|
| Ghost | ||
| Flat |
Regular
| Default | ||
|---|---|---|
| Ghost | ||
| Flat |
Large
| Default | ||
|---|---|---|
| Ghost | ||
| Flat |
Standard Button With Icon
-
Assign
class='button flex'to the button element or a .button link- Note that an
<a class='button flex'>will be givendisplay: inline-flex
- Note that an
- Place an
<img/svg>as a child of the button element -
Encapsulate the text of the button within a
<div>as a child of the button element to prevent unexpected wrapping (the div will getflex-shrink: 0from the button.flex class) -
Define specific styling via a class that's unique to the specific page or project
- Initially a standard flex button's img/svg height is
1.125rem(it adjusts accordingly for other button sizes) - Width is auto
- Initially a standard flex button's img/svg height is
Left/Right Aligned Flex Buttons
Sometimes buttons with icons look better when their content is aligned to the left so that the icons line up.
- Assign
class='button flex left'to align content to the left - Assign
class='button flex right'to align content to the right
Aligning content to the left or right only works with flex buttons. Most of the time, button content should be centered.
Button Width
By default, buttons have a min-width and left+right padding. This can prevent a flat button from looking like it's "flush left." To disable min-width and padding, use:
noPaddingXnoMinWidth
noPaddingX and noMinWidth.To make a button full-width in its container, use:
fullWidth
Lorem ipsum dolor sit amet consec tetur adipi sicing elit. Dolores tenetur animi, exercit ationem quam itaque numquam facilis incidunt at unde quis soluta sed quidem nam saepe distinctio? Id saepe autem neque facilis ab.
fullWidth to set the width property = 100% of container's width.Button With Icon
<button class='button blue flex'> <?= preg_replace("/{{class-name}}/", "importIcon", file_get_contents("../images/icons/import.svg")); ?> <div>Button With a pretty Icon</div> </button>
Optional SCSS: Change the size of the svg icon
.button { &.specificStylingClass { svg { width: 24px; height: 24px; } } }
Just an Icon Buttons
-
Assign
class='button reset'to a button element or a .button link<button class='button reset specificStylingClass'><a href='…' class='button reset specificStylingClass'>
-
Define specific styling (size, hover, etc) via a class that's unique to the specific page or project
-
The reset class does not set a width or height for the img/svg.
(The
.button.flexclass does, but it's not advised to use the flex class in this scenario.)
-
The reset class does not set a width or height for the img/svg.
(The
HTML: Just an Icon
<button class='button reset specificStylingClass'> <?= preg_replace("/{{class-name}}/", "importIcon", file_get_contents("../images/icons/import.svg")); ?> </button>
SCSS: Just an Icon
.specificStylingClass { svg { width: $buttonHeight; height: $buttonHeight; fill: $orange; transition: all $transitionDuration; path { transition: all $transitionDuration; } } &:hover { svg { path#box { fill: $purple; } path#arrow { fill: $green; } } } }
Marker Flags: Like a Skinny Post-it© Page Marker
The class .markerFlag replaces the deprecated @mixin edit-this-flag that is still used in WordPress but no where else.
Marker flags don't have to be links, but they often will be.
Page Marker LinkDepending on the page, marker flags might work best with a negative left margin so they stick to the left edge of the window (outside of the article's boundary).
The negative left margin is not part of the
.markerFlagclass. You'll need to extend the class with the negative margin.
Tag Cloud Links
Tags are presented as links inside <li class='tag'> children of a <ul class='reset tags'> container.
HTML: tag cloud
<ul class='tags'> <li class='tag'><a href=''>Apples</a></li> <li class='tag'><a href=''>Oranges</a></li> <li class='tag'><a href=''>Kiwis</a></li> </ul>
Subtle Buttons
Subtle buttons are for links that need just a little bit of sparkle-dust (not for actions). For example: A blog author's name that links to their entire collection of posts, or individual tags in a tag cloud might be a subtle button.
The subtle button is also used as the base for the deprecated edit-this-flag styles,
as well as the base for tags in a tag cloud.