Skip to content

Buttons

Buttons are used to trigger an action or an event. Button labels let the user know what to expect by clearly communicating what selecting the button will do or where it will take them.

Code

Variants

Brand Secondary Danger Success
Inverse
packages/certara-ui/src/components/button/button.tsx
<certara-button color="brand">…</certara-button>

certara-button

Properties

PropertyAttributeDescriptionTypeDefault
blockblockbooleanfalse
colorcolor"brand" | "danger" | "inverse" | "neutral" | "secondary" | "success" | "warning"'brand'
configAriaconfig-ariaany{}
disableddisabledbooleanfalse
hrefhrefstringundefined
innerClassNameinner-class-namestringundefined
leftIconleft-iconstringundefined
popoverTargetpopover-targetstringundefined
popoverTargetActionpopover-target-action"hide" | "show" | "toggle"undefined
rightIconright-iconstringundefined
showLoadershow-loaderbooleanfalse
sizesize"lg" | "md" | "sm"'md'
targettarget"_blank" | "_parent" | "_self" | "_top" | "_unfencedTop"undefined
typetype"button" | "reset" | "submit"'button'
variantvariant"default" | "icon" | "link" | "outline"'default'

Events

EventDescriptionType
certaraBlurCustomEvent<void>
certaraClickCustomEvent<any>
certaraFocusCustomEvent<void>

Dependencies

Used by

Depends on

Graph

graph TD;
certara-button --> certara-icon
certara-dropdown --> certara-button
style certara-button fill:#f9f,stroke:#333,stroke-width:4px

Stencil provides an API to specify the events a component can emit, and it does so with the Event() decorators. Here’s an example of how to use them:


<script>
const element = document.getElementById('my-button');
element.addEventListener('certaraClick', handleClick);
function handleClick() {
console.log('Clicked!');
}
</script>

Additional sizing

(Note: Works on solid, outline, and link buttons)

Small button
<certara-button color="brand" size="sm">
Small button
</certara-button>

Icons

(Note: Works on solid, outline, and link buttons)

Icon on left
<certara-button left-icon="plus">
Icon on left
</certara-button>

If you have a <button> that for whatever reason needs to look like a link, eschew the use of <certara-button> in favor of a simple <button> with a class="link". Use Text color utilities to effect color variances.

<button class="link">Link</button>
<button class="link text-brand">Brand</button>
<button class="link text-danger">Danger</button>
<button class="link text-success">Success</button>
<button class="link text-inverse">Inverse</button>

Best Practices

Choosing an icon

For more information, refer to the Icon page.

Hierarchy

When multiple actions/options are needed it is important to distinguish their level of importance. Buttons have three levels of importance (primary, secondary, and tertiary).

The example below shows how to display buttons in order of importance (left to right), and the possible combinations when all three are in use.

Brand as primary Neutral as secondary Button link as tertiary
Brand as primary Brand as secondary Button link as tertiary
Danger as primary Neutral as secondary Button link as tertiary
Brand as primary Danger as secondary Button link as tertiary

Content guidelines

  • Be clear and predictable for users to anticipate what will happen when they click a button
  • Lead with strong action verbs that encourage action and provide enough context. Use the {verb}+{noun} format except in common action like Save, Close, Cancel, or OK.
  • Be scannable: avoid unnecessary words and articles such as the, an, or a.

Accessibility

Generally: links go somewhere while buttons do something.

A link is focusable and can be triggered by the enter key. A link will redirect you to a new page or a section within the same page. In VoiceOver’s rotator, it will also be collected within the “Links” window. A link changes what the URL in the browser points to and then displays that website or file. (If the browser can’t display the file, it gets downloaded)

Buttons

Buttons perform an action and are used for functionality that does not lead a user somewhere else. A button is focusable, too, and can be triggered by the space key. A button will trigger an action like opening or closing something, sending a form, expanding navigation, or show/hide. In most cases JavaScript is used to do this. In VoiceOver’s rotator, it will be collected within the “Form controls” window. Outside of submitting a form, a button is paired with Javascript, and without it, the usefulness of buttons is generally limited.

Accessibility concerns

Buttons and links have two different roles, so assistive technologies announce them differently. Links are announced as “links”, while buttons are announced as “buttons”. Having these different roles means there are different user expectations. Not only that links go somewhere and buttons do something, but also their interactivity:

  • Links can be activated by pressing the return key only.
  • Buttons can be activated by pressing return or space.
  • Screen readers have a function to present a list of links to their users. Buttons cannot be as easily reached.
  • Buttons use the normal mouse pointer arrow, while links trigger the use of the pointing hand mouse pointer.

Design resources

View component in Figma