Skip to main content

ns-cta

Introduction#

A CTA (call-to-action) allows users to take action once they are ready for it.

Users can perform certain actions through the use of ns-cta. An example of these actions could be to submit a form through an event (i.e. click event) or navigate with a hyperlink.

There is no distinciton between a hyperlink or an action through the design of ns-cta. Use the text content to convey the intent of the CTA to the user.

Content guidance#

CTA Direct#

CTA - Direct

CTA Text#

CTA - Text

KeyField typeGuidelines
ATextKeep the text 'short, relevant, and actionable'. It should not exceed more than 24 characters.
BIconThis is a decoration. It is intended to imply direction such as moving forwards and backwards in a journey. The specification table has a list of options.

Differences between direct and text types#

The two types of ns-cta are there to offer hierarchical structure to the page.

The direct type has a more emphasised affordance, therefore it can be used as the main action for that page. As it's the main action, it should be used sparingly.

The text type supports the direct type and helps build hierarchy. It can be used for actions that are not the main reason for the page and can accommodate longer text content.

For example, on the Energy Hub Page the main purpose is for customers to get a quote. This action would be a direct CTA supplementary information such as Seeing all tariffs, Energy guides or Learning about smart meters would be the text type. We recommend when grouping actions through a set of cards they all use the same CTA type.

How to identify when to use the text type#

For example, if the content starts with:

  • Learn more...
  • Find out...
  • Look up...
  • See our...
  • Discover...

These are all supporting actions and our recommendation is to use the text type.

If there is a group of more than three actions it would be preferable to make all these CTAs the text type. Or to find the main action in this group and place it in an alternative, more suitable component such as ns-lockup or ns-standout to establish hierarchy.

Button vs link#

There is no visual distinction between a button and a link when using ns-cta. It's recommended not to use a native <button> element, but to use the CTA with the required events.

The distinction for a user on either a navigation or an event is not based on the appearance but on the text content. It needs to be clear based on the text content that the user is either going to the next step in a journey / page, or that they are doing an action, such as submitting a form.

Decorative vs functional#

The ns-cta is a standalone component that can serve an action whether it is a link or an event. However, if required it can be used as a decoration and be wrapped within an <a> element or another routing component (such as for specific frameworks). This means that those functionalities will still look like the ns-cta even though the functional task is being done outside of it.

States#

Loading#

The ns-cta is capable of handling a loading interaction using the loading and loadingMessage attributes, these can be found in the specification table below.

This loading state is used to provide the user with feedback that their action is being handled. It also reassures the user that action may take a number of seconds to be completed.

We recommend only to use this loading state for a maximum of 5 seconds. If it's known that the action is likely to take longer than 5 seconds, present the user with a Roadblock page type.

If the action fails, don't leave the CTA in its Loading state. Present the user with clear feedback with the highlighter component.

Your loading message should be contextual to the action of the text of the CTA. E.g. "Get a quote" becomes "Getting your quote...".

CTA - Loading state

You can see the live example of the loading state on Storybook.

Disabled#

We do not offer a disabled state, every CTA should have an action even if that is to an unhappy path. Such as, when in a form, a submit CTA will go to the highest invalid inputter to help the user to complete the form. It allows us to track the experience better when the user can interact with it.

If we use a disabled state in this example, it will infuriate the user as they wouldn't know what their next action is. This may force them to take an undesirable action, such as trying to call the call centre.

The only time we present a disabled state is during the Loading state. This ensures no accidental additional clicks are performed whilst the action is in progress.

Best practice#

๐Ÿ’š Do's๐Ÿ’” Dont's
Make it short and actionableMake it vague
Only use loading on an action that will take between 1 and 5 secondsMake it overly wordy
Relate the action to the content it sits besideChange the icon for the sake of it
Use direct type for the most important action on the pageUse more than 24 characters
Use text type to support the direct actionHave CTAs within a paragraph
Use instead of a native buttonRepeat the CTA copy within the same page
Use for downloads. Use the ns-download component instead

