<section class="overview">

## Overview

Cardinal buttons are provided in two forms, as Angular elements, and as styles (CSS classes).

Buttons are divided into four categories: filled, outline, text, and icon.  Create a layered page or application with buttons via togglable classes or component inputs. 
</section>

<section class="usage-guides">

<hr>

## Usage


### Installation

<hr class="ta-shortDivider">

 Consult the <a href="http://dds.us.aegon.com/implementation" target="_blank" rel="noopener noreferrer">Implementation</a> section before continuing with component specific instructions.

Install @cardinal/button with:

`$ npm install --save @cardinal/button `

</section>

<section class="usage-guides">

### Buttons as Angular Elements

<hr class="ta-shortDivider">

Buttons can be implemented as Angular elements that consume button styles. Element buttons are framework agnostic.

Import the Cardinal button element into an existing Angular project by adding a link to the `button.js` file in the `scripts` section of the `angular.json` file.

```json
"scripts": [
  "node_modules/@cardinal/button/button.js",
]
```

To include the Cardinal button element in a non-Angular project, point to the `js` file of the element with a `script` tag in your `index.html` file.

```html
<body>
  <script src="node_modules/@cardinal/button/button.js"></script>
</body>
```

#### Polyfills
Please refer to the Support for Angular Elements section of the <a href="implementation">Implementation</a> page for documentation on required polyfills for Angular elements.

</section>

<section class="usage-guides">

<h4 class="-mt-2xl">Text (Default)</h4>

<section class="code-example -displayBlock">
  <ta-button class-list="-m-md">Button</ta-button>
  <ta-button class-list="-m-md" color="secondary">Button</ta-button>
  <ta-button class-list="-m-md" color="secondary" disabled="true">Button</ta-button>
</section>

```html
<ta-button class-list="-m-md">Button</ta-button>
<ta-button class-list="-m-md" color="secondary">Button</ta-button>
<ta-button class-list="-m-md" color="secondary" disabled="true">Button</ta-button>
```

<h4 class="-mt-2xl">Outline</h4>

<section class="code-example -displayBlock">
  <ta-button class-list="-m-md" variant="outline">Button</ta-button>
  <ta-button class-list="-m-md" variant="outline" color="secondary">Button</ta-button>
  <ta-button class-list="-m-md" variant="outline" color="secondary" disabled="true">Button</ta-button>

  <div class="ta-blue500Bg -mw960">
  <ta-button class-list="-m-md" variant="outline" color="inverse">Button Dark BG</ta-button>
  <ta-button class-list="-m-md" variant="outline" color="inverse" disabled="true">Button Dark BG</ta-button>
</div>
</section>

```html
<ta-button class-list="-m-md" variant="outline">Button</ta-button>
<ta-button class-list="-m-md" variant="outline" color="secondary">Button</ta-button>
<ta-button class-list="-m-md" variant="outline" color="secondary" disabled="true">Button</ta-button>

<ta-button class-list="-m-md" variant="outline" color="inverse">Button Dark BG</ta-button>
<ta-button class-list="-m-md" variant="outline" color="inverse" disabled="true">Button Dark BG</ta-button>
```

<h4 class="-mt-2xl">Filled</h4>

<section class="code-example -displayBlock">
  <ta-button class-list="-m-md" variant="filled">Button</ta-button>
  <ta-button class-list="-m-md" variant="filled" color="secondary">Button</ta-button>
  <ta-button class-list="-m-md" variant="filled" color="secondary" disabled="true">Button</ta-button>
</section>

```html
  <ta-button class-list="-m-md" variant="filled">Button</ta-button>
  <ta-button class-list="-m-md" variant="filled" color="secondary">Button</ta-button>
  <ta-button class-list="-m-md" variant="filled" color="secondary" disabled="true">Button</ta-button>
```

