import * as React from 'react';
import { DefaultButton } from '@fluentui/react/lib/Button';
import { Stack, IStackTokens } from '@fluentui/react/lib/Stack';
import { Toggle } from '@fluentui/react/lib/Toggle';
import { TooltipHost } from '@fluentui/react/lib/Tooltip';
import { useId } from '@fluentui/react-hooks';
const stackTokens: IStackTokens = { childrenGap: 10 };
const buttonStyles = {
root: {
background: 'transparent',
border: 'none',
minWidth: '16px',
padding: 0,
},
};
export const ToggleCustomLabelExample: React.FunctionComponent = () => {
const [showTooltip, setShowTooltip] = React.useState(false);
const tooltipId = useId('tooltipId');
const iconWithTooltip = (
<>
setShowTooltip(!showTooltip)}
styles={buttonStyles}
iconProps={{ iconName: 'Info' }}
/>
>
);
return (
Custom label {iconWithTooltip}} onText="On" offText="Off" onChange={_onChange} />
Custom inline label {iconWithTooltip}}
inlineLabel
onText="On"
offText="Off"
onChange={_onChange}
/>
);
};
function _onChange(ev: React.MouseEvent, checked?: boolean) {
console.log('toggle is ' + (checked ? 'checked' : 'not checked'));
}