You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@asphalt-react/button

Package Overview
Dependencies
Maintainers
3
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asphalt-react/button

Button

npmnpm
Version
1.17.0
Version published
Weekly downloads
1K
9.05%
Maintainers
3
Weekly downloads
 
Created
Source

Button

Buttons provides a way to trigger an action. The caption of a Button should hint what action will occur. Buttons come in 3 sizes: small, medium and large. Along with the main component, Button provides 4 named exports:

  • IconButton
  • ToggleButton
  • ButtonLink
  • IconButtonLink

Buttons can render an icon or text before or after the caption.

Buttons except ToggleButtons:

💡

Don't use outline buttons as an alternative to secondary buttons. Only secondary buttons should be used with primary buttons.

All buttons accept most button attributes.

Accessibility considerations

  • All buttons are focusable and support keyboard navigation; tab (or shift+tab when tabbing backwards)
  • space and enter keyboard shortcuts trigger the buttons when in focus; toggles the state of ToggleButton.
  • ToggleButton has a role of “switch”.
  • The state of ToggleButton determines the value of aria-checked attribute.
  • Add aria-label or aria-labelledby in IconButton & icon-only variant of ToggleButton to help assitive technologies.
  • enter keyboard shortcut triggers the link buttons when in focus.
  • All buttons accept the button aria-* attributes.
  • Both link buttons accept the link aria-* attributes.

Props

children

React node for button's caption

typerequireddefault
nodetrueN/A

size

Controls size of button. Possible values are "s", "m", "l" for small, medium & large respectively

typerequireddefault
enumfalse"m"

stretch

Button matches width of it's container

typerequireddefault
boolfalsefalse

nude

Renders a nude button

typerequireddefault
boolfalsefalse

primary

Applies primary brand color

typerequireddefault
boolfalseN/A

secondary

Renders a secondary button

typerequireddefault
boolfalseN/A

outline

Renders an outline button

typerequireddefault
boolfalseN/A

danger

Renders as danger button

typerequireddefault
boolfalseN/A

qualifier

Qualifiers provide a hint about the action a button will perform. Appends (default) or prepends an icon to the button's caption. Accepts SVG or string.

Checkout @asphalt-react/iconpack for SVG wrapped React components.

typerequireddefault
unionfalsenull

qualifierStart

Renders qualifier before the button's caption

typerequireddefault
boolfalsetrue

qualifierEnd

Renders qualifier after the button's caption. Has priority over qualifierStart.

typerequireddefault
boolfalsefalse

IconButton

IconButton provides a way to render an icon as a button.

Props

icon

Renders an icon for the caption. Accepts an inline SVG or SVG wrapped React component

typerequireddefault
elementtrueN/A

primary

Applies primary brand color

typerequireddefault
boolfalseN/A

danger

Renders as danger button

typerequireddefault
boolfalseN/A

nude

Renders a nude icon button

typerequireddefault
boolfalsefalse

size

Determines the size. Possible values are "s", "m", "l" for small, medium & large respectively/

typerequireddefault
enumfalse"m"

ToggleButton

A ToggleButton is a digital switch to turn an option on or off. Switching between the states — as a result of direct user action or a programmatic event — should produce an immediate result. The caption should always reflect the current logical state of the button.

There are two variants:

  • text-only
  • icon-only

ToggleButton vs Checkbox

Similar to ToggleSwitches, ToggleButtons are not an alternative to Checkboxes. They are not form controls and should not appear inside a form. ToggleButtons should only manipulate local UI states, i.e. they should not directly or indirectly initiate a remote API call to change database states.

ToggleButton vs ToggleSwitch

Both of them provide options to toggle between states. Consider the following points to choose between them:

  • Prefer ToggleSwitches to toggle states on mobile; they support swipe gestures
  • ToggleButtons fit better in designs with space constraints
  • Use ToggleButtons to programmatically toggle the state. For example, you can bind a keyboard shortcut to a mute button in a video player.

Props

text

Label for text-only variant

typerequireddefault
stringfalseN/A

icon

Icon for icon-only variant. Accepts SVG or SVG wrapped React component

Note: icon prop overrides text prop

typerequireddefault
nodefalseN/A

children

React node for caption

Note: Both icon and text props override children

typerequireddefault
nodefalseN/A

on

Sets the state of button

typerequireddefault
boolfalsefalse

size

Sets the size of button. Possible values are "s", "m", "l" for small, medium & large respectively

typerequireddefault
enumfalse"m"

ButtonLink is a semantic link element styled as a Button component.

It supports two variants - Primary & Secondary. It can also render an icon (qualifier) along with the caption. There are three sizes available - small, medium & large.

ButtonLink detects target="_blank" in the props and adds an icon hinting users that the link will open in a new tab (or window). However, you can provide your custom icon via qualifier prop to override this default behavior.

Security and privacy risks

When a link opens in a new tab, users' security and privacy may be at risk. To prevent this both ButtonLink and IconButtonLink checks the value of target attribute and adds rel="noreferrer" (why not rel="noopener noreferrer") if the value is other than _self, _top or _parent. To override this default behavior, you can pass a rel attribute in tagProps prop.

Props

children

React node for the caption.

typerequireddefault
nodetrueN/A

tagProps

Accepts props & attributes for the link element.

typerequireddefault
objecttrueN/A

as

Link element to render. Accepts an HTML element or a React component.

typerequireddefault
elementTypefalse"a"

size

Size of ButtonLink. Possible values are "s", "m", "l" for small, medium & large respectively.

typerequireddefault
enumfalse"m"

primary

Applies primary brand styles.

typerequireddefault
boolfalseN/A

secondary

Applies secondary styles.

typerequireddefault
boolfalseN/A

qualifier

Qualifiers provide a hint about the action a ButtonLink will perform. Appends or prepends (default) an icon to the caption. Accepts SVG or string.

Checkout @asphalt-react/iconpack for SVG wrapped React components.

typerequireddefault
unionfalsenull

qualifierEnd

Appends qualifier to the caption.

typerequireddefault
boolfalsefalse

IconButtonLinks are semantic links styled as an IconButton component. Supports two variants - Primary & Nude. There are three sizes available - small, medium & large.

Props

icon

Renders an icon for the caption. Accepts an inline SVG or SVG wrapped React component

Checkout @asphalt-react/iconpack for SVG wrapped React components.

typerequireddefault
elementtrueN/A

tagProps

Accepts props & attributes for the link element

typerequireddefault
objecttrueN/A

as

Link element to render. Accepts an HTML element or a React component.

typerequireddefault
elementTypefalse"a"

primary

Applies primary brand styles.

typerequireddefault
boolfalseN/A

nude

Applies nude styles

typerequireddefault
boolfalseN/A

size

Size of IconButtonLink. Possible values are "s", "m", "l" for small, medium & large respectively

typerequireddefault
enumfalse"m"

Keywords

button

FAQs

Package last updated on 05 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts