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.
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.
| Description | Additional information to be included in the |
|---|---|
| Type | { [x: string]: any; } |
| Description | The base styling to apply to the button. |
|---|---|
| Type | "default" | "danger" | "link" | "primary" | "subtle" | "subtle-link" | "warning" |
| Description | Set the button to autofocus on mount. |
|---|---|
| Type | boolean |
| Description | Text content to be rendered in the button. |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | Add a classname to the button. |
|---|---|
| Type | string |
| Description | No description. |
|---|---|
| Type | ComponentType<AllHTMLAttributes<HTMLElement>> | ElementType<any, keyof JSX.IntrinsicElements> |
| Description | No description. |
|---|---|
| Type | never |
| Description | No description. |
|---|---|
| Type | never |
| Description | Provides a URL that's used when the button is a link styled as a button. |
|---|---|
| Type | string |
| Description | Places an icon within the button, after the button's text. |
|---|---|
| Type | string | number | ReactElement<any, string | JSXElementConstructor<any>> |
| Description | Places an icon within the button, before the button's text. |
|---|---|
| Type | string | number | ReactElement<any, string | JSXElementConstructor<any>> |
| 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. |
|---|---|
| Type | string |
| Description | Set if the button is disabled. |
|---|---|
| Type | boolean |
| Description | Change the style to indicate the button is selected. |
|---|---|
| Type | boolean |
| Description | Handler called on blur. |
|---|---|
| Type | (event: FocusEvent<HTMLElement, Element>) => void |
| 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 |
| Description | Handler called on focus. |
|---|---|
| Type | (event: FocusEvent<HTMLElement, Element>) => void |
| Description | Used to 'overlay' something over a button. This is commonly used to display a loading spinner. |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | No description. |
|---|---|
| Type | ((instance: HTMLElement) => void) | RefObject<HTMLElement> |
| Description | Option to fit button width to its parent width. |
|---|---|
| Type | boolean |
| Description | Set the amount of padding in the button. |
|---|---|
| Type | "default" | "compact" | "none" |
| 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 & {}) |
| Description | A |
|---|---|
| Type | string |
| Description | Pass type down to the button. |
|---|---|
| Type | "submit" | "reset" | "button" |
The LoadingButton accepts all shared props (except for overlay) as well as an optional
isLoading prop.
| Description | Additional information to be included in the |
|---|---|
| Type | { [x: string]: any; } |
| Description | The base styling to apply to the button. |
|---|---|
| Type | "default" | "danger" | "link" | "primary" | "subtle" | "subtle-link" | "warning" |
| Description | Set the button to autofocus on mount. |
|---|---|
| Type | boolean |
| Description | Text content to be rendered in the button. |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | Add a classname to the button. |
|---|---|
| Type | string |
| Description | No description. |
|---|---|
| Type | ComponentType<AllHTMLAttributes<HTMLElement>> | ElementType<any, keyof JSX.IntrinsicElements> |
| Description | No description. |
|---|---|
| Type | never |
| Description | No description. |
|---|---|
| Type | never |
| Description | Provides a URL that's used when the button is a link styled as a button. |
|---|---|
| Type | string |
| Description | Places an icon within the button, after the button's text. |
|---|---|
| Type | string | number | ReactElement<any, string | JSXElementConstructor<any>> |
| Description | Places an icon within the button, before the button's text. |
|---|---|
| Type | string | number | ReactElement<any, string | JSXElementConstructor<any>> |
| 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. |
|---|---|
| Type | string |
| Description | Set if the button is disabled. |
|---|---|
| Type | boolean |
| Description | No description. |
|---|---|
| Type | boolean |
| Description | Change the style to indicate the button is selected. |
|---|---|
| Type | boolean |
| Description | Handler called on blur. |
|---|---|
| Type | (event: FocusEvent<HTMLElement, Element>) => void |
| 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 |
| Description | Handler called on focus. |
|---|---|
| Type | (event: FocusEvent<HTMLElement, Element>) => void |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLElement> |
| Description | Option to fit button width to its parent width. |
|---|---|
| Type | boolean |
| Description | Set the amount of padding in the button. |
|---|---|
| Type | "default" | "compact" | "none" |
| 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 & {}) |
| Description | A |
|---|---|
| Type | string |
| Description | Pass type down to the button. |
|---|---|
| Type | "submit" | "reset" | "button" |
The CustomThemeButton accepts all shared props (except for overlay) as well as an optional
isLoading prop, and an optional theme prop.
| Description | Additional information to be included in the |
|---|---|
| Type | { [x: string]: any; } |
| Description | The base styling to apply to the button. |
|---|---|
| Type | "default" | "danger" | "link" | "primary" | "subtle" | "subtle-link" | "warning" |
| Description | Set the button to autofocus on mount. |
|---|---|
| Type | boolean |
| Description | Text content to be rendered in the button. |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | Add a classname to the button. |
|---|---|
| Type | string |
| Description | No description. |
|---|---|
| Type | ComponentType<AllHTMLAttributes<HTMLElement>> | ElementType<any, keyof JSX.IntrinsicElements> |
| Description | No description. |
|---|---|
| Type | never |
| Description | No description. |
|---|---|
| Type | never |
| Description | Provides a URL that's used when the button is a link styled as a button. |
|---|---|
| Type | string |
| Description | Places an icon within the button, after the button's text. |
|---|---|
| Type | string | number | ReactElement<any, string | JSXElementConstructor<any>> |
| Description | Places an icon within the button, before the button's text. |
|---|---|
| Type | string | number | ReactElement<any, string | JSXElementConstructor<any>> |
| 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. |
|---|---|
| Type | string |
| Description | Set if the button is disabled. |
|---|---|
| Type | boolean |
| Description | No description. |
|---|---|
| Type | boolean |
| Description | Change the style to indicate the button is selected. |
|---|---|
| Type | boolean |
| Description | Handler called on blur. |
|---|---|
| Type | (event: FocusEvent<HTMLElement, Element>) => void |
| 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 |
| Description | Handler called on focus. |
|---|---|
| Type | (event: FocusEvent<HTMLElement, Element>) => void |
| Description | No description. |
|---|---|
| Type | ((instance: HTMLElement) => void) | RefObject<HTMLElement> |
| Description | Option to fit button width to its parent width. |
|---|---|
| Type | boolean |
| Description | Set the amount of padding in the button. |
|---|---|
| Type | "default" | "compact" | "none" |
| 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 & {}) |
| Description | A |
|---|---|
| Type | string |
| Description | Slow + discouraged custom theme API See custom theme guide for usage details |
|---|---|
| Type | (current: (props: ThemeProps) => ThemeTokens, props: ThemeProps) => ThemeTokens |
| Description | Pass type down to the button. |
|---|---|
| Type | "submit" | "reset" | "button" |