<h4 class="-mt-2xl">Text Buttons with Icons</h4>
<section class="code-example -displayBlock">
  <ta-button class-list="-m-md" icon="ta-favorite">Button</ta-button>
  <ta-button class-list="-m-md" icon="ta-download" icon-pos="right" color="secondary">Button</ta-button>
  <ta-button class-list="-m-md" icon="ta-print" color="secondary" disabled="true">Button</ta-button>

  <div class="ta-blue500Bg -mw960">
  <ta-button class-list="-m-md" icon="ta-favorite" color="inverse">Button Dark BG</ta-button>
  <ta-button class-list="-m-md" icon="ta-delete" icon-pos="right" color="inverse">Button Dark BG</ta-button>
  <ta-button class-list="-m-md" icon="ta-alarm" icon-pos="right" color="inverse" disabled="true">Button Dark BG</ta-button>
</section>

```html
  <ta-button class-list="-m-md" icon="ta-favorite">Button</ta-button>
  <ta-button class-list="-m-md" icon="ta-download" icon-pos="right" color="secondary">Button</ta-button>
  <ta-button class-list="-m-md" icon="ta-print" color="secondary" disabled="true">Button</ta-button>

  <ta-button class-list="-m-md" icon="ta-favorite" color="inverse">Button Dark BG</ta-button>
  <ta-button class-list="-m-md" icon="ta-delete" icon-pos="right" color="inverse">Button Dark BG</ta-button>
  <ta-button class-list="-m-md" icon="ta-alarm" icon-pos="right" color="inverse" disabled="true">Button Dark BG</ta-button>
```

<h4 class="-mt-2xl">Icon Buttons</h4>

Icon buttons require inputs for **icon** and  **label** to comply with WCAG 2.0 AA standards.

<section class="code-example -displayBlock">

  <ta-button class-list="-m-md" variant="iconButton" icon="ta-favorite" color="secondary" label="Favorite"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-download" label="Download" color="secondary"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-print" label="Print" color="secondary"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-call" label="Call" color="secondary"></ta-button>

  <ta-button class-list="-m-md" variant="iconButton" icon="ta-favorite" label="Favorite"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-download" label="Download"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-print" label="Print"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-call" label="Call"></ta-button>

  <ta-button class-list="-m-md" variant="iconButton" icon="ta-favorite" label="Favorite" disabled="true"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-download" label="Download" disabled="true"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-print" label="Print" disabled="true"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-call" label="Call" disabled="true"></ta-button>

</section>

```html
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-favorite" color="secondary" label="Favorite"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-download" label="Download" color="secondary"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-print" label="Print" color="secondary"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-call" label="Call" color="secondary"></ta-button>

  <ta-button class-list="-m-md" variant="iconButton" icon="ta-favorite" label="Favorite"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-download" label="Download"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-print" label="Print"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-call" label="Call"></ta-button>

  <ta-button class-list="-m-md" variant="iconButton" icon="ta-favorite" label="Favorite" disabled="true"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-download" label="Download" disabled="true"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-print" label="Print" disabled="true"></ta-button>
  <ta-button class-list="-m-md" variant="iconButton" icon="ta-call" label="Call" disabled="true"></ta-button>
```

<h4 id="buttonLinks"  class="-mt-2xl">Buttons as Links</h4>

Cardinal buttons can be used as links by adding a `link-href` input. This will change the base HTML element of the button to an anchor tag.

<section class="code-example -displayBlock">
<ta-button class-list="-m-md" link-href="https://www.google.com">Link</ta-button>
<ta-button class-list="-m-md" color ="secondary" link-href="https://www.google.com">Link</ta-button>
<ta-button class-list="-m-md" variant="outline" link-href="https://www.google.com">Link</ta-button>
<ta-button class-list="-m-md" variant="outline" link-href="https://www.google.com" color="secondary">Link</ta-button>
<ta-button class-list="-m-md" variant="filled" link-href="https://www.google.com">Link</ta-button>
<ta-button class-list="-m-md"color="secondary" variant="filled" link-href="https://www.google.com">Link</ta-button>
<ta-button class-list="-m-md" variant="iconButton" label="Favorite" link-href="https://www.google.com" color="secondary" icon="ta-favorite"></ta-button>

</section>

```html
<ta-button class-list="-m-md" link-href="https://www.google.com">Link</ta-button>
<ta-button class-list="-m-md" variant="outline" link-href="https://www.google.com" color="secondary">Link</ta-button>
<ta-button class-list="-m-md" variant="filled" link-href="https://www.google.com">Link</ta-button>
<ta-button class-list="-m-md" variant="iconButton" label="Favorite" link-href="https://www.google.com" color="secondary" icon="ta-favorite"></ta-button>
```

