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

@material/mwc-radio

Package Overview
Dependencies
Maintainers
19
Versions
721
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@material/mwc-radio

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

  • 0.15.0-canary.ba05565e.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.4K
decreased by-57.49%
Maintainers
19
Weekly downloads
 
Created
Source

<mwc-radio> Published on npm

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

Radio buttons allow the user to select one option from a set. Use radio buttons when the user needs to see all available options.

Material Design Guidelines: Radio buttons

Installation

npm install @material/mwc-radio

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-radio name="myGroup" value="value1"></mwc-radio>
<mwc-radio name="myGroup" value="value2" checked></mwc-radio>

<script type="module">
  import '@material/mwc-radio';
</script>

Custom color

<style>
body {
  background-color: #363636;

  --mdc-theme-secondary: #ff2929;
  --mdc-radio-unchecked-color: white;
}
</style>

<mwc-radio name="myGroup" checked></mwc-radio>
<mwc-radio name="myGroup"></mwc-radio>

Disabled custom color

<style>
body {
  background-color: #363636;

  --mdc-radio-disabled-color: #adadad;
}
</style>

<mwc-radio disabled name="myGroup"></mwc-radio>
<mwc-radio disabled name="myGroup" checked></mwc-radio>

With Form Field

Most applications should use <mwc-formfield> to associate an interactive label with the radio.

<style>
  mwc-formfield {
    display: block;
  }
</style>

<mwc-formfield label="Home">
  <mwc-radio name="location"></mwc-radio>
</mwc-formfield>

<mwc-formfield label="Work">
  <mwc-radio name="location"></mwc-radio>
</mwc-formfield>

<script type="module">
  import '@material/mwc-radio';
  import '@material/mwc-formfield';
</script>

API

Slots

None

Properties/Attributes

NameTypeDefaultDescription
checkedbooleanfalseWhether this radio button is the currently-selected one in its group. Maps to the native checked attribute.
disabledbooleanfalseIf true, this radio button cannot be selected or de-selected. Maps to the native disabled attribute.
namestring''Name of the input for form submission, and identifier for the selection group. Only one radio button can be checked for a given selection group. Maps to the native name attribute.
valuestring''Value of the input for form submission. Maps to the native value attribute.
globalbooleanfalseIf true, this radio button will use a global, document-level scope for its selection group rather than its local shadow root.

Methods

None

Events

NameDetailDescription
change{}Fired when the user modifies the radio checked state from an input device interaction on this radio. Note that, like native <input>, the change event is not fired when the checked property is set from JavaScript, nor is it fired when another radio in the same group becomes checked.

CSS Custom Properties

NameDefaultDescription
--mdc-theme-secondary #018786Color of the radio button.
--mdc-radio-unchecked-color rgba(0, 0, 0, 0.54)Color of the ring of an unchecked radio.
--mdc-radio-disabled-color rgba(0, 0, 0, 0.38)Color of the ring and circle of a disabled radio.

Additional references

FAQs

Package last updated on 08 Apr 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