Considerations of best practice#

  • It should always be clear to the user what the CTA's action is through its text.
  • To be aware of the distinct roles of the CTA's types direct and text and that they don't always act as a primary and secondary button.
  • Try not to have multiple CTA's next to each other.
  • Don't make the main purpose of the page to have a group of CTAs.
  • Don't overload the page with the same type of CTA or too many CTAs.
  • The loading message should be the action of the text of the CTA. E.g. "Get a quote" becomes "Getting your quote...".

Usage#

View example on Storybook

Component placement#

The ns-cta component can be used in the following components:

Specification#

AttributeTypeDefaultOptionsDescription
typestringdirectdirect, textDifferent variants of the CTA.
hrefstringNavigating using a hyperlink.
iconstringarrow-rightarrow-left, arrow-right See ns-icon componentThe icon inside the CTA.
loadingstringfalsetrue, falseChange the state of the CTA to loading.
loadingMessagestringLoading...Overwrites the CTA anonymous slot for the loading state.
SlotsType
AnonymoustextNode

Specification notes#

Icons#

  • They are decorative, not descriptive, and are there to supplement the text.

Href#

  • Can be used instead of having a wrapping <a> element.
  • This shouldn't be used if a click event is added.

Design Tokens

You can change the branded look and feel of the ns-cta by modifying these options in the design tokens.

Read more about design tokens in our getting started guide.

{
  "icon-positions": {
    "direct": "right",
    "text": "left"
  },
  "focus-outline-color": " #FFDD57",
  "direct": {
    "icon": {
      "position": "right",
      "spacer": {
        "outside-left": "0.5rem"
      }
    },
    "typography": "action",
    "color": "#FFFFFF",
    "spacer": {
      "inside-top": "0.75rem",
      "inside-right": "1rem",
      "inside-bottom": "0.75rem",
      "inside-left": "1.25rem"
    },
    "disabled-background-color": "#005EB8",
    "box-shadow": [
      "rgba(170, 170, 170, 0.2) 0px 0px  5px 0px",
      "rgba(170, 170, 170, 0.4) -3px 3px 5px 0px",
      "rgba(51, 51, 51, 0.2) -5px 5px 20px;"
    ],
    "hover": {
      "box-shadow": [
        "rgba(170, 170, 170, 0.2) 0px 0px  1px 0px",
        "rgba(170, 170, 170, 0.4) -1px 1px 3px 0px",
        "rgba(51, 51, 51, 0.2) -1px 1px 10px;"
      ],
      "background-gradient": {
        "angle": "180deg",
        "stops": {
          "1": {
            "color": "#0099FF",
            "position": "-125%"
          },
          "2": {
            "color": "#005EB8",
            "position": "75%"
          }
        }
      }
    },
    "iconless": {
      "spacer": {
        "inside-right": "1.25rem"
      }
    },
    "background-gradient": {
      "angle": "180deg",
      "stops": {
        "1": {
          "color": "#0099FF",
          "position": "-75%"
        },
        "2": {
          "color": "#005EB8",
          "position": "100%"
        }
      }
    }
  },
  "text": {
    "icon": {
      "position": "left",
      "spacer": {
        "outside-right": "0.25rem"
      }
    },
    "typography": "action",
    "color": "#005EB8",
    "spacer": {
      "inside-right": "0.5rem"
    },
    "hover": {
      "color": "#003C71",
      "text-decoration-color": "rgba(51, 63, 72, .25)"
    },
    "focus": {
      "background-color": " #FFDD57",
      "text-decoration-color": "rgba(0, 60, 113, .5)"
    }
  }
}

Feedback#

  • Do you have insights or concerns to share? You can raise an issue via Github bugs.
  • See all the issues already raised via Github issues.

๐Ÿ’ฉ ๐ŸŽ‰ ๐Ÿฆ„ If you have any questions, contact us on Microsoft Teams in the Nucleus Design System channels.

Related links#