<section class="usage-guides">

<h4 class="-mt-2xl section-h4">Accesibility</h4>

The Cardinal Angular element button adheres to the <a href="https://www.w3.org/WAI/perspective-videos/controls/" target="_blank" rel="noopener noreferrer"> W3.org wai-aria</a> accesibilility standards.

The Angular element button defaults to a `<button>` html tag which comes prepackaged to meet AA Accesibility standards.

When using the Cardinal button element as type `linkButton` or `linkIconButton`, **`role="button"`** is included on the elment by default.

When using the Button as type `iconButton` or `linkIconButton`, developers must use the **`label`** input to ensure that icon buttons have discernable text for screenreaders. Failure to include this input will result in a console error.

</section>

#### Parameters

<div class="table">
<table style="width: 100%;">
  <thead>
    <th>Input Name</td>
    <th>Type</td>
    <th>Options</td>
    <th>Default</th>
    <th>Required</th>
    <th>Description</td>
  </thead>
  <tbody>
    <tr>
      <td class="label -initialText">variant</td>
      <td>string</td>
      <td class="-initialText">filled, outline, text, iconButton</td>
      <td class="-initialText">text</td>
      <td>No</td>
      <td>Sets button style.</td>
    </tr>
    <tr>
      <td class="label -initialText">color</td>
      <td>string</td>
      <td class="-initialText">'primary', 'secondary', 'inverse'</td>
      <td class="-initialText">'primary'</td>
      <td>No</td>
      <td>Sets button color.</td>
    </tr>
    <tr>
      <td class="label -initialText">icon</td>
      <td>string</td>
      <td><a href="/iconography/library">Icon class names</a></td>
      <td class="-initialText">undefined</td>
      <td>Yes <br>(On iconButtons)</td>
      <td>Sets icon using icon classname.</td>
    </tr>
    <tr>
      <td class="label -initialText">icon-pos</td>
      <td>string</td>
      <td class="-initialText">left, right</td>
      <td class="-initialText">left</td>
      <td>No</td>
      <td>Sets icon position relative to button text.</td>
    </tr>
    <tr>
      <td class="label -initialText">disabled</td>
      <td>boolean</td>
      <td class="-initialText">true, false</td>
      <td class="-initialText">false</td>
      <td>No</td>
      <td>Disables button functionality.</td>
    </tr>
    <tr>
      <td class="label -initialText">label</td>
      <td>string</td>
      <td class="-initialText">Any descriptive string</td>
      <td class="-initialText">undefined</td>
      <td>Yes <br>(On iconButtons)</td>
      <td>Adds aria-label for accessibility. Only used on iconButtons.</td>
    </tr>
    <tr>
      <td class="label -initialText">link-href</td>
      <td>string</td>
      <td class="-initialText">Any string pointing to an internal or external url.</td>
      <td class="-initialText">undefined</td>
      <td>No</td>
      <td>Uses an anchor tag for the button's base and adds the href attribute.</td>
    </tr>
    <tr>
      <td class="label -initialText">type</td>
      <td>string</td>
      <td class="-initialText">button, submit, reset</td>
      <td class="-initialText">undefined</td>
      <td>No</td>
      <td>Sets <a href="https://www.w3schools.com/tags/att_button_type.asp">type attribute</a> of button for use in forms. Does not apply to buttons with links.</td>
    </tr>
    <tr>
      <td class="label -initialText">class-list</td>
      <td>string</td>
      <td class="-initialText">Any string of CSS classes</td>
      <td class="-initialText">undefined</td>
      <td>No</td>
      <td>Adds CSS classes to the button element. Intended to be used with Cardinal <a href="spacing">Spacing</a> classes for ease of positioning.</td>
    </tr>
  <tbody>
</table>
</div>

<section class="usage-guides">

<hr>

### Buttons as Styles

<hr class="ta-shortDivider">

Cardinal button styles can be added with CSS classes, allowing developers to implement their own custom logic. Buttons are classified as filled, outline, text, and icon.

The source files included are written in <a href="http://sass-lang.com/" target="_blank" rel="noopener noreferrer">Sass</a>. Point the sass include-path to the node_modules directory and import with:

