Button | UI components (BETA)

APPLICABLE PRODUCTS
  • Sales Hub
    • Enterprise
  • Service Hub
    • Enterprise

The Button component renders a single button. Use this component to enable users to perform actions, such as submitting a form, sending data to an external system, or deleting data.

Button text is passed into the component like a standard HTML element, rather than through a prop. 

design-guide-button-component
  1. Button text: the visible button text that describes the button's action.
  2. Variant: the color of the button. Learn more about available button variants below.
import { Button } from '@hubspot/ui-extensions'; const Extension = () => { return ( <Button onClick={() => { console.log('Someone clicked the button!'); }} href="https://hubspot.com" variant="destructive" size="md" type="button" > Click me! </Button> ); };
Prop Type Description
href String  Navigates to a URL on button click. When a button includes both href and an onClick action, both will be executed on button click. Links to external pages will open in a new tab, while links to pages in the HubSpot account will open in the same tab.
onClick () => void

A function that will be invoked when the button is clicked. It receives no arguments and it's return value is ignored.

You can use this function to open panels.

disabled Boolean When set to true, the button will render in a greyed-out state and cannot be clicked.
variant 'primary' | 'secondary' (default) | 'destructive' Sets the color of the button. See variants section for more information.
type 'button' (default) | 'reset' | 'submit' Sets the role HTML attribute of the button.
size 'xs', 'extra-small' | 'sm', 'small' | 'med', 'medium' (default) The size of the button.

Variants

Using the variant prop, you can set the color of the button.
  • Primary: a dark blue button for the most frequently used or most important action on an extension. Each extension should only have one primary button.
    design-guide-button-type-primary
    • Secondary: a grey button to provide alternative or non-primary actions. Each extension should include no more than two secondary buttons.
      design-guide-button-type-secondary
  • Destructive: a red button for actions that delete, disconnect, or perform any action that the user can't undo. Button text should clearly communicate what is being deleted or disconnected. After a destructive button is clicked, the user should have to verify or confirm the action.
    design-guide-button-type-destructive

Please note: HubSpot does not provide variant options for the orange buttons you’ll find across the app (both solid and outlined). Those color variants are reserved for the HubSpot product, which helps to maintain the hierarchy of available actions on a given page.

Usage examples

  • Use a primary button at the end of a form to submit data to another system.
  • Use a secondary button next to a primary form submit button to reset form fields.
  • Use a destructive button to enable users to delete a contact's data from an external system.
  • Set a button to disabled when a contact doesn't qualify for a form submission due to missing criteria or other ineligibility.

Guidelines

  • DO: set button text that clearly communicates what action will occur when a user clicks it. Text should be unambiguous and concise (~2-4 words).
  • DO: use sentence-casing for button text (only the first word capitalized)
  • DO: minimize the number of buttons that appear on a page record across all extensions.
  • DON'T: include multiple primary buttons in a single extension.
  • DON'T: use a destructive button unless the consequences are significant or irreversible.

Was this article helpful?
This form is used for documentation feedback only. Learn how to get help with HubSpot.