Icon toggle button that uses MDCIconButton component implemented by react component.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props |
Object | Attributes other than followings are passed to the Properties
|
- Source:
Returns:
- Type
- DetailedReactHTMLElement
Example
import { IconToggle } from 'material-react-js';
function MyVisibilityToggleButton(props) {
switch (props.type) {
case 'material':
return <IconToggle iconClassName="material-icons"
offIcon="visibility_off"
onIcon="visibility"
label="visibility"/>;
// The following code also returns the same output
// return (
// <IconToggle label="visibility">
// <IconToggle.OffIcon className="material-icons">visibility_off</IconToggle.OffIcon>
// <IconToggle.OnIcon className="material-icons">visibility</IconToggle.OnIcon>
// </IconToggle>
// );
case 'image':
return (
<IconToggle label="visibility">
<IconToggle.OffImage src="./img/visibility_off.png" alt="visibility_off"/>
<IconToggle.OnImage src="./img/visibility.png" alt="visibility"/>
</IconToggle>
);
case 'svg':
return (
<IconToggle label="visibility">
<IconToggle.OffSVG viewBox="0 0 24 24">
...
</IconToggle.OffSVG>
<IconToggle.OnSVG viewBox="0 0 24 24">
...
</IconToggle.OnSVG>
</IconToggle>
);
default:
throw new Error('unknown icon type');
}
}
Methods
(static) IconToggle.OffIcon(propsopt)
Icon element that is used “off” state icon in IconToggle. This component outputs
HTML <i>
element with appropriate attributes.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
props |
Object |
<optional> |
Attributes passed to the |
- Source:
(static) IconToggle.OffImage(propsopt)
Image element that is used “off” state icon in IconToggle. This component outputs
HTML <img>
element with appropriate attributes.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
props |
Object |
<optional> |
Attributes passed to the |
- Source:
(static) IconToggle.OffSVG(propsopt)
SVG element that is used “off” state icon in IconToggle. This component outputs
HTML <svg>
element with appropriate attributes.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
props |
Object |
<optional> |
Attributes passed to the |
- Source:
(static) IconToggle.OnIcon(propsopt)
Icon element that is used “on” state icon in IconToggle. This component outputs
HTML <i>
element with appropriate attributes.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
props |
Object |
<optional> |
Attributes passed to the |
- Source:
(static) IconToggle.OnImage(propsopt)
Image element that is used “on” state icon in IconToggle. This component outputs
HTML <img>
element with appropriate attributes.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
props |
Object |
<optional> |
Attributes passed to the |
- Source:
(static) IconToggle.OnSVG(propsopt)
SVG element that is used “on” state icon in IconToggle. This component outputs
HTML <svg>
element with appropriate attributes.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
props |
Object |
<optional> |
Attributes passed to the |
- Source: