menu
Dark Mode
backgroundLayer 1
preact-material-components
Components and their props
  • IconToggle
    • disabled true/false
      Is the icon disabled
    • data-toggle-on true/false
      JSON object for toggle on icon
    • data-toggle-off true/false
      JSON object for toggle off icon
Sample code
import {h, Component} from 'preact';
import IconToggle from 'preact-material-components/IconToggle';
import 'preact-material-components/IconToggle/style.css';

export default class IconTogglePage extends Component {
  render(){
    const toggleOnIcon = {
      content: "favorite",
      label: "Remove From Favorites"
    };
    const toggleOffIcon = {
      content: "favorite_border",
      label: "Add to Favorites"
    };
    return (
      <div>
        <IconToggle
          role="button"
          tabindex="0"
          aria-pressed="false"
          aria-label="Add to favorites"
          data-toggle-on={toggleOnIcon}
          data-toggle-off={toggleOffIcon}
        >
          favorite_border
        </IconToggle>
      </div>
    );
  }
}
Original documentation
This component encapsulates mdc-icon-toggle, you can refer to its documentation here.
Demo
favorite_border