Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 2x 2x 2x 2x 2x | // @flow strict
import React, { useState, useCallback } from 'react';
import IconButton from '../material-toolbox/icon-button';
import IconButtonState from '../material-toolbox/icon-button/State';
import Example from '../Example';
const source = `import React, { useState, useCallback } from 'react';
import IconButton from '../material-toolbox/icon-button';
import IconButtonState from '../material-toolbox/icon-button/State';
const Demo = () => {
const [isOn, setIsOn] = useState(false);
const handleChange = useCallback(() => {
setIsOn(prevIsOn => !prevIsOn);
}, []);
return (
<div>
<p>Icon Button</p>
<IconButton className="material-icons">wifi</IconButton>
<p>Icon Toggle Button</p>
<IconButton toggle on={isOn} onChange={handleChange}>
<IconButtonState className="material-icons" isOn>
favorite
</IconButtonState>
<IconButtonState className="material-icons">
favorite_border
</IconButtonState>
</IconButton>
</div>
);
};
export default Demo;`;
const Demo = () => {
const [isOn, setIsOn] = useState<boolean>(false);
const handleChange = useCallback(() => {
setIsOn(prevIsOn => !prevIsOn);
}, []);
return (
<Example title="" source={source}>
<p>Icon Button</p>
<IconButton className="material-icons">wifi</IconButton>
<p>Icon Toggle Button</p>
<IconButton toggle on={isOn} onChange={handleChange}>
<IconButtonState className="material-icons" isOn>
favorite
</IconButtonState>
<IconButtonState className="material-icons">
favorite_border
</IconButtonState>
</IconButton>
</Example>
);
};
export default Demo;
|