Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@material/switch
Advanced tools
@material/switch is a Material Design implementation of a switch component. It provides a customizable and accessible switch that can be used to toggle between two states, such as on and off. The package is part of the Material Components for the web, which ensures a consistent look and feel across different platforms.
Basic Switch
This is the most basic usage of the @material/switch component. It renders a switch that can be toggled between on and off states.
<mwc-switch></mwc-switch>
Disabled Switch
This example shows how to render a switch that is disabled and cannot be interacted with.
<mwc-switch disabled></mwc-switch>
Switch with Label
This example demonstrates how to use a switch with a label. The label is provided using the mwc-formfield component.
<mwc-formfield label="Toggle me"><mwc-switch></mwc-switch></mwc-formfield>
Switch with Event Listener
This example shows how to add an event listener to the switch to handle state changes.
document.querySelector('mwc-switch').addEventListener('change', (e) => { console.log('Switch state:', e.target.checked); });
react-switch is a lightweight switch component for React. It provides similar functionality to @material/switch but is designed specifically for React applications. It offers customization options for colors, sizes, and labels.
rc-switch is a React component that provides a switch UI element. It is highly customizable and supports various themes and styles. It is similar to @material/switch but is more focused on providing a flexible API for React developers.
vue-js-toggle-button is a Vue.js component for creating toggle buttons. It offers similar functionality to @material/switch but is designed for Vue.js applications. It supports customization of colors, sizes, and labels.
The MDC Switch component is a spec-aligned switch component adhering to the Material Design Switch requirements. It works without JavaScript.
npm install --save @material/switch
<div class="mdc-switch">
<input type="checkbox" id="basic-switch" class="mdc-switch__native-control" />
<div class="mdc-switch__background">
<div class="mdc-switch__knob"></div>
</div>
</div>
<label for="basic-switch" class="mdc-switch-label">off/on</label>
<div class="mdc-switch mdc-switch--disabled">
<input type="checkbox" id="another-basic-switch" class="mdc-switch__native-control" disabled />
<div class="mdc-switch__background">
<div class="mdc-switch__knob"></div>
</div>
</div>
<label for="another-basic-switch" class="mdc-switch-label">off/on</label>
The block class is mdc-switch
. This defines the top-level switch element.
The provided modifiers are:
Class | Description |
---|---|
mdc-switch--disabled | Applies disabled style to disabled switches. |
FAQs
The Material Components for the web switch component
The npm package @material/switch receives a total of 319,114 weekly downloads. As such, @material/switch popularity was classified as popular.
We found that @material/switch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 15 open source maintainers collaborating on the project.
Did you know?
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.