Skip to main content
K
Last modified: 24/Jun/2024

IconButton

Use the IconButton component for simple interactions that doesn't need labeling, like "Copy text" or format options like "Insert link". Use the nested hover tooltip to describe the action or show the shortcut.

#Usage

Note that the IconButton needs either a tooltip or an ariaLabel because of accessibility reasons.

#IconButton with tooltip

import { IconButton } from '@kinsta/stratus' const MyComponent = () => ( <> <IconButton icon="Wrench" tooltip="This is a wrench" /> </> )

#IconButton with aria-label

import { IconButton } from '@kinsta/stratus' const MyComponent = () => ( <> <IconButton icon="Wrench" ariaLabel="This is a wrench" /> </> )

#Props

The IconButton components interface extends the HTMLButtonElement interface. So you can use any props which documented there. Also, you can utilize all the React Synthetic events (on*), and props related to styling (className, style).

#icon
Required
IconName
Sets the type of the icon
#size
"xs" ǀ "s" ǀ "m" ǀ "l"
Sets the size, defines how much space takes on the UI
#tooltip
React.ReactNode
Tooltip of the button. Required if ariaLabel is not provided
#ariaLabel
React.ReactNode
ARIA label of the button. Required if tooltip is not provided
#isDisabled
boolean
Sets the disabled state of button - Defaults to false
#isLoading
boolean
Sets the loading status of button - Defaults to false
#htmlType
"button" ǀ "submit" ǀ "reset"
Indicates the behavior of the button - Defaults to 'button'
#type
"primary" ǀ "secondary" ǀ "tertiary" ǀ "danger"
Sets the type of the icon button - Defaults to tertiary

#Types

  • IconName: visit the Icon's docs for more info.
  • IconButtonProps: props of the IconButtonProps component processed by stratus.
  • IconButtonInterface: IconButtonProps extended by HTMLAttributes<HTMLButtonElement >.

Read more about types here


#See also