IconButton
composes the Button component except that it renders only an icon.
Import
import { IconButton } from '@contentful/f36-components';// orimport { IconButton } from '@contentful/f36-button';
Examples
Sizes and Variations
You need to pass an Icon component you want to render to the icon
prop, you may also provide variant
and size
to the icon.
As toolbar actions
In toolbars, action bars, and in all other space restricted containers we suggest using IconButton
instead of Button
component.
For these cases, it would be also beneficial to use Tooltip as a wrapper of IconButton
to help users with understanding the button's purpose.
Props (API reference)
- Name
aria-label(required)
DescriptionAria label is required when using icon only
string - Name
icon(required)
DescriptionExpects any of the icon components
ReactElement<any, string | JSXElementConstructor<any>> - Name
as
DescriptionThe element used for the root node.
HTML Tag or React Component (e.g. div, span, etc) - Name
children
ReactNode - Name
className
DescriptionCSS class to be appended to the root element
string - Name
isActive
DescriptionApplies active styles
falsetrue - Name
isDisabled
DescriptionDisabled interaction and applies disabled styles
falsetrue - Name
isFullWidth
DescriptionForces button to take 100% of the container
falsetrue - Name
isLoading
DescriptionAdds loading indicator icon and disables interactions
falsetrue - Name
size
DescriptionDetermines size variation of Button component
"small""medium""large" - Name
testId
DescriptionA [data-test-id] attribute used for testing purposes
string - Name
variant
DescriptionDetermines style variation of Button component
"negative""positive""primary""secondary""transparent"
Accessibility
We enforce aria-label
property for IconButton
component to ensure that these buttons are fully accessible for screen readers.