Swarm Design System Documentation

Button


Buttons are a fundamental component and primarily how users trigger actions. They can be customized by sizes and color to communicate importance and content heirarchy.



Default

This style is the most common in the product and is a good starting point in many cases.

Primary

Use this style for the most important actions within an experience. Only one primary button should be used per screen.

Neutral

To reduce the visual weight and importance of a button, use this style.

Bordered

This style has the least visual weight, while still maintaining a button aesthetic.

Inverted

Use this style when an action must be overlayed on an image or a dark or saturated background.

Disabled

When an action is not available to the user, use this style.

Buttons with icons

Icons can easily be added to any button size. The icon can be configured to appear to the right or left, as well as on its own.

Text only buttons

It is also possible to reset the button style to remove its inherent visual properties.




<>
  <Button>Default</Button>
  <Button primary>Primary</Button>
  <Button neutral>Neutral</Button>
  <Button bordered>Bordered</Button>
  <Button icon="send">Send message</Button>
  <Button large iconOnly>
    <Search/>
  </Button>
  <br/><br/>
  <Button neutral grow icon="InfoCircled">Fill the space</Button>
</>




Props


NameTypeRequired?DefaultDescription
bordered
booleanoptionalnoneThe bordered button
className
stringoptionalnoneClasses for additional styles to be applied
disabled
booleanoptionalnoneIndicates whether the button is disabled or not
icon
stringoptionalnoneSupports solid icon shapes found at https://swarm-docs.now.sh/Foundations/Icons. This is the recommended way to use icons in buttons.
iconOnly
booleanoptionalnoneSupports icon only padding for using icons as children rather than by passing an icon prop. Using the icon prop is preferred.
reset
booleanoptionalnoneStrips all styles from the button
inverted
booleanoptionalnoneInverted styles for dark backgrounds
neutral
booleanoptionalnoneThe neutral style
onClick
signatureoptionalnoneThe function invoked when interacting with Button
primary
booleanoptionalnoneThe primary style
right
booleanoptionalnoneAligns the icon to the right
size
unionoptionalnoneThe size of the button. supports "small", "large", & "default"
large
booleanoptionalnoneThe large button size
small
booleanoptionalnoneUse the small button size
grow
booleanoptionalnoneGrow button to 100% width (full width)
forwardedRef
unionoptionalnone
children
ReactReactNodeoptionalnoneContent of button


Anatomy

All button styles and sizes share the same anatomy.



Label

Button labels should be short and actionable. Label attributes are driven by the selected button style and size.

Border

All buttons have a solid 1px border, though some styles require the same color for background and border, hiding the presence of the border.

Background

Button style determines its background color and opacity.

Radius

All buttons in all sizes and viewports have an 8px border radius.



Sizing


Size & Height

Any button can be configured to one of three distinct sizes. Size dictates label text style and top/bottom padding. Button padding uses spacing variables which are dynamic based on viewport.





Width

Buttons will inherit their left and right padding from their size. Use the grow attribute to expand a button to fill its container.






a11y


Keyboard interactions

The button action should be triggered by the enter and space keys.




Content Guidelines


Button labels

Should clearly indicate what will happen if the user clicks on them. They should be easy to scan and comprehend.


  • Keep it scannable: Avoid articles like "a" and "the"
  • Use sentence case
  • Don't use first person to speak from the user's point of view (Sign up vs. Sign me up!)
  • No ampersands or end punctuation (Agree and continue vs. Agree & continue)
  • Make priorities clear: Never present the user with more than one primary action
alert--smallalertannounce--smallannouncearchive--smallarchivearrow-left--smallarrow-leftarrow-right--smallarrow-rightaudio--smallaudiobadge--smallbadgeblock--smallblockbolt--smallboltcalendar--smallcalendar-check--smallcalendar-checkcalendar-cross--smallcalendar-crosscalendar-plus--smallcalendar-pluscalendarcamera--smallcameracheck--smallcheck-circle--smallcheck-circlecheckchevron-down--smallchevron-downchevron-left--smallchevron-leftchevron-right--smallchevron-rightchevron-up--smallchevron-upclock--smallclock-arrow--smallclock-arrowclockcog--smallcogconversation--smallconversationcopy--smallcopycreditcard--smallcreditcardcross--smallcross-circle--smallcross-circlecross-circled--smallcross-circledcrossdownload--smalldownloaddrinks--smalldrinksedit--smalleditexport--smallexportexternal-facebookexternal-facebookboxedexternal-flickrexternal-gmailexternal-instagramexternal-linkedinexternal-mediumexternal-messenger-outlined--smallexternal-messenger-outlinedexternal-outlookexternal-tumblrexternal-twitter-outlined--smallexternal-twitter-outlinedexternal-twitterexternal-yahooexternal-youtubefilter--smallfilterfolder--smallfolderglobe--smallglobegrid--smallgridgroups--smallgroupsheart--smallheart-outline--smallheart-outlinehearthide--smallhidehome--smallhomeinfo--smallinfoinvite--smallinvite-filled--smallinvite-filledinvitelaunch-new-window--smalllaunch-new-windowlink--smalllinklist--smalllistlocation-pin--smalllocation-pin-filled--smalllocation-pin-filledlocation-pin-slashed--smalllocation-pin-slashedlocation-pinlocation-services--smalllocation-serviceslock--smalllockmail--smallmailmeetup-m--smallmeetup-mmessages--smallmessagesmicrophone--smallmicrophoneminus--smallminusnotifications--smallnotifications-badged--smallnotifications-badgednotifications-mute--smallnotifications-mutenotificationsoverflow--smalloverflow-vertical--smalloverflow-verticaloverflowphoto-album--smallphoto-album-add--smallphoto-album-addphoto-albumplay--smallplayplus--smallplus-circle--smallplus-circleplusprofile--smallprofileprofiles--smallprofilesprojector--smallprojectorpulse--smallpulserefresh--smallrefreshreply--smallreplysearch--smallsearchsend--smallsendsent-messages--smallsent-messagesshow--smallshowsort-direction--smallsort-directionstar--smallstar-rounded--smallstar-roundedstartextblock--smalltextblockticket--smalltickettrash--smalltrashtune--smalltunetv--smalltvupdates--smallupdateswifi--smallwifi