Button API
Import
Section titled “Import”Cimpress UI exports several different button-related components. Use the version that’s appropriate for your use case.
Button: has a visible label, performs an actionLinkButton: has a visible label, performs navigationIconButton: has no visible label (icon-only), performs an actionIconLinkButton: has no visible label (icon-only), performs navigation
import { Button, IconButton, IconLinkButton, LinkButton } from '@cimpress-ui/react';Accessibility notes
Section titled “Accessibility notes”Button and IconButton can be activated by pressing Enter or Space, similar to a native HTML button.
LinkButton and IconLinkButton can be activated by pressing Enter, similar to a native HTML link.
IconButton and IconLinkButton should have an aria-label prop defined to identify the function of the button to assistive technologies. Button and IconButton in a loading state should have a loadingLabel prop defined to identify the loading state to assistive technologies. See our accessibility guide for more details.
Buttons with a variant="tertiary" prop have a transparent background. This variant should only be used on backgrounds that provide adequate contrast.
API reference
Section titled “API reference”Button
Section titled “Button”Displays a labelled button that allows users to perform an action.
- Ref<HTMLButtonElement>
-
The
reftype for this component.
ButtonProps
- StringLikeChildren
children *
Section titled “ children * ” -
The text displayed on the button.
- 'primary' | 'secondary' | 'tertiary'
variant
Section titled “ variant ” - Defaults to 'secondary' .
Determines the visual appearance of the button.
- 'base' | 'critical'
- Defaults to 'base' .
Determines the color tone of the button.
- 'small' | 'medium' | 'large'
- Defaults to 'medium' .
The size of the button.
- boolean
fullWidth
Section titled “ fullWidth ” - Defaults to false .
Whether the button should take up the whole available width.
- ReactNode
iconStart
Section titled “ iconStart ” -
An icon displayed before the button text.
- ReactNode
iconEnd
Section titled “ iconEnd ” -
An icon displayed after the button text.
- boolean
isLoading
Section titled “ isLoading ” - Defaults to false .
Whether the button is in a loading state. This disables the button and replaces its contents with a spinner.
- string
loadingLabel
Section titled “ loadingLabel ” -
A string that identifies the loading state to assistive technologies. It will be announced by screen readers together with the button label. You must provide this prop if
isLoadingistrue. - string
-
The element's unique identifier. See MDN.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.
- string
aria-label
Section titled “ aria-label ” -
Defines a string value that labels the current element.
- string
aria-labelledby
Section titled “ aria-labelledby ” -
Identifies the element (or elements) that labels the current element.
- string
aria-describedby
Section titled “ aria-describedby ” -
Identifies the element (or elements) that describes the object.
- string
aria-details
Section titled “ aria-details ” -
Identifies the element (or elements) that provide a detailed, extended description for the object.
- boolean
isDisabled
Section titled “ isDisabled ” -
Whether the button is disabled.
- 'button' | 'reset' | 'submit'
- Defaults to 'button' .
The behavior of the button when used in an HTML form.
- string
-
The
<form>element to associate the button with. The value of this attribute must be the id of a<form>in the same document. See MDN. - string
-
Submitted as a pair with the button's value as part of the form data.
- string
value
Section titled “ value ” -
The value associated with the button's name when it's submitted with the form data.
- (e: HoverEvent) => void
onHoverStart
Section titled “ onHoverStart ” -
Handler that is called when a hover interaction starts.
- (e: HoverEvent) => void
onHoverEnd
Section titled “ onHoverEnd ” -
Handler that is called when a hover interaction ends.
- (e: PressEvent) => void
onPress
Section titled “ onPress ” -
Handler that is called when the press is released over the target.
StyleProps
- Responsive<Spacing | "auto">
margin
Section titled “ margin ” -
The amount of margin applied to all edges of this component.
- Responsive<Spacing | "auto">
marginX
Section titled “ marginX ” -
The amount of margin applied to the left and right edges of this component. Takes priority over
margin. - Responsive<Spacing | "auto">
marginY
Section titled “ marginY ” -
The amount of margin applied to the top and bottom edges of this component. Takes priority over
margin. - Responsive<Spacing | "auto">
marginTop
Section titled “ marginTop ” -
The amount of margin applied to the top edge of this component. Takes priority over
marginYandmargin. - Responsive<Spacing | "auto">
marginRight
Section titled “ marginRight ” -
The amount of margin applied to the right edge of this component. Takes priority over
marginXandmargin. - Responsive<Spacing | "auto">
marginBottom
Section titled “ marginBottom ” -
The amount of margin applied to the bottom edge of this component. Takes priority over
marginYandmargin. - Responsive<Spacing | "auto">
marginLeft
Section titled “ marginLeft ” -
The amount of margin applied to the left edge of this component. Takes priority over
marginXandmargin.
LinkButton
Section titled “LinkButton”Displays a labelled button that allows users to navigate to another page or resource.
- Ref<HTMLAnchorElement>
-
The
reftype for this component.
LinkButtonProps
- StringLikeChildren
children *
Section titled “ children * ” -
The text displayed on the button.
- string
href *
Section titled “ href * ” -
A URL to link to.
- 'primary' | 'secondary' | 'tertiary'
variant
Section titled “ variant ” - Defaults to 'secondary' .
Determines the visual appearance of the button.
- 'base' | 'critical'
- Defaults to 'base' .
Determines the color tone of the button.
- 'small' | 'medium' | 'large'
- Defaults to 'medium' .
The size of the button.
- boolean
fullWidth
Section titled “ fullWidth ” - Defaults to false .
Whether the button should take up the whole available width.
- ReactNode
iconStart
Section titled “ iconStart ” -
An icon displayed before the button text.
- ReactNode
iconEnd
Section titled “ iconEnd ” -
An icon displayed after the button text.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.
- string
aria-label
Section titled “ aria-label ” -
Defines a string value that labels the current element.
- string
aria-labelledby
Section titled “ aria-labelledby ” -
Identifies the element (or elements) that labels the current element.
- string
aria-describedby
Section titled “ aria-describedby ” -
Identifies the element (or elements) that describes the object.
- string
aria-details
Section titled “ aria-details ” -
Identifies the element (or elements) that provide a detailed, extended description for the object.
- undefined
routerOptions
Section titled “ routerOptions ” -
Options for the configured client side router.
- boolean
isDisabled
Section titled “ isDisabled ” -
Whether the link is disabled.
- string
hrefLang
Section titled “ hrefLang ” -
Hints at the human language of the linked URL. SeeMDN.
- HTMLAttributeAnchorTarget
target
Section titled “ target ” -
The target window for the link. See MDN.
- string
-
The relationship between the linked resource and the current page. See MDN.
- string | boolean
download
Section titled “ download ” -
Causes the browser to download the linked URL. A string may be provided to suggest a file name. See MDN.
- string
-
A space-separated list of URLs to ping when the link is followed. See MDN.
- HTMLAttributeReferrerPolicy
referrerPolicy
Section titled “ referrerPolicy ” -
How much of the referrer to send when following the link. See MDN.
- (e: HoverEvent) => void
onHoverStart
Section titled “ onHoverStart ” -
Handler that is called when a hover interaction starts.
- (e: HoverEvent) => void
onHoverEnd
Section titled “ onHoverEnd ” -
Handler that is called when a hover interaction ends.
StyleProps
- Responsive<Spacing | "auto">
margin
Section titled “ margin ” -
The amount of margin applied to all edges of this component.
- Responsive<Spacing | "auto">
marginX
Section titled “ marginX ” -
The amount of margin applied to the left and right edges of this component. Takes priority over
margin. - Responsive<Spacing | "auto">
marginY
Section titled “ marginY ” -
The amount of margin applied to the top and bottom edges of this component. Takes priority over
margin. - Responsive<Spacing | "auto">
marginTop
Section titled “ marginTop ” -
The amount of margin applied to the top edge of this component. Takes priority over
marginYandmargin. - Responsive<Spacing | "auto">
marginRight
Section titled “ marginRight ” -
The amount of margin applied to the right edge of this component. Takes priority over
marginXandmargin. - Responsive<Spacing | "auto">
marginBottom
Section titled “ marginBottom ” -
The amount of margin applied to the bottom edge of this component. Takes priority over
marginYandmargin. - Responsive<Spacing | "auto">
marginLeft
Section titled “ marginLeft ” -
The amount of margin applied to the left edge of this component. Takes priority over
marginXandmargin.
IconButton
Section titled “IconButton”Displays an icon-only button that allows users to perform an action.
- Ref<HTMLButtonElement>
-
The
reftype for this component.
IconButtonProps
- ReactNode
icon *
Section titled “ icon * ” -
The icon displayed on the button.
- string
aria-label *
Section titled “ aria-label * ” -
The label describing the function of this button for assistive technologies.
- 'primary' | 'secondary' | 'tertiary'
variant
Section titled “ variant ” - Defaults to 'secondary' .
Determines the visual appearance of the button.
- 'base' | 'critical'
- Defaults to 'base' .
Determines the color tone of the button.
- 'small' | 'medium' | 'large'
- Defaults to 'medium' .
The size of the button.
- boolean
fullWidth
Section titled “ fullWidth ” - Defaults to false .
Whether the button should take up the whole available width.
- boolean
isLoading
Section titled “ isLoading ” - Defaults to false .
Whether the button is in a loading state. This disables the button and replaces its contents with a spinner.
- string
loadingLabel
Section titled “ loadingLabel ” -
A string that identifies the loading state to assistive technologies. It will be announced by screen readers together with the button label. You must provide this prop if
isLoadingistrue. - string
-
The element's unique identifier. See MDN.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.
- string
aria-labelledby
Section titled “ aria-labelledby ” -
Identifies the element (or elements) that labels the current element.
- string
aria-describedby
Section titled “ aria-describedby ” -
Identifies the element (or elements) that describes the object.
- string
aria-details
Section titled “ aria-details ” -
Identifies the element (or elements) that provide a detailed, extended description for the object.
- boolean
isDisabled
Section titled “ isDisabled ” -
Whether the button is disabled.
- 'button' | 'reset' | 'submit'
- Defaults to 'button' .
The behavior of the button when used in an HTML form.
- string
-
The
<form>element to associate the button with. The value of this attribute must be the id of a<form>in the same document. See MDN. - string
-
Submitted as a pair with the button's value as part of the form data.
- string
value
Section titled “ value ” -
The value associated with the button's name when it's submitted with the form data.
- (e: HoverEvent) => void
onHoverStart
Section titled “ onHoverStart ” -
Handler that is called when a hover interaction starts.
- (e: HoverEvent) => void
onHoverEnd
Section titled “ onHoverEnd ” -
Handler that is called when a hover interaction ends.
- (e: PressEvent) => void
onPress
Section titled “ onPress ” -
Handler that is called when the press is released over the target.
StyleProps
- Responsive<Spacing | "auto">
margin
Section titled “ margin ” -
The amount of margin applied to all edges of this component.
- Responsive<Spacing | "auto">
marginX
Section titled “ marginX ” -
The amount of margin applied to the left and right edges of this component. Takes priority over
margin. - Responsive<Spacing | "auto">
marginY
Section titled “ marginY ” -
The amount of margin applied to the top and bottom edges of this component. Takes priority over
margin. - Responsive<Spacing | "auto">
marginTop
Section titled “ marginTop ” -
The amount of margin applied to the top edge of this component. Takes priority over
marginYandmargin. - Responsive<Spacing | "auto">
marginRight
Section titled “ marginRight ” -
The amount of margin applied to the right edge of this component. Takes priority over
marginXandmargin. - Responsive<Spacing | "auto">
marginBottom
Section titled “ marginBottom ” -
The amount of margin applied to the bottom edge of this component. Takes priority over
marginYandmargin. - Responsive<Spacing | "auto">
marginLeft
Section titled “ marginLeft ” -
The amount of margin applied to the left edge of this component. Takes priority over
marginXandmargin.
IconLinkButton
Section titled “IconLinkButton”Displays an icon-only button that allows users to navigate to another page or resource.
- Ref<HTMLAnchorElement>
-
The
reftype for this component.
IconLinkButtonProps
- ReactNode
icon *
Section titled “ icon * ” -
The icon displayed on the button.
- string
aria-label *
Section titled “ aria-label * ” -
The label describing the function of this button for assistive technologies.
- string
href *
Section titled “ href * ” -
A URL to link to.
- 'primary' | 'secondary' | 'tertiary'
variant
Section titled “ variant ” - Defaults to 'secondary' .
Determines the visual appearance of the button.
- 'base' | 'critical'
- Defaults to 'base' .
Determines the color tone of the button.
- 'small' | 'medium' | 'large'
- Defaults to 'medium' .
The size of the button.
- boolean
fullWidth
Section titled “ fullWidth ” - Defaults to false .
Whether the button should take up the whole available width.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.
- string
aria-labelledby
Section titled “ aria-labelledby ” -
Identifies the element (or elements) that labels the current element.
- string
aria-describedby
Section titled “ aria-describedby ” -
Identifies the element (or elements) that describes the object.
- string
aria-details
Section titled “ aria-details ” -
Identifies the element (or elements) that provide a detailed, extended description for the object.
- undefined
routerOptions
Section titled “ routerOptions ” -
Options for the configured client side router.
- boolean
isDisabled
Section titled “ isDisabled ” -
Whether the link is disabled.
- string
hrefLang
Section titled “ hrefLang ” -
Hints at the human language of the linked URL. SeeMDN.
- HTMLAttributeAnchorTarget
target
Section titled “ target ” -
The target window for the link. See MDN.
- string
-
The relationship between the linked resource and the current page. See MDN.
- string | boolean
download
Section titled “ download ” -
Causes the browser to download the linked URL. A string may be provided to suggest a file name. See MDN.
- string
-
A space-separated list of URLs to ping when the link is followed. See MDN.
- HTMLAttributeReferrerPolicy
referrerPolicy
Section titled “ referrerPolicy ” -
How much of the referrer to send when following the link. See MDN.
- (e: HoverEvent) => void
onHoverStart
Section titled “ onHoverStart ” -
Handler that is called when a hover interaction starts.
- (e: HoverEvent) => void
onHoverEnd
Section titled “ onHoverEnd ” -
Handler that is called when a hover interaction ends.
StyleProps
- Responsive<Spacing | "auto">
margin
Section titled “ margin ” -
The amount of margin applied to all edges of this component.
- Responsive<Spacing | "auto">
marginX
Section titled “ marginX ” -
The amount of margin applied to the left and right edges of this component. Takes priority over
margin. - Responsive<Spacing | "auto">
marginY
Section titled “ marginY ” -
The amount of margin applied to the top and bottom edges of this component. Takes priority over
margin. - Responsive<Spacing | "auto">
marginTop
Section titled “ marginTop ” -
The amount of margin applied to the top edge of this component. Takes priority over
marginYandmargin. - Responsive<Spacing | "auto">
marginRight
Section titled “ marginRight ” -
The amount of margin applied to the right edge of this component. Takes priority over
marginXandmargin. - Responsive<Spacing | "auto">
marginBottom
Section titled “ marginBottom ” -
The amount of margin applied to the bottom edge of this component. Takes priority over
marginYandmargin. - Responsive<Spacing | "auto">
marginLeft
Section titled “ marginLeft ” -
The amount of margin applied to the left edge of this component. Takes priority over
marginXandmargin.