Buttons

Use buttons to help the user carry out an important action such as starting a transaction or agreeing to a purchase.

  • Content:
    @import "../../../theme/assets/styles/sass/variables-import";
    @import "../../../theme/assets/styles/sass/tools/focus.placeholder";
    
    $ontario-button-bg-primary: $ontario-colour-link;
    $ontario-button-bg-primary--hover: $ontario-colour-link--hover;
    $ontario-button-bg-primary--active: $ontario-colour-link--active;
    $ontario-button-bg-secondary: $ontario-colour-white;
    
    .ontario-button {
        border: none;
        border-radius: $global-radius;
        box-sizing: border-box;
        box-shadow: none;
        display: inline-block;
        font-size: 1.125rem;
        font-weight: 600;
        font-family: $ontario-font-open-sans;
        line-height: calc(14/9);
        margin: $spacing-0 calc(#{$spacing-4} + #{$spacing-3}) $spacing-5 $spacing-0;
        min-width: 10rem;
        padding: calc((#{$spacing-4} + #{$spacing-1}) / 2) $spacing-5;
        text-align: center;
        text-decoration: none;
        cursor: pointer;
    
        &:focus,
        &:active {
            @extend %ontario-focus;
        }
    
        @media screen and (max-width: $small-breakpoint) {
            margin-right: 0;
            display: block;
            width: 100%;
        }
    
        .ontario-icon{
            margin-right: 4px;
        }
    
    }
    
    .ontario-button--primary {
        background-color: $ontario-button-bg-primary;
        color: $ontario-colour-white;
    
        &:hover {
            background-color: $ontario-button-bg-primary--hover;
            color: $ontario-colour-white;
        }
    
        &:focus {
            background-color: $ontario-button-bg-primary--hover;
            color: $ontario-colour-white;
            transition: background-color .2s ease-out, $ontario-focus-transition;
        }
    
        &:active {
            background-color: $ontario-button-bg-primary--active;
            color: $ontario-colour-white;
            transition: background-color 0s, $ontario-focus-transition;
        }
    
        &:visited {
            color: $ontario-colour-white;
        }
    }
    
    .ontario-button--secondary {
        background-color: $ontario-button-bg-secondary;
        border: 2px solid $ontario-colour-link;
        color: $ontario-colour-link;
        padding-top: $spacing-2;
        padding-bottom: $spacing-2;
    
        &:hover {
            background-color: $ontario-colour-button-secondary--hover;
            border-color: $ontario-colour-link--hover;
            color: $ontario-colour-link--hover;
        }
    
        &:focus {
            background-color: $ontario-colour-button-secondary--hover;
            border-color: $ontario-colour-link--hover;
            color: $ontario-colour-link--hover;
            transition: background-color .2s ease-out, $ontario-focus-transition;
        }
    
        &:active {
            background-color: $ontario-colour-button-secondary--active;
            border-color: $ontario-colour-link--active;
            color: $ontario-colour-link--active;
            transition: background-color 0s, $ontario-focus-transition;
        }
    
        &:visited {
            color: $ontario-colour-link;
        }
    
    }
    
    .ontario-button--tertiary {
        background-color: transparent;
        color: $ontario-colour-link;
        text-decoration: underline;
    
        &:hover {
            background-color: $ontario-colour-button-tertiary--hover;
            color: $ontario-button-bg-primary--hover;
            text-decoration: underline;
        }
    
        &:focus {
            background-color: $ontario-colour-button-tertiary--hover;
            color: $ontario-colour-link--hover;
            text-decoration: underline;
            transition: background-color .2s ease-out, $ontario-focus-transition;
        }
    
        &:active {
            background-color: $ontario-colour-button-tertiary--active;
            color: $ontario-colour-link--active;
            text-decoration: underline;
            transition: background-color 0s, $ontario-focus-transition;
        }
    
        &:visited {
            color: $ontario-colour-link;
        }
    
    
    
    }
    
  • URL: /components/raw/buttons/buttons.scss
  • Filesystem Path: fractal/components/components/buttons/buttons.scss
  • Size: 3.6 KB
  • Content:
    .ontario-button:focus,.ontario-button:active{box-shadow:0 0 0 4px #009adb;outline:4px solid transparent;-webkit-transition:box-shadow .1s ease-in-out;transition:box-shadow .1s ease-in-out}.ontario-button{border:none;border-radius:4px;box-sizing:border-box;box-shadow:none;display:inline-block;font-size:1.125rem;font-weight:600;font-family:"Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif;line-height:calc(14/9);margin:0 calc(1rem + 0.75rem) 1.5rem 0;min-width:10rem;padding:calc((1rem + 0.25rem) / 2) 1.5rem;text-align:center;text-decoration:none;cursor:pointer}@media screen and (max-width: 40em){.ontario-button{margin-right:0;display:block;width:100%}}.ontario-button .ontario-icon{margin-right:4px}.ontario-button--primary{background-color:#06c;color:#fff}.ontario-button--primary:hover{background-color:#00478f;color:#fff}.ontario-button--primary:focus{background-color:#00478f;color:#fff;-webkit-transition:background-color .2s ease-out,box-shadow .1s ease-in-out;transition:background-color .2s ease-out,box-shadow .1s ease-in-out}.ontario-button--primary:active{background-color:#002142;color:#fff;-webkit-transition:background-color 0s,box-shadow .1s ease-in-out;transition:background-color 0s,box-shadow .1s ease-in-out}.ontario-button--primary:visited{color:#fff}.ontario-button--secondary{background-color:#fff;border:2px solid #06c;color:#06c;padding-top:.5rem;padding-bottom:.5rem}.ontario-button--secondary:hover{background-color:#e0f0ff;border-color:#00478f;color:#00478f}.ontario-button--secondary:focus{background-color:#e0f0ff;border-color:#00478f;color:#00478f;-webkit-transition:background-color .2s ease-out,box-shadow .1s ease-in-out;transition:background-color .2s ease-out,box-shadow .1s ease-in-out}.ontario-button--secondary:active{background-color:#c2e0ff;border-color:#002142;color:#002142;-webkit-transition:background-color 0s,box-shadow .1s ease-in-out;transition:background-color 0s,box-shadow .1s ease-in-out}.ontario-button--secondary:visited{color:#06c}.ontario-button--tertiary{background-color:transparent;color:#06c;text-decoration:underline}.ontario-button--tertiary:hover{background-color:#e8e8e8;color:#00478f;text-decoration:underline}.ontario-button--tertiary:focus{background-color:#e8e8e8;color:#00478f;text-decoration:underline;-webkit-transition:background-color .2s ease-out,box-shadow .1s ease-in-out;transition:background-color .2s ease-out,box-shadow .1s ease-in-out}.ontario-button--tertiary:active{background-color:#d1d1d1;color:#002142;text-decoration:underline;-webkit-transition:background-color 0s,box-shadow .1s ease-in-out;transition:background-color 0s,box-shadow .1s ease-in-out}.ontario-button--tertiary:visited{color:#06c}
  • URL: /components/raw/buttons/buttons.css
  • Filesystem Path: fractal/components/components/buttons/buttons.css
  • Size: 2.7 KB

Guiding principle: Be consistent.

When to use this component

Use buttons when you want the user to do something (often called a “call to action”), for example:

  • start an application process or a transaction
  • agree to make a payment
  • download a PDF

Don’t use a button when you’re not encouraging an action. Buttons should not be used the same way as links, which usually send the user to another page or to a different part of the same page.


Types of buttons

Use a primary button to draw attention to the main action you want to help the user take. Avoid using multiple primary buttons on one page unless the page has equally important calls to action.

Use a secondary button for a less important call to action on a page. Avoid using multiple secondary buttons so the user is not confused about what they should do next. Instead, ask the writer to simplify or break up the content so that it doesn’t need multiple secondary buttons.

Use tertiary buttons for links that should function like a button, such as “edit” or “cancel” in applications. It’s okay to use more than one tertiary button on a page.


Technical specifications

Button type Colour Minimum width
Primary button Default background: #0066CC
Font: #FFFFFF
Hover background: #00478F
Active background: #002142
160px
Secondary button Default background: #FFFFFF
Default border and font: #0066CC
Hover background: #E0F0FF
Hover border and font: #00478F
Active background: #C2E0FF
Active border and font: #002142
160px
Tertiary button Default background: none
Default border: none
Default font: #0066CC
Hover background: #E8E8E8
Hover font: #00478F
Active background: #D1D1D1
Active font: #002142
160px

The width of primary, secondary and tertiary buttons (minimum 160px) should be the size of the text label with additional padding:

  • 24px internal padding on the right and left sides of the button text
  • 16px internal padding on the top and bottom of the button text

There should be 32px spacing between buttons on desktop and 24px spacing between buttons on mobile.

Desktop

Examples showing the padding of normal state primary, secondary and tertiary buttons in desktop mode.

Mobile

Examples showing the padding of normal state primary, secondary and tertiary buttons in desktop mode.

Do:

  • ensure button text is clear, descriptive and action-oriented (for example, “Save your profile” or “Download your receipt”)
  • use sentence case (capitalize only the first letter of the first word)
  • use a maximum of 25 characters including spaces
  • place buttons below form elements
    • when reading online, people’s eyes typically follow an “F” pattern, so you’re making it easier for the user by putting the call-to-action in a button where their eyes are naturally drawn anyway
The “F” pattern
Examples showing the padding of normal state of primary, secondary and tertiary buttons in mobile mode with 25 character limit.

Don’t:

  • change button colours
  • underline text for primary or secondary buttons
  • use multiple primary and secondary buttons unless absolutely necessary
    • tertiary buttons aren’t as prominent as primary or secondary buttons so you can use a few if needed

Help improve this page

If you have other suggestions or advice or any questions on buttons, the design system team would love to hear from you.