Button (legacy)

Caution

Legacy buttons will soon be deprecated. Please use the new button, icon button, link button, or link icon button. Migrate from legacy buttons using our codemod.

View the migration guide

Props

Shared props

These props can be applied to all buttons (Button, LoadingButton and CustomThemeButton).

All buttons also support all valid HTMLElement props, except for disabled which is replaced with the isDisabled prop.

analyticsContext

Description

Additional information to be included in the context of analytics events that come from button.

Type{ [x: string]: any; }

appearance

Description

The base styling to apply to the button.

Type"default" | "danger" | "link" | "primary" | "subtle" | "subtle-link" | "warning"

autoFocus

Description

Set the button to autofocus on mount.

Typeboolean

children

Description

Text content to be rendered in the button.

Typestring | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal

className

Description

Add a classname to the button.

Typestring

component

Description
No description.
TypeComponentType<AllHTMLAttributes<HTMLElement>> | ElementType<any, keyof JSX.IntrinsicElements>

data-has-overlay

Description
No description.
Typenever

data-testid

Description
No description.
Typenever

href

Description

Provides a URL that's used when the button is a link styled as a button.

Typestring

iconAfter

Description

Places an icon within the button, after the button's text.

Typestring | number | ReactElement<any, string | JSXElementConstructor<any>>

iconBefore

Description

Places an icon within the button, before the button's text.

Typestring | number | ReactElement<any, string | JSXElementConstructor<any>>

interactionName

Description

An optional name used to identify this component to press listeners. For example, interaction tracing. For more information, see UFO integration into Design System components.

Typestring

isDisabled

Description

Set if the button is disabled.

Typeboolean

isSelected

Description

Change the style to indicate the button is selected.

Typeboolean

onBlur

Description

Handler called on blur.

Type(event: FocusEvent<HTMLElement, Element>) => void

onClick

Description

Handler called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details.

Type(e: MouseEvent<HTMLElement, globalThis.MouseEvent>, analyticsEvent: UIAnalyticsEvent) => void

onFocus

Description

Handler called on focus.

Type(event: FocusEvent<HTMLElement, Element>) => void

overlay

Description

Used to 'overlay' something over a button. This is commonly used to display a loading spinner.

Typestring | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal

ref

Description
No description.
Type((instance: HTMLElement) => void) | RefObject<HTMLElement>

shouldFitContainer

Description

Option to fit button width to its parent width.

Typeboolean

spacing

Description

Set the amount of padding in the button.

Type"default" | "compact" | "none"

target

Description

Pass target down to the button. If a href is provided, this will be a semantic link styled as a button.

Type"_self" | "_blank" | "_parent" | "_top" | (string & {})

testId

Description

A testId prop is provided for specified elements, which is a unique string that appears as a data attribute data-testid in the rendered code, serving as a hook for automated tests.

Typestring

type

Description

Pass type down to the button.

Type"submit" | "reset" | "button"

Loading button props

The LoadingButton accepts all shared props (except for overlay) as well as an optional isLoading prop.

analyticsContext

Description

Additional information to be included in the context of analytics events that come from button.

Type{ [x: string]: any; }

appearance

Description

The base styling to apply to the button.

Type"default" | "danger" | "link" | "primary" | "subtle" | "subtle-link" | "warning"

autoFocus

Description

Set the button to autofocus on mount.

Typeboolean

children

Description

Text content to be rendered in the button.

Typestring | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal

className

Description

Add a classname to the button.

Typestring

component

Description
No description.
TypeComponentType<AllHTMLAttributes<HTMLElement>> | ElementType<any, keyof JSX.IntrinsicElements>

data-has-overlay

Description
No description.
Typenever

data-testid

Description
No description.
Typenever

href

Description

Provides a URL that's used when the button is a link styled as a button.

Typestring

iconAfter

Description

Places an icon within the button, after the button's text.

Typestring | number | ReactElement<any, string | JSXElementConstructor<any>>

iconBefore

Description

Places an icon within the button, before the button's text.

Typestring | number | ReactElement<any, string | JSXElementConstructor<any>>

interactionName

Description

An optional name used to identify this component to press listeners. For example, interaction tracing. For more information, see UFO integration into Design System components.

