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
          role="button"
          tabindex="0"
          aria-pressed="false"
          aria-label="Add to favorites"
          data-toggle-on-content='favorite'
          data-toggle-off-content='favorite_border'>
          favorite_border
        </IconButton>
      </div>
    );
  }
}
Original documentation
This component encapsulates mdc-icon-button, you can refer to its documentation here.
Demo