This is the default variant for the Button component.
<Button>Default</Button>
Danger button
The danger variant of Button is used to warn users about potentially destructive actions
<Buttonvariant="danger">Danger</Button>
Outline button
The outline variant of Button is typically used as a secondary button
<Buttonvariant="outline">Outline</Button>
Invisible button
The invisible variant of Button indicates that the action is a low priority one.
<Buttonvariant="invisible">Invisible</Button>
Different sized buttons
Button component supports three different sizes. small, medium, large.
<>
<Buttonsize="small">Search</Button>
<Buttonsx={{mt:2}}>Search</Button>
<Buttonsx={{mt:2}}size="large">
Search
</Button>
</>
Appending an icon
We can place an icon inside the Button in either the leading or the trailing position to enhance the visual context.
It is recommended to use an octicon here.
A common use case for primer is a button with a counter component which shows the child count value.
We provide Button.Counter as a composite component which requires you to provide a number as child.
The counter will match the variant styles of the parent button.
<Button>
Watch
<Button.Counter>1</Button.Counter>
</Button>
Styling a button
A button can be styled in an appropriate manner using the sx prop. This may be to change width, or to add margins etc.
Here's an example of a block button which takes 100% of available width. Checkout styled-system to see what you can send in an sx prop.
<Buttonsx={{width:'100%'}}>Block</Button>
API reference
Native <button> HTML attributes are forwarded to the underlying React button component and are not listed below.
Button
Name
Type
Default
Description
children Required
React.ReactNode
Button description along with other components like Counter could be used here.