Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
105 lines
2.5 KiB
TypeScript
105 lines
2.5 KiB
TypeScript
import * as React from 'react';
|
|
import Button from '@mui/material/Button';
|
|
import Box from '@mui/material/Box';
|
|
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
import Switch from '@mui/material/Switch';
|
|
import SaveIcon from '@mui/icons-material/Save';
|
|
import SendIcon from '@mui/icons-material/Send';
|
|
|
|
export default function LoadingButtonsTransition() {
|
|
const [loading, setLoading] = React.useState(true);
|
|
function handleClick() {
|
|
setLoading(true);
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<FormControlLabel
|
|
sx={{ display: 'block' }}
|
|
control={
|
|
<Switch
|
|
checked={loading}
|
|
onChange={() => setLoading(!loading)}
|
|
name="loading"
|
|
color="primary"
|
|
/>
|
|
}
|
|
label="Loading"
|
|
/>
|
|
<Box sx={{ '& > button': { m: 1 } }}>
|
|
<Button
|
|
size="small"
|
|
onClick={handleClick}
|
|
loading={loading}
|
|
variant="outlined"
|
|
disabled
|
|
>
|
|
Disabled
|
|
</Button>
|
|
<Button
|
|
size="small"
|
|
onClick={handleClick}
|
|
loading={loading}
|
|
loadingIndicator="Loading…"
|
|
variant="outlined"
|
|
>
|
|
Fetch data
|
|
</Button>
|
|
<Button
|
|
size="small"
|
|
onClick={handleClick}
|
|
endIcon={<SendIcon />}
|
|
loading={loading}
|
|
loadingPosition="end"
|
|
variant="contained"
|
|
>
|
|
Send
|
|
</Button>
|
|
<Button
|
|
size="small"
|
|
color="secondary"
|
|
onClick={handleClick}
|
|
loading={loading}
|
|
loadingPosition="start"
|
|
startIcon={<SaveIcon />}
|
|
variant="contained"
|
|
>
|
|
Save
|
|
</Button>
|
|
</Box>
|
|
<Box sx={{ '& > button': { m: 1 } }}>
|
|
<Button onClick={handleClick} loading={loading} variant="outlined" disabled>
|
|
Disabled
|
|
</Button>
|
|
<Button
|
|
onClick={handleClick}
|
|
loading={loading}
|
|
loadingIndicator="Loading…"
|
|
variant="outlined"
|
|
>
|
|
Fetch data
|
|
</Button>
|
|
<Button
|
|
onClick={handleClick}
|
|
endIcon={<SendIcon />}
|
|
loading={loading}
|
|
loadingPosition="end"
|
|
variant="contained"
|
|
>
|
|
Send
|
|
</Button>
|
|
<Button
|
|
color="secondary"
|
|
onClick={handleClick}
|
|
loading={loading}
|
|
loadingPosition="start"
|
|
startIcon={<SaveIcon />}
|
|
variant="contained"
|
|
>
|
|
Save
|
|
</Button>
|
|
</Box>
|
|
</div>
|
|
);
|
|
}
|