```javascript
@import "node_modules/@cardinal/button/button";
```

</section>

<section class="usage-guides">

#### Style Defaults

Button styles default to text buttons, with all variants defaulting to Primary (Red 500). 

  <section class="code-example -displayBlock">

  <button class="ta-button -m-md">Base</button>
  <button class="ta-button -m-md -filled">Filled</button>
  <button class="ta-button -m-md -outline">Outline</button>
  <button class="ta-iconButton ta-plant"></button>

  </section>

  ```html
  <button class="ta-button -m-md">Base</button>
  <button class="ta-button -m-md -filled">Filled</button>
  <button class="ta-button -m-md -outline">Outline</button>
  <button class="ta-iconButton ta-plant"></button>
  ```
</section>

<section class="usage-guides">

#### Button Classes

<div class="table cardinalTable">
Specify the button type.

| Class            | Description                                   |
| :---             |     ---:                                              |
| `.ta-button`     | Default button styles (Text Button, Primary Red 500)  |
| `.ta-iconButton` | Icon button styles                            |

Specify the button variant.

| Class            | Description                  |
| :---             |     ---:                     |
| `.-outline`      | Outline button styles        |
| `.-filled`       | Filled button styles         |

Specify the button color.

| Class            | Description                      |
| :---             |     ---:                         |
| `.-secondary`    | Secondary (Blue 500) styles      |
| `.-inverse`      | Inverse (Dark background) styles |

</div>
</section>

<section class="usage-guides">

#### Text Buttons

Cardinal text buttons are available in Primary (red 500), Secondary (blue 500), and Inverse (white on dark background) colors. They are low emphasis buttons used to support the secondary CTA.

<!-- begin code example -->
<section class="code-example -displayBlock">
  <button class="ta-button -m-md">
    Text Primary
  </button>

  <button class="ta-button -m-md -secondary">
    Text Secondary
  </button>

  <button disabled class="ta-button -m-md ">
    Text Disabled
  </button>

  <div class="ta-blue500Bg -mw960">
  <button class="ta-button -m-md -inverse">
    Text Inverse
  </button>

  <button class="ta-button -m-md -inverse" disabled>
    Text Inverse Disabled
  </button>
  </div>
</section>
<!-- end code example -->

```html
<button class="ta-button -m-md">Text Primary</button>

<button class="ta-button -m-md -secondary">Text Secondary</button>

<button class="ta-button -m-md" disabled>Text Disabled</button>

<button class="ta-button -m-md -inverse">Text Inverse</button>

<button class="ta-button -m-md -inverse" disabled>Text Inverse Disabled</button>
```
</section>

<section class="usage-guides">

#### Outline

Outline buttons are available in Primary (red 500), Secondary (blue 500), and Inverse (white on dark background) and are available with the modifier class `.-outline`.

**Note:** Inverse buttons are used against dark backgrounds.

<!-- begin code example -->
<section class="code-example -displayBlock">
  <button class="ta-button -m-md -outline">
    Outline Primary
  </button>

  <button class="ta-button -m-md -outline -secondary">
    Outline Secondary
  </button>

  <button class="ta-button -m-md -outline" disabled>
    Outline Disabled
  </button>

  <div class="ta-blue500Bg -mw960">
    <button class="ta-button -m-md -outline -inverse">
      Outline Inverse
    </button>
    <button disabled class="ta-button -m-md -outline -inverse">
      Outline Inverse Disabled
    </button>
  </div>
</section>
<!-- end code example -->

```html
<button class="ta-button -m-md -outline">Outline Primary</button>

<button class="ta-button -m-md -outline -secondary">Outline Secondary</button>

<button class="ta-button -m-md -outline" disabled>Outline Disabled</button>

<button class="ta-button -m-md -outline -inverse">Outline Inverse</button>

<button class="ta-button -m-md -outline -inverse"  disabled>Outline Inverse Disabled</button>
```
</section>

<section class="usage-guides">

#### Filled

