Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@material/mwc-button

Package Overview
Dependencies
Maintainers
19
Versions
720
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@material/mwc-button

> IMPORTANT: The Material Web Components are a work in progress and subject to > major changes until 1.0 release.

  • 0.15.0-canary.603d6eb3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
decreased by-17.95%
Maintainers
19
Weekly downloads
 
Created
Source

<mwc-button> Published on npm

IMPORTANT: The Material Web Components are a work in progress and subject to major changes until 1.0 release.

Buttons allow users to take actions, and make choices, with a single tap.

Material Design Guidelines: Button

Installation

npm install @material/mwc-button

NOTE: The Material Web Components are distributed as ES2017 JavaScript Modules, and use the Custom Elements API. They are compatible with all modern browsers including Chrome, Firefox, Safari, Edge, and IE11, but an additional tooling step is required to resolve bare module specifiers, as well as transpilation and polyfills for IE11. See here for detailed instructions.

Example Usage

Standard

<mwc-button label="standard"></mwc-button>
<mwc-button label="standard" icon="code"></mwc-button>

Outlined

<mwc-button outlined label="outlined"></mwc-button>
<mwc-button outlined label="outlined" icon="code"></mwc-button>

Raised

<mwc-button raised label="raised"></mwc-button>
<mwc-button raised label="raised" icon="code"></mwc-button>

Unelevated

<mwc-button unelevated label="unelevated"></mwc-button>
<mwc-button unelevated label="unelevated" icon="code"></mwc-button>

Dense

<mwc-button dense unelevated label="dense"></mwc-button>
<mwc-button dense unelevated label="dense" icon="code"></mwc-button>

Trailing Icon

<mwc-button label="trailing icon" icon="code" trailingIcon></mwc-button>

Disabled

<mwc-button disabled label="disabled"></mwc-button>
<mwc-button disabled label="disabled" icon="code"></mwc-button>

Customize Colors

mwc-button {
  --mdc-theme-primary: #e9437a;
  --mdc-theme-on-primary: white;
}

API

Slots

NameDescription
iconLeading icon. Overrides icon property. Use label or the icon property to set the aria-label.
trailingIconIcon to show after the label. Overrides trailingIcon property. Use label or the trailingIcon property to set the aria-label.
defaultDefault content to display between both icons and after label. NOTE: It is highly recommended to set the label property instead of projecting text as it will also set the aria-label

Properties/Attributes

NameTypeDefaultDescription
iconstring''Icon to display, and aria-label value when label is not defined.
labelstring''Label to display for the button, and aria-label.
raisedbooleanfalseCreates a contained button that is elevated above the surface.
unelevatedbooleanfalseCreates a contained button that is flush with the surface.
outlinedbooleanfalseCreates an outlined button that is flush with the surface.
densebooleanfalseMakes the button text and container slightly smaller.
disabledbooleanfalseDisabled buttons cannot be interacted with and have no visual interaction effect.
trailingIconbooleanfalseWhen true, icon will be displayed after label.

Methods

None

Events

None

CSS Custom Properties

NameDefaultDescription
--mdc-icon-fontMaterial IconsFont to use for the icon.
--mdc-theme-primary #6200eeBackground color of the button.
--mdc-theme-on-primary #ffffffText color of the button.
--mdc-button-horizontal-paddingfilled: 16px outlined: 15px default: 8pxLeft and right padding of the button label (for outlined buttons the outline width is automatically subtracted).
--mdc-button-outline-width1pxwidth of the outline of an outlined button and attempts to keep the component size constant.
--mdc-button-outline-color --mdc-theme-primaryColor of the outline of an outlined element. (Overrides --mdc-theme-primary)
--mdc-button-disabled-fill-color rgba(0,0,0,0.12)Background fill color of a disabled raised or unelevated button.
--mdc-button-disabled-ink-color rgba(0,0,0,0.37)Text color of a disabled button as well as the outline color of a disabled outlined button.
--mdc-button-disabled-outline-color --mdc-button-disabled-ink-colorSets the color of the outline of a disabled outlined button. (Overrides --mdc-button-disabled-ink-color)
--mdc-button-raised-box-shadowmdc elevation 2Sets the box shadow of the raised button.
--mdc-button-raised-box-shadow-hovermdc elevation 4Sets the box shadow of the raised button when focused or hovered.
--mdc-button-raised-box-shadow-activemdc elevation 8Sets the box shadow of the raised button when active.
--mdc-button-raised-box-shadow-disabledmdc elevation 0Sets the box shadow of the raised button when disabled.
Elevation values
Elevation LevelCSS Value
20px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12)
40px 2px 4px -1px rgba(0, 0, 0, 0.2), 0px 4px 5px 0px rgba(0, 0, 0, 0.14), 0px 1px 10px 0px rgba(0, 0, 0, 0.12)
80px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12)
00px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0, 0, 0, 0.12)

Additional references

FAQs

Package last updated on 20 Mar 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc