<!-- Default -->
<button class="vgr-button vgr-button--primary">Button</button>
<!-- Subtle -->
<button class="vgr-button vgr-button--subtle">Button</button>
<!-- Secondary -->
<button class="vgr-button vgr-button--secondary">Button</button>
<!-- Disabled -->
<button class="vgr-button vgr-button--primary" disabled>Button</button>
<!-- Icon With Text -->
<button class="vgr-button" type="submit">
<svg class="vgr-icon vgr-icon--" ><use xlink:href="/icons/sprite/icons.svg#search"></use></svg>
Button
</button>
<!-- Icon -->
<button class="vgr-button" type="submit">
<svg class="vgr-icon vgr-icon--" ><use xlink:href="/icons/sprite/icons.svg#search"></use></svg>
</button>
{% if modifier == 'icon' %}
<button class="vgr-button" type="submit">
{% render "@icon", iconData %} {% if iconWithText %}{{ buttonText }}{% endif %}
</button>
{% else %}
<button class="vgr-button vgr-button--{{ modifier }}" {{disabled}}>{{ buttonText }}</button>
{% endif %}
/* Default */
{
"buttonText": "Button",
"modifier": "primary"
}
/* Subtle */
{
"buttonText": "Button",
"modifier": "subtle"
}
/* Secondary */
{
"buttonText": "Button",
"modifier": "secondary"
}
/* Disabled */
{
"buttonText": "Button",
"modifier": "primary",
"disabled": "disabled"
}
/* Icon With Text */
{
"buttonText": "Button",
"modifier": "icon",
"iconWithText": true,
"iconData": {
"id": "search"
}
}
/* Icon */
{
"buttonText": "Button",
"modifier": "icon",
"iconWithText": null,
"iconData": {
"id": "search"
}
}
/* Gradient backgrounds */
$color-gradient-primary-light: linear-gradient(to bottom,#4ab31f 0,#39791f 100%); // Primary btn
$color-gradient-primary-dark: linear-gradient(to bottom,#388618 0,#244d14 100%); // Primary btn hover
$color-gradient-subtle-light: linear-gradient(to bottom,#f8f8f8 0%,#f1f1f1 100%); // Subtlebtn
$color-gradient-subtle-dark: linear-gradient(to bottom,$color-gray-100 0%,lighten($color-gray-lighter, 5%) 100%); // Subtlebtn hover
.vgr-button {
position: relative;
display: inline-block;
box-sizing: border-box;
margin: 0;
padding: .4rem 1.5rem;
border-width: 1px;
border-style: solid;
border-bottom-width: 2px;
border-radius: 4px;
font-family: Helvetica,Arial,sans-serif;
line-height: 150%;
cursor: pointer;
.vgr-icon {
width: 1rem;
height: 1rem;
vertical-align: text-top;
}
&:hover,
&:focus {
background-color: inherit;
box-shadow: inherit;
}
&[disabled] {
background-color: $color-gray-100;
border-color: $color-gray-lighter;
color: $color-gray-600;
background-image: none;
cursor: not-allowed;
box-shadow: none;
pointer-events: none;
&:hover,
&:focus {
background-color: $color-gray-100;
box-shadow: none;
color: $color-black;
}
}
&--primary {
border-color: #4ab31f;
border-bottom-color: #075d2d;
background-color: #13aa55;
background-image: $color-gradient-primary-light;
color: $color-white;
&:hover,
&:focus {
background: $color-gradient-primary-dark;
border-color: #388618 #388618 #084422;
color: #fff;
outline: 0;
}
}
&--secondary {
&:hover,
&:focus {
color: $color-black;
}
}
}
.vgr-button--subtle {
padding: 10px 16px 12px;
border: solid 1px $color-gray-lighter;
border-radius: 2px;
background: $color-gray-100;
background-image: $color-gradient-subtle-dark;
color: #2d2d2d;
text-decoration: none;
font-weight: 700;
font-size: .8125em;
transition: all .1s linear;
-webkit-tap-highlight-color: rgba(0,0,0,0);
&:active {
color: #2d2d2d;
}
&:hover,
&:focus {
border-color: #c6c6c6;
background-image: $color-gradient-subtle-light;
box-shadow: 0 1px 3px rgba(0,0,0,.15);
color: #2d2d2d;
text-decoration: none;
}
}
Text from The U.S. Web Design Standards
The examples demonstrate how to use button elements. To use a button style on an anchor link, add the vgr-button
class to your anchor link.
To use a different style button on your anchor link, add the special button class in addition to vgr-button
:
vgr-button--primary
vgr-button--secondary
vgr-button--subtle
For example, a secondary button style would use the following code: <a class="vgr-button vgr-button-secondary" href="/my-link">My button</a>
<div>
or <img>
tags to create buttons. Screen readers don’t automatically know either is a usable button.