Examples
Variant examples
PatternFly supports several button styling variants to be used in different scenarios as needed. The following button variants can be assigned using the variant
property.
Variant | Description |
---|---|
Primary | Primary buttons are the most visually prominent variant. Use for the most important call to action. |
Secondary | Secondary buttons are less visually prominant than primary buttons. Use for general actions on a page that require less emphasis than primary buttons. |
Tertiary | Tertiary buttons are the least visually prominent variant. Use to retain a classic button format with less emphasis than primary or secondary buttons. |
Danger | Danger buttons may be used for actions that are potentially destructive or difficult/impossible to undo. Danger is an independent variant, but all button variants may use the the isDanger property to apply similar styling. |
Warning | Warning buttons may be used for actions that change an important setting or behavior, but not in a destructive or irreversible way. |
Link | Links are labeled, but have no background or border. Use for actions that require less emphasis, actions that navigate users to another page within the same window, and/or actions that navigate to external pages in a new window. Links may be placed inline with text using the isInline property. |
Plain | Plain buttons have no styling and are intended to be labeled with icons. |
Control | Control buttons can be labeled with text or icons. Primarily intended to be paired with other controls in an input group. |
Stateful | Stateful buttons are ideal for displaying the state of notifications. They have 3 states: read , unread and attention . |
Disabled buttons
To indicate that an action is currently unavailable, all button variations can be disabled using the isDisabled
property.
Small buttons
To fit into tight spaces, primary, secondary, tertiary, danger, and warning button variations can be made smaller using the "sm"
value for the size
property.
Call to action (CTA) buttons
CTA buttons and links direct users to complete an action. Primary, secondary, tertiary, and link button variants can be styled as CTAs using the "lg"
value for the size
property.
Block level buttons
Block level buttons span the full width of the parent element and can be enabled using the isBlock
property.
Progress indicators
Progress indicators can be added to buttons to identify that an action is in progress after a click.
Links as buttons
Buttons that link to another resource may take the form of primary, secondary, tertiary, or link variants. Use component="a"
and an href
property to designate the button's target link.
Inline link as span
Inline links should use component="span"
and the isInline
property to wrap inline with surrounding text.
Router link
Router links can be used for in-app linking in React environments to prevent page reloading.
Aria-disabled examples
Accessible Rich Internet Applications (ARIA) is a set of roles and attributes specified by the World Wide Web Consortium. ARIA defines ways to make web content and web applications more accessible to people with disabilities.
Buttons that are aria-disabled are similar to normal disabled buttons, except they can receive focus. Every button variant can be aria-disabled using the isAriaDisabled
property.
Unlike normal disabled buttons, aria-disabled buttons can support tooltips. Furthermore, aria-disabled buttons can operate as links, which also support tooltips.
Button with count
Buttons can display a count
in the form of a badge to indicate some value or number by passing in the countOptions
prop as a BadgeCountObject
object. The BadgeCountObject
object will handle count
, isRead
, and className
props for the badge count.
Plain with no padding
To display a plain/icon button inline with text, use noPadding
prop in addition to variant="plain"
.
Stateful
Stateful buttons are ideal for displaying the state of notifications. Use variant="stateful"
alongside with the state
property, which can have these 3 values: read
, unread
(used as default) and attention
(which means unread and requires attention).
Props
Button
Name | Type | Default | Description |
---|---|---|---|
aria-label | string | Adds accessible text to the button. | |
children | React.ReactNode | Content rendered inside the button | |
className | string | Additional classes added to the button | |
component | React.ElementType<any> | React.ComponentType<any> | Sets the base component to render. defaults to button | |
countOptions | BadgeCountObject | Adds count number to button | |
hasNoPadding | boolean | Applies no padding on a plain button variant. Use when plain button is placed inline with text | |
icon | React.ReactNode | null | Icon for the button. Usable by all variants except for plain. | |
iconPosition | 'start' | 'end' | 'left' | 'right' | Sets position of the icon. Note: "left" and "right" are deprecated. Use "start" and "end" instead | |
inoperableEvents | string[] | Events to prevent when the button is in an aria-disabled state | |
isAriaDisabled | boolean | Adds disabled styling and communicates that the button is disabled using the aria-disabled html attribute | |
isBlock | boolean | Adds block styling to button | |
isClicked | boolean | Adds clicked styling to button. | |
isDanger | boolean | Adds danger styling to secondary or link button variants | |
isDisabled | boolean | Adds disabled styling and disables the button using the disabled html attribute | |
isInline | boolean | Adds inline styling to a link button | |
isLoading | boolean | Adds progress styling to button | |
ouiaId | number | string | Value to overwrite the randomly generated data-ouia-component-id. | |
ouiaSafe | boolean | Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. | |
size | 'default' | 'sm' | 'lg' | Adds styling which affects the size of the button | |
spinnerAriaLabel | string | Accessible label for the spinner to describe what is loading | |
spinnerAriaLabelledBy | string | Id of element which describes what is being loaded | |
spinnerAriaValueText | string | Text describing that current loading status or progress | |
state | 'read' | 'unread' | 'attention' | Sets state of the stateful button variant. Default is "unread" | |
tabIndex | number | Sets the button tabindex. | |
type | 'button' | 'submit' | 'reset' | Sets button type | |
variant | 'primary' | 'secondary' | 'tertiary' | 'danger' | 'warning' | 'link' | 'plain' | 'control' | 'stateful' | Adds button variant styles |
BadgeCountObject
Name | Type | Default | Description |
---|---|---|---|
className | string | Additional classes added to the badge count | |
count | number | Adds count number right of button | |
isRead | boolean | Adds styling to the badge to indicate it has been read |
CSS variables
Expand or collapse column | Selector | Variable | Value |
---|