Admin Button

A button component using the admin colors

Props

PropTypeDefaultDescription
childrennodeThe content of the button.
aria-labelstringAn accessible label for the button.
data-testidstringA data-testid for the button.
loadingboolfalseIf true, the button will be in a loading state.
componentelementType'button'The component used for the root node. Either a string to use a HTML element or a component.
disabledboolfalseIf true, the button will be disabled.
disableElevationboolfalseIf true, no elevation is used.
disableFocusRippleboolfalseIf true, the keyboard focus ripple will be disabled.
disableRippleboolIf true, the ripple effect will be disabled. ⚠️ Without a ripple there is no styling for :focus-visible by default. Be sure to highlight the element by applying separate styles with the focusVisibleClassName.
endIconnodeElement placed after the children.
fullWidthboolfalseIf true, the button will take up the full width of its container.
hrefstringThe URL to link to when the button is clicked. If defined, an a element will be used as the root node.
size 'small' | 'medium' | 'large''medium'The size of the button. small is equivalent to the dense button styling.
startIconnodeElement placed before the children.
variant'contained' | 'outlined' | 'text''contained'The variant to use.
adminColorboolfalseIf true, semantic blue color is considered as primary color

Examples

Simple

<AdminButton
sx={{mr: 4}}
onClick={() => console.log('clicked primary')}
>
Primary
</AdminButton>
<AdminButton
disabled
onClick={() => console.log('clicked primary')}
>
Primary
</AdminButton>

Accessibility & Testing

<AdminButton aria-label="primary" data-testid="admin:primary">
data-testid and aria-label
</AdminButton>

Icon

<AdminButton
sx={{ mr: 4 }}
onClick={() => console.log('clicked primary')}
startIcon={<Trophy />}
>
Start Icon
</AdminButton>
<AdminButton
sx={{ mr: 4 }}
onClick={() => console.log('clicked primary')}
endIcon={<Trophy />}
>
End Icon
</AdminButton>

Button with Dot loader

() => {
const [loading, setLoading] = React.useState(false);
const onClick = () => {
setLoading(!loading);
};
return (
<AdminButton loading={loading} onClick={onClick}>
Click Me
</AdminButton>
);
};