Spruce comes with basic button variations like size, width, color, state and can also generate your custom color variants.

Defaults

You can use two default color variants named: primary and secondary. To overwrite colors, see the configurable variables section.

Secondary
html
<button type="button" class="btn btn--primary">Primary</button>
<a href="https://conedevelopment.com" class="btn btn--secondary">Secondary</a>

Use <a> for links and navigation between pages and <button> for actions (in page) like a form sending or modal opening.

Sizes

Spruce came with three different button sizes: small, regular, large. Using the standard size, you don't have to use any modifier. For small use: btn--sm, for large use: btn--lg class.

html
<button type="button" class="btn btn--primary btn--sm">Small</button>
<button type="button" class="btn btn--primary">Regular</button>
<button type="button" class="btn btn--primary btn--lg">Large</button>

Disabled state

To disable any button element, use the disabled boolean attribute. The disabled style is a bit dimmer (opacity: 0.5;) and has the pointer-evens: none; to prevent the user actions.

The disabled attribute doesn't work on links, so you have to use the btn--disabled modifier class. Also, you should omit the href attribute and set the aria-disabled="true".

html
<button type="button" class="btn btn--primary" disabled>Disabled button</button>
<button type="button" class="btn btn--secondary" disabled>Disabled button</button>
<a class="btn btn--primary btn--disabled" aria-disabled="true">Disabled button</a>
<a class="btn btn--secondary btn--disabled" aria-disabled="true">Disabled button</a>

Block Buttons

To display a block button, you can use the btn--block modifier class.

html
<button type="button" class="btn btn--primary btn--block">Block button</button>
<button type="button" class="btn btn--secondary btn--block">Block button</button>

With Icon

To use any icon with Spruce, you must specify it in image format, preferably in SVG, because we set its height and width. Use with the btn__icon class on the image. Place it before (left) or after the caption (right) depending on the position.

The .btn has inline-flex display with a gap value.

html
<button type="button" class="btn btn--primary">
<svg class="btn__icon">...</svg>
Read more
</button>
<button type="button" class="btn btn--secondary">
Read more
<svg class="btn__icon">...</svg>
</button>

You can also use the .btn__icon--sm modifier to make the icons smaller.

html
<button type="button" class="btn btn--primary">
<svg class="btn__icon btn__icon--sm">...</svg>
Read more
</button>
<button type="button" class="btn btn--secondary">
Read more
<svg class="btn__icon btn__icon--sm">...</svg>
</button>

Icon

To make an only icon button use the btn--icon modifier class. If you create an icon button, use aria-label to add a caption.

html
<button class="btn btn--secondary btn--icon" aria-label="Copy Text">
<svg class="btn__icon">...</svg>
Read more
</button>

Configurable Variables

There are default variables that you can configure to customize the button's look.

Also, Spruce manage the colors in a separate Sass map named $colors (under the btn object).

Add Custom Button Variant

You can create new button color variants using the btn-variant mixin. First, you must declare the new button's colors at the $color map under the btn object. After this, all you have to do is to call the mixin on the preferred selector.

More information about the btn-variant() please visit the releated mixin page.