Typestring

isDisabled

Description

Set if the button is disabled.

Typeboolean

isLoading

Description
No description.
Typeboolean

isSelected

Description

Change the style to indicate the button is selected.

Typeboolean

onBlur

Description

Handler called on blur.

Type(event: FocusEvent<HTMLElement, Element>) => void

onClick

Description

Handler called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details.

Type(e: MouseEvent<HTMLElement, globalThis.MouseEvent>, analyticsEvent: UIAnalyticsEvent) => void

onFocus

Description

Handler called on focus.

Type(event: FocusEvent<HTMLElement, Element>) => void

ref

Description

Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

@see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}

Typestring | Ref<HTMLElement>

shouldFitContainer

Description

Option to fit button width to its parent width.

Typeboolean

spacing

Description

Set the amount of padding in the button.

Type"default" | "compact" | "none"

target

Description

Pass target down to the button. If a href is provided, this will be a semantic link styled as a button.

Type"_self" | "_blank" | "_parent" | "_top" | (string & {})

testId

Description

A testId prop is provided for specified elements, which is a unique string that appears as a data attribute data-testid in the rendered code, serving as a hook for automated tests.

Typestring

type

Description

Pass type down to the button.

Type"submit" | "reset" | "button"

Custom theme button props

The CustomThemeButton accepts all shared props (except for overlay) as well as an optional isLoading prop, and an optional theme prop.

analyticsContext

Description

Additional information to be included in the context of analytics events that come from button.

Type{ [x: string]: any; }

appearance

Description

The base styling to apply to the button.

Type"default" | "danger" | "link" | "primary" | "subtle" | "subtle-link" | "warning"

autoFocus

Description

Set the button to autofocus on mount.

Typeboolean

children

Description

Text content to be rendered in the button.

Typestring | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal

className

Description

Add a classname to the button.

Typestring

component

Description
No description.
TypeComponentType<AllHTMLAttributes<HTMLElement>> | ElementType<any, keyof JSX.IntrinsicElements>

data-has-overlay

Description
No description.
Typenever

data-testid

Description
No description.
Typenever

href

Description

Provides a URL that's used when the button is a link styled as a button.

Typestring

iconAfter

Description

Places an icon within the button, after the button's text.

Typestring | number | ReactElement<any, string | JSXElementConstructor<any>>

iconBefore

Description

Places an icon within the button, before the button's text.

Typestring | number | ReactElement<any, string | JSXElementConstructor<any>>

interactionName

Description

An optional name used to identify this component to press listeners. For example, interaction tracing. For more information, see UFO integration into Design System components.

Typestring

isDisabled

Description

Set if the button is disabled.

Typeboolean

isLoading

Description
No description.
Typeboolean

isSelected

Description

Change the style to indicate the button is selected.

Typeboolean

onBlur

Description

Handler called on blur.

Type(event: FocusEvent<HTMLElement, Element>) => void

onClick

Description

Handler called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details.

Type(e: MouseEvent<HTMLElement, globalThis.MouseEvent>, analyticsEvent: UIAnalyticsEvent) => void

onFocus

Description

Handler called on focus.

Type(event: FocusEvent<HTMLElement, Element>) => void

ref

Description
No description.
Type((instance: HTMLElement) => void) | RefObject<HTMLElement>

shouldFitContainer

Description

Option to fit button width to its parent width.

Typeboolean

spacing

Description

Set the amount of padding in the button.

Type"default" | "compact" | "none"

target

Description

Pass target down to the button. If a href is provided, this will be a semantic link styled as a button.

Type"_self" | "_blank" | "_parent" | "_top" | (string & {})

testId

Description

A testId prop is provided for specified elements, which is a unique string that appears as a data attribute data-testid in the rendered code, serving as a hook for automated tests.

Typestring

theme

Description

Slow + discouraged custom theme API See custom theme guide for usage details

Type(current: (props: ThemeProps) => ThemeTokens, props: ThemeProps) => ThemeTokens

type

Description

Pass type down to the button.

Type"submit" | "reset" | "button"
Was this page helpful?
We use this feedback to improve our documentation.
© 2026 AtlassianTrademark, (opens new window)Privacy, (opens new window)License