menu
Dark Mode
backgroundLayer 1
preact-material-components
Components and their props
  • IconButton
    • no specific props
  • Icon
    • on true/false
      Determine if this button is the on state or off state button.
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>
        <IconButton>
          <IconButton.Icon on>favorite</IconButton.Icon>
          <IconButton.Icon>favorite_border</IconButton.Icon>
        </IconButton>
      </div>
    );
  }
}
Original documentation
This component encapsulates mdc-icon-button, you can refer to its documentation here.
Demo