Cardinal filled buttons are available in Primary (red 500) and Secondary (blue 500) Colors and are available with the modifier class `.-filled`.
<!-- begin code example -->
<section class="code-example -displayBlock">
  <button class="ta-button -m-md -filled">
    Filled Primary
  </button>

  <button class="ta-button -m-md -filled -secondary">
    Filled Secondary
  </button>

  <button disabled class="ta-button -m-md -filled">
    Filled Disabled
  </button>
</section>
<!-- end begin code example -->

```html
  <button class="ta-button -m-md -filled">Filled Primary</button>

  <button class="ta-button -m-md -filled -secondary">Filled Secondary</button>

  <button class="ta-button -m-md -filled" disabled>Filled Disabled</button>
```
</section>

<section class="usage-guides">

#### Text Buttons with Icons

Cardinal text buttons can be paired with icons by passing the icon CSS class to the element. Default icon position is to the left of the text button and can be switched with the <code>-iconRight</code> modifier.

<!-- begin code example -->
<section class="code-example -displayBlock">
  <button class="ta-button -m-md ta-download -secondary">
    Text With Icon Left
  </button>
  <button class="ta-button -m-md ta-close -iconRight">
    Text With Icon Right
  </button>

  <div class="ta-blue500Bg -mw960">
    <button class="ta-button -m-md ta-download -inverse">
      Text With Icon Left
    </button>
    <button class="ta-button -m-md ta-plant -iconRight -inverse">
      Text With Icon Right
    </button>
  </div>
</section>
<!-- end code example -->

```html
<button class="ta-button -m-md ta-download -secondary">Text With Icon Left</button>

<button class="ta-button -m-md ta-close -iconRight">Text With Icon Right</button>

<button class="ta-button -m-md ta-download -inverse">Text With Icon Left</button>

<button class="ta-button -m-md ta-plant -iconRight -inverse">Text With Icon Right</button>
```
</section>

<section class="usage-guides">

#### Icon Buttons


Cardinal icon buttons are available in Primary (red 500) and Secondary (blue 500). Use these where the expected action is clear.

**Note:** To meet WCAG 2.0 compliance, `aria-label` attributes must also be included on the element.

<!-- begin code example -->
<section class="code-example -displayBlock">
  <button aria-label="Download the file" class="ta-iconButton -secondary ta-download"></button>
  <button aria-label="Favorite this item" class="ta-iconButton -secondary ta-favorite"></button>
  <button aria-label="Print the information" class="ta-iconButton -secondary ta-print"></button>
  <button aria-label="Call Support Services" class="ta-iconButton -secondary ta-call"></button>
  <br>
  <button aria-label="Download the file" class="ta-iconButton ta-download"></button>
  <button aria-label="Favorite this item" class="ta-iconButton ta-favorite"></button>
  <button aria-label="Print the information" class="ta-iconButton ta-print"></button>
  <button aria-label="Call Support Services" class="ta-iconButton ta-call"></button>
  <br>
  <button aria-label="Download the file" class="ta-iconButton ta-download" disabled></button>
  <button aria-label="Favorite this item" class="ta-iconButton ta-favorite" disabled></button>
  <button aria-label="Print the information" class="ta-iconButton ta-print" disabled></button>
  <button aria-label="Call Support Services" class="ta-iconButton ta-call" disabled></button>
</section>
<!-- end code example -->

```html
<button aria-label="Download the file" class="ta-iconButton -secondary ta-download"></button>
<button aria-label="Favorite this item" class="ta-iconButton -secondary ta-favorite"></button>
<button aria-label="Print the information" class="ta-iconButton -secondary ta-print"></button>
<button aria-label="Call Support Services" class="ta-iconButton -secondary ta-call"></button>

<button aria-label="Download the file" class="ta-iconButton ta-download"></button>
<button aria-label="Favorite this item" class="ta-iconButton ta-favorite"></button>
<button aria-label="Print the information" class="ta-iconButton ta-print"></button>
<button aria-label="Call Support Services" class="ta-iconButton ta-call"></button>

<button aria-label="Download the file" class="ta-iconButton ta-download" disabled></button>
<button aria-label="Favorite this item" class="ta-iconButton ta-favorite" disabled></button>
<button aria-label="Print the information" class="ta-iconButton ta-print" disabled></button>
<button aria-label="Call Support Services" class="ta-iconButton ta-call" disabled></button>
```
</section>
