index
int64 0
0
| repo_id
stringlengths 16
181
| file_path
stringlengths 28
270
| content
stringlengths 1
11.6M
| __index_level_0__
int64 0
10k
|
---|---|---|---|---|
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/slider/VerticalSlider.js | import * as React from 'react';
import Box from '@mui/joy/Box';
import Slider from '@mui/joy/Slider';
const marks = [
{
value: 0,
label: '0°C',
},
{
value: 20,
label: '20°C',
},
{
value: 37,
label: '37°C',
},
{
value: 100,
label: '100°C',
},
];
function valueText(value) {
return `${value}°C`;
}
export default function VerticalSlider() {
return (
<Box sx={{ mx: 'auto', height: 200 }}>
<Slider
orientation="vertical"
aria-label="Always visible"
defaultValue={80}
getAriaValueText={valueText}
step={10}
marks={marks}
valueLabelDisplay="on"
/>
</Box>
);
}
| 1,500 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/slider/VerticalSlider.tsx | import * as React from 'react';
import Box from '@mui/joy/Box';
import Slider from '@mui/joy/Slider';
const marks = [
{
value: 0,
label: '0°C',
},
{
value: 20,
label: '20°C',
},
{
value: 37,
label: '37°C',
},
{
value: 100,
label: '100°C',
},
];
function valueText(value: number) {
return `${value}°C`;
}
export default function VerticalSlider() {
return (
<Box sx={{ mx: 'auto', height: 200 }}>
<Slider
orientation="vertical"
aria-label="Always visible"
defaultValue={80}
getAriaValueText={valueText}
step={10}
marks={marks}
valueLabelDisplay="on"
/>
</Box>
);
}
| 1,501 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/slider/VerticalSlider.tsx.preview | <Slider
orientation="vertical"
aria-label="Always visible"
defaultValue={80}
getAriaValueText={valueText}
step={10}
marks={marks}
valueLabelDisplay="on"
/> | 1,502 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/slider/slider.md | ---
productId: joy-ui
title: React Slider component
components: Slider
githubLabel: 'component: slider'
unstyled: /base-ui/react-slider/
---
# Slider
<p class="description">Slider generates a background element that can be used for various purposes.</p>
{{"component": "modules/components/ComponentLinkHeader.js"}}
## Introduction
Sliders are ideal for interface controls that benefit from a visual representation of adjustable content, such as volume or brightness settings, or for applying image filters such as gradients or saturation.
{{"demo": "SliderUsage.js", "hideToolbar": true, "bg": "gradient"}}
## Component
After [installation](/joy-ui/getting-started/installation/), you can start building with this component using the following basic elements:
```jsx
import Slider from '@mui/joy/Slider';
export default function MyApp() {
return <Slider defaultValue={3} max={10} />;
}
```
### Steps
Change the default step increments by setting a desired value to the `step` prop.
{{"demo": "StepsSlider.js"}}
### Custom marks
You can create custom marks by providing a rich array to the `marks` prop:
{{"demo": "MarksSlider.js"}}
### Always visible label
To make the thumb label always visible, toggle on the `valueLabelDisplay` prop.
{{"demo": "AlwaysVisibleLabelSlider.js"}}
### Vertical
Set `orientation="vertical"` to display the vertical slider.
{{"demo": "VerticalSlider.js"}}
### Keep the label at edges
Apply the following styles to ensure that the label doesn't get cut off on mobile when it hits the edge of the slider.
{{"demo": "EdgeLabelSlider.js"}}
### Range slider
To let users set the start and end of a range on a slider, provide an array of values to the `value` or `defaultValue` prop:
{{"demo": "RangeSlider.js"}}
### Track
The slider's track shows how much of it has been selected.
You can either invert it by assigning `inverted` to the `track` prop or remove it entirely by assigning a value of `false`.
{{"demo": "TrackInvertedSlider.js"}}
{{"demo": "TrackFalseSlider.js"}}
## CSS variables playground
Play around with all the CSS variables available in the slider component to see how the design changes.
You can use those to customize the component on both the `sx` prop and the theme.
{{"demo": "SliderVariables.js", "hideToolbar": true, "bg": "gradient"}}
| 1,503 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/CustomAnimatedSnackbar.js | import * as React from 'react';
import Button from '@mui/joy/Button';
import Snackbar from '@mui/joy/Snackbar';
import { keyframes } from '@mui/system';
const inAnimation = keyframes`
0% {
transform: scale(0);
opacity: 0;
}
100% {
transform: scale(1);
opacity: 1;
}
`;
const outAnimation = keyframes`
0% {
transform: scale(1);
opacity: 1;
}
100% {
transform: scale(0);
opacity: 0;
}
`;
export default function CustomAnimatedSnackbar() {
const [open, setOpen] = React.useState(false);
const animationDuration = 600;
const handleClick = () => {
setOpen(true);
};
const handleClose = () => {
setOpen(false);
};
return (
<div>
<Button variant="outlined" color="neutral" onClick={handleClick}>
Show Snackbar
</Button>
<Snackbar
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
open={open}
onClose={handleClose}
autoHideDuration={4000}
animationDuration={animationDuration}
sx={{
...(open && {
animation: `${inAnimation} ${animationDuration}ms forwards`,
}),
...(!open && {
animation: `${outAnimation} ${animationDuration}ms forwards`,
}),
}}
>
I love this animation!
</Snackbar>
</div>
);
}
| 1,504 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/CustomAnimatedSnackbar.tsx | import * as React from 'react';
import Button from '@mui/joy/Button';
import Snackbar from '@mui/joy/Snackbar';
import { keyframes } from '@mui/system';
const inAnimation = keyframes`
0% {
transform: scale(0);
opacity: 0;
}
100% {
transform: scale(1);
opacity: 1;
}
`;
const outAnimation = keyframes`
0% {
transform: scale(1);
opacity: 1;
}
100% {
transform: scale(0);
opacity: 0;
}
`;
export default function CustomAnimatedSnackbar() {
const [open, setOpen] = React.useState(false);
const animationDuration = 600;
const handleClick = () => {
setOpen(true);
};
const handleClose = () => {
setOpen(false);
};
return (
<div>
<Button variant="outlined" color="neutral" onClick={handleClick}>
Show Snackbar
</Button>
<Snackbar
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
open={open}
onClose={handleClose}
autoHideDuration={4000}
animationDuration={animationDuration}
sx={{
...(open && {
animation: `${inAnimation} ${animationDuration}ms forwards`,
}),
...(!open && {
animation: `${outAnimation} ${animationDuration}ms forwards`,
}),
}}
>
I love this animation!
</Snackbar>
</div>
);
}
| 1,505 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/PositionedSnackbar.js | import * as React from 'react';
import Grid from '@mui/joy/Grid';
import Box from '@mui/joy/Box';
import Button from '@mui/joy/Button';
import Snackbar from '@mui/joy/Snackbar';
import NorthWestIcon from '@mui/icons-material/NorthWest';
import NorthEastIcon from '@mui/icons-material/NorthEast';
import NorthIcon from '@mui/icons-material/North';
import SouthIcon from '@mui/icons-material/South';
import SouthEastIcon from '@mui/icons-material/SouthEast';
import SouthWestIcon from '@mui/icons-material/SouthWest';
export default function PositionedSnackbar() {
const [state, setState] = React.useState({
open: false,
vertical: 'top',
horizontal: 'center',
});
const { vertical, horizontal, open } = state;
const handleClick = (newState) => () => {
setState({ ...newState, open: true });
};
const handleClose = () => {
setState({ ...state, open: false });
};
const buttons = (
<React.Fragment>
<Box sx={{ display: 'flex', justifyContent: 'center' }}>
<Button
variant="plain"
startDecorator={<NorthIcon />}
onClick={handleClick({ vertical: 'top', horizontal: 'center' })}
sx={{ flexDirection: 'column', gap: 1, '--Button-gap': 0 }}
>
Top Center
</Button>
</Box>
<Grid container justifyContent="center">
<Grid xs={6}>
<Button
variant="plain"
startDecorator={<NorthWestIcon />}
onClick={handleClick({ vertical: 'top', horizontal: 'left' })}
>
Top Left
</Button>
</Grid>
<Grid xs={6} textAlign="right" sx={{ mb: 2 }}>
<Button
variant="plain"
endDecorator={<NorthEastIcon />}
onClick={handleClick({ vertical: 'top', horizontal: 'right' })}
>
Top Right
</Button>
</Grid>
<Grid xs={6}>
<Button
variant="plain"
startDecorator={<SouthWestIcon />}
onClick={handleClick({ vertical: 'bottom', horizontal: 'left' })}
>
Bottom Left
</Button>
</Grid>
<Grid xs={6} textAlign="right">
<Button
variant="plain"
endDecorator={<SouthEastIcon />}
onClick={handleClick({ vertical: 'bottom', horizontal: 'right' })}
>
Bottom Right
</Button>
</Grid>
</Grid>
<Box sx={{ display: 'flex', justifyContent: 'center' }}>
<Button
variant="plain"
endDecorator={<SouthIcon />}
onClick={handleClick({ vertical: 'bottom', horizontal: 'center' })}
sx={{ flexDirection: 'column', gap: 1, '--Button-gap': 0 }}
>
Bottom Center
</Button>
</Box>
</React.Fragment>
);
return (
<Box sx={{ width: 500 }}>
{buttons}
<Snackbar
anchorOrigin={{ vertical, horizontal }}
open={open}
onClose={handleClose}
key={vertical + horizontal}
>
I love snacks
</Snackbar>
</Box>
);
}
| 1,506 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/PositionedSnackbar.tsx | import * as React from 'react';
import Grid from '@mui/joy/Grid';
import Box from '@mui/joy/Box';
import Button from '@mui/joy/Button';
import Snackbar, { SnackbarOrigin } from '@mui/joy/Snackbar';
import NorthWestIcon from '@mui/icons-material/NorthWest';
import NorthEastIcon from '@mui/icons-material/NorthEast';
import NorthIcon from '@mui/icons-material/North';
import SouthIcon from '@mui/icons-material/South';
import SouthEastIcon from '@mui/icons-material/SouthEast';
import SouthWestIcon from '@mui/icons-material/SouthWest';
interface State extends SnackbarOrigin {
open: boolean;
}
export default function PositionedSnackbar() {
const [state, setState] = React.useState<State>({
open: false,
vertical: 'top',
horizontal: 'center',
});
const { vertical, horizontal, open } = state;
const handleClick = (newState: SnackbarOrigin) => () => {
setState({ ...newState, open: true });
};
const handleClose = () => {
setState({ ...state, open: false });
};
const buttons = (
<React.Fragment>
<Box sx={{ display: 'flex', justifyContent: 'center' }}>
<Button
variant="plain"
startDecorator={<NorthIcon />}
onClick={handleClick({ vertical: 'top', horizontal: 'center' })}
sx={{ flexDirection: 'column', gap: 1, '--Button-gap': 0 }}
>
Top Center
</Button>
</Box>
<Grid container justifyContent="center">
<Grid xs={6}>
<Button
variant="plain"
startDecorator={<NorthWestIcon />}
onClick={handleClick({ vertical: 'top', horizontal: 'left' })}
>
Top Left
</Button>
</Grid>
<Grid xs={6} textAlign="right" sx={{ mb: 2 }}>
<Button
variant="plain"
endDecorator={<NorthEastIcon />}
onClick={handleClick({ vertical: 'top', horizontal: 'right' })}
>
Top Right
</Button>
</Grid>
<Grid xs={6}>
<Button
variant="plain"
startDecorator={<SouthWestIcon />}
onClick={handleClick({ vertical: 'bottom', horizontal: 'left' })}
>
Bottom Left
</Button>
</Grid>
<Grid xs={6} textAlign="right">
<Button
variant="plain"
endDecorator={<SouthEastIcon />}
onClick={handleClick({ vertical: 'bottom', horizontal: 'right' })}
>
Bottom Right
</Button>
</Grid>
</Grid>
<Box sx={{ display: 'flex', justifyContent: 'center' }}>
<Button
variant="plain"
endDecorator={<SouthIcon />}
onClick={handleClick({ vertical: 'bottom', horizontal: 'center' })}
sx={{ flexDirection: 'column', gap: 1, '--Button-gap': 0 }}
>
Bottom Center
</Button>
</Box>
</React.Fragment>
);
return (
<Box sx={{ width: 500 }}>
{buttons}
<Snackbar
anchorOrigin={{ vertical, horizontal }}
open={open}
onClose={handleClose}
key={vertical + horizontal}
>
I love snacks
</Snackbar>
</Box>
);
}
| 1,507 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/PositionedSnackbar.tsx.preview | {buttons}
<Snackbar
anchorOrigin={{ vertical, horizontal }}
open={open}
onClose={handleClose}
key={vertical + horizontal}
>
I love snacks
</Snackbar> | 1,508 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarCloseReason.js | import * as React from 'react';
import Button from '@mui/joy/Button';
import List from '@mui/joy/List';
import ListItem from '@mui/joy/ListItem';
import Typography from '@mui/joy/Typography';
import Stack from '@mui/joy/Stack';
import Snackbar from '@mui/joy/Snackbar';
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
import CheckBoxIcon from '@mui/icons-material/CheckBox';
export default function SnackbarCloseReason() {
const [open, setOpen] = React.useState(false);
const [reasons, setReasons] = React.useState([]);
React.useEffect(() => {
if (
['timeout', 'clickaway', 'escapeKeyDown'].every((item) =>
reasons.includes(item),
)
) {
setOpen(false);
}
}, [reasons]);
return (
<div>
<Button
variant="outlined"
color="neutral"
onClick={() => {
setOpen(true);
}}
>
Show snackbar
</Button>
<Snackbar
autoHideDuration={3000}
open={open}
onClose={(event, reason) => {
setReasons((prev) => [...new Set([...prev, reason])]);
}}
onUnmount={() => {
setReasons([]);
}}
sx={{ minWidth: 360 }}
>
<Stack spacing={0.5}>
<Typography level="title-md">
To close this snackbar, you have to:
</Typography>
<List size="sm">
<ListItem>
{reasons.includes('timeout') ? (
<CheckBoxIcon color="success" />
) : (
<CheckBoxOutlineBlankIcon />
)}{' '}
Wait for 3 seconds.
</ListItem>
<ListItem>
{reasons.includes('clickaway') ? (
<CheckBoxIcon color="success" />
) : (
<CheckBoxOutlineBlankIcon />
)}{' '}
Click outside of the snackbar.
</ListItem>
<ListItem>
{reasons.includes('escapeKeyDown') ? (
<CheckBoxIcon color="success" />
) : (
<CheckBoxOutlineBlankIcon />
)}{' '}
Press ESC key.
</ListItem>
</List>
</Stack>
</Snackbar>
</div>
);
}
| 1,509 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarCloseReason.tsx | import * as React from 'react';
import Button from '@mui/joy/Button';
import List from '@mui/joy/List';
import ListItem from '@mui/joy/ListItem';
import Typography from '@mui/joy/Typography';
import Stack from '@mui/joy/Stack';
import Snackbar, {
SnackbarCloseReason as SnackbarCloseReasonType,
} from '@mui/joy/Snackbar';
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
import CheckBoxIcon from '@mui/icons-material/CheckBox';
export default function SnackbarCloseReason() {
const [open, setOpen] = React.useState(false);
const [reasons, setReasons] = React.useState<SnackbarCloseReasonType[]>([]);
React.useEffect(() => {
if (
(['timeout', 'clickaway', 'escapeKeyDown'] as const).every((item) =>
reasons.includes(item),
)
) {
setOpen(false);
}
}, [reasons]);
return (
<div>
<Button
variant="outlined"
color="neutral"
onClick={() => {
setOpen(true);
}}
>
Show snackbar
</Button>
<Snackbar
autoHideDuration={3000}
open={open}
onClose={(event, reason) => {
// @ts-ignore
setReasons((prev) => [...new Set([...prev, reason])]);
}}
onUnmount={() => {
setReasons([]);
}}
sx={{ minWidth: 360 }}
>
<Stack spacing={0.5}>
<Typography level="title-md">
To close this snackbar, you have to:
</Typography>
<List size="sm">
<ListItem>
{reasons.includes('timeout') ? (
<CheckBoxIcon color="success" />
) : (
<CheckBoxOutlineBlankIcon />
)}{' '}
Wait for 3 seconds.
</ListItem>
<ListItem>
{reasons.includes('clickaway') ? (
<CheckBoxIcon color="success" />
) : (
<CheckBoxOutlineBlankIcon />
)}{' '}
Click outside of the snackbar.
</ListItem>
<ListItem>
{reasons.includes('escapeKeyDown') ? (
<CheckBoxIcon color="success" />
) : (
<CheckBoxOutlineBlankIcon />
)}{' '}
Press ESC key.
</ListItem>
</List>
</Stack>
</Snackbar>
</div>
);
}
| 1,510 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarColors.js | import * as React from 'react';
import Button from '@mui/joy/Button';
import Stack from '@mui/joy/Stack';
import Select from '@mui/joy/Select';
import Option from '@mui/joy/Option';
import Snackbar from '@mui/joy/Snackbar';
export default function SnackbarColors() {
const [open, setOpen] = React.useState(false);
const [variant, setVariant] = React.useState('outlined');
const [color, setColor] = React.useState('neutral');
return (
<Stack spacing={2} alignItems="center">
<Select
value={variant}
onChange={(event, newValue) => setVariant(newValue)}
sx={{ minWidth: 160 }}
>
<Option value="outlined">outlined</Option>
<Option value="plain">plain</Option>
<Option value="soft">soft</Option>
<Option value="solid">solid</Option>
</Select>
<Stack spacing={1} direction="row">
{['primary', 'neutral', 'danger', 'success', 'warning'].map(
(currentColor) => (
<Button
key={currentColor}
variant="soft"
color={currentColor}
size="sm"
onClick={() => {
setOpen(true);
setColor(currentColor);
}}
>
{currentColor}
</Button>
),
)}
</Stack>
<Snackbar
autoHideDuration={4000}
open={open}
variant={variant}
color={color}
onClose={(event, reason) => {
if (reason === 'clickaway') {
return;
}
setOpen(false);
}}
>
{variant} snackbar with {color} color.
</Snackbar>
</Stack>
);
}
| 1,511 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarColors.tsx | import * as React from 'react';
import Button from '@mui/joy/Button';
import Stack from '@mui/joy/Stack';
import Select from '@mui/joy/Select';
import Option from '@mui/joy/Option';
import Snackbar, { SnackbarProps } from '@mui/joy/Snackbar';
export default function SnackbarColors() {
const [open, setOpen] = React.useState(false);
const [variant, setVariant] = React.useState<SnackbarProps['variant']>('outlined');
const [color, setColor] = React.useState<SnackbarProps['color']>('neutral');
return (
<Stack spacing={2} alignItems="center">
<Select
value={variant}
onChange={(event, newValue) => setVariant(newValue!)}
sx={{ minWidth: 160 }}
>
<Option value="outlined">outlined</Option>
<Option value="plain">plain</Option>
<Option value="soft">soft</Option>
<Option value="solid">solid</Option>
</Select>
<Stack spacing={1} direction="row">
{(['primary', 'neutral', 'danger', 'success', 'warning'] as const).map(
(currentColor) => (
<Button
key={currentColor}
variant="soft"
color={currentColor}
size="sm"
onClick={() => {
setOpen(true);
setColor(currentColor);
}}
>
{currentColor}
</Button>
),
)}
</Stack>
<Snackbar
autoHideDuration={4000}
open={open}
variant={variant}
color={color}
onClose={(event, reason) => {
if (reason === 'clickaway') {
return;
}
setOpen(false);
}}
>
{variant} snackbar with {color} color.
</Snackbar>
</Stack>
);
}
| 1,512 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarHideDuration.js | import * as React from 'react';
import Button from '@mui/joy/Button';
import FormControl from '@mui/joy/FormControl';
import FormLabel from '@mui/joy/FormLabel';
import Input from '@mui/joy/Input';
import Stack from '@mui/joy/Stack';
import Snackbar from '@mui/joy/Snackbar';
export default function SnackbarHideDuration() {
const [open, setOpen] = React.useState(false);
const [duration, setDuration] = React.useState();
const [left, setLeft] = React.useState();
const timer = React.useRef();
const countdown = () => {
timer.current = window.setInterval(() => {
setLeft((prev) => (prev === undefined ? prev : Math.max(0, prev - 100)));
}, 100);
};
React.useEffect(() => {
if (open && duration !== undefined && duration > 0) {
setLeft(duration);
countdown();
} else {
window.clearInterval(timer.current);
}
}, [open, duration]);
const handlePause = () => {
window.clearInterval(timer.current);
};
const handleResume = () => {
countdown();
};
return (
<div>
<Stack spacing={2} direction="row" alignItems="center">
<FormControl disabled={open} sx={{ display: 'grid', columnGap: 1 }}>
<FormLabel sx={{ gridColumn: 'span 2' }}>
Auto Hide Duration (ms)
</FormLabel>
<Input
type="number"
slotProps={{ input: { step: 100 } }}
value={duration || ''}
onChange={(event) => {
setDuration(event.target.valueAsNumber || undefined);
}}
/>
<Button
disabled={open}
variant="outlined"
color="neutral"
onClick={() => {
setOpen(true);
}}
>
Show snackbar
</Button>
</FormControl>
</Stack>
<Snackbar
variant="solid"
color="danger"
autoHideDuration={duration}
resumeHideDuration={left}
onMouseEnter={handlePause}
onMouseLeave={handleResume}
onFocus={handlePause}
onBlur={handleResume}
onUnmount={() => setLeft(undefined)}
open={open}
onClose={() => {
setOpen(false);
}}
>
This snackbar will{' '}
{left !== undefined
? `disappear in ${left}ms`
: `not disappear until you click away`}
.
</Snackbar>
</div>
);
}
| 1,513 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarHideDuration.tsx | import * as React from 'react';
import Button from '@mui/joy/Button';
import FormControl from '@mui/joy/FormControl';
import FormLabel from '@mui/joy/FormLabel';
import Input from '@mui/joy/Input';
import Stack from '@mui/joy/Stack';
import Snackbar from '@mui/joy/Snackbar';
export default function SnackbarHideDuration() {
const [open, setOpen] = React.useState(false);
const [duration, setDuration] = React.useState<undefined | number>();
const [left, setLeft] = React.useState<undefined | number>();
const timer = React.useRef<undefined | number>();
const countdown = () => {
timer.current = window.setInterval(() => {
setLeft((prev) => (prev === undefined ? prev : Math.max(0, prev - 100)));
}, 100);
};
React.useEffect(() => {
if (open && duration !== undefined && duration > 0) {
setLeft(duration);
countdown();
} else {
window.clearInterval(timer.current);
}
}, [open, duration]);
const handlePause = () => {
window.clearInterval(timer.current);
};
const handleResume = () => {
countdown();
};
return (
<div>
<Stack spacing={2} direction="row" alignItems="center">
<FormControl disabled={open} sx={{ display: 'grid', columnGap: 1 }}>
<FormLabel sx={{ gridColumn: 'span 2' }}>
Auto Hide Duration (ms)
</FormLabel>
<Input
type="number"
slotProps={{ input: { step: 100 } }}
value={duration || ''}
onChange={(event) => {
setDuration(event.target.valueAsNumber || undefined);
}}
/>
<Button
disabled={open}
variant="outlined"
color="neutral"
onClick={() => {
setOpen(true);
}}
>
Show snackbar
</Button>
</FormControl>
</Stack>
<Snackbar
variant="solid"
color="danger"
autoHideDuration={duration}
resumeHideDuration={left}
onMouseEnter={handlePause}
onMouseLeave={handleResume}
onFocus={handlePause}
onBlur={handleResume}
onUnmount={() => setLeft(undefined)}
open={open}
onClose={() => {
setOpen(false);
}}
>
This snackbar will{' '}
{left !== undefined
? `disappear in ${left}ms`
: `not disappear until you click away`}
.
</Snackbar>
</div>
);
}
| 1,514 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarInvertedColors.js | import * as React from 'react';
import Snackbar from '@mui/joy/Snackbar';
import Button from '@mui/joy/Button';
import Stack from '@mui/joy/Stack';
import Typography from '@mui/joy/Typography';
export default function SnackbarInvertedColors() {
const [open, setOpen] = React.useState(false);
return (
<React.Fragment>
<Button variant="outlined" color="neutral" onClick={() => setOpen(true)}>
Show Snackbar
</Button>
<Snackbar
autoHideDuration={5000}
variant="solid"
color="primary"
size="lg"
invertedColors
open={open}
onClose={() => setOpen(false)}
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
sx={(theme) => ({
background: `linear-gradient(45deg, ${theme.palette.primary[600]} 30%, ${theme.palette.primary[500]} 90%})`,
maxWidth: 360,
})}
>
<div>
<Typography level="title-lg">Hey, Wait!!</Typography>
<Typography sx={{ mt: 1, mb: 2 }}>
Are you sure, you want to leave this page without confirming your order?
</Typography>
<Stack direction="row" spacing={1}>
<Button variant="solid" color="primary" onClick={() => setOpen(false)}>
Yes, Maybe later
</Button>
<Button
variant="outlined"
color="primary"
onClick={() => setOpen(false)}
>
No, I want to stay
</Button>
</Stack>
</div>
</Snackbar>
</React.Fragment>
);
}
| 1,515 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarInvertedColors.tsx | import * as React from 'react';
import Snackbar from '@mui/joy/Snackbar';
import Button from '@mui/joy/Button';
import Stack from '@mui/joy/Stack';
import Typography from '@mui/joy/Typography';
export default function SnackbarInvertedColors() {
const [open, setOpen] = React.useState(false);
return (
<React.Fragment>
<Button variant="outlined" color="neutral" onClick={() => setOpen(true)}>
Show Snackbar
</Button>
<Snackbar
autoHideDuration={5000}
variant="solid"
color="primary"
size="lg"
invertedColors
open={open}
onClose={() => setOpen(false)}
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
sx={(theme) => ({
background: `linear-gradient(45deg, ${theme.palette.primary[600]} 30%, ${theme.palette.primary[500]} 90%})`,
maxWidth: 360,
})}
>
<div>
<Typography level="title-lg">Hey, Wait!!</Typography>
<Typography sx={{ mt: 1, mb: 2 }}>
Are you sure, you want to leave this page without confirming your order?
</Typography>
<Stack direction="row" spacing={1}>
<Button variant="solid" color="primary" onClick={() => setOpen(false)}>
Yes, Maybe later
</Button>
<Button
variant="outlined"
color="primary"
onClick={() => setOpen(false)}
>
No, I want to stay
</Button>
</Stack>
</div>
</Snackbar>
</React.Fragment>
);
}
| 1,516 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarSizes.js | import * as React from 'react';
import Button from '@mui/joy/Button';
import Stack from '@mui/joy/Stack';
import Snackbar from '@mui/joy/Snackbar';
export default function SnackbarSizes() {
const [open, setOpen] = React.useState(false);
const [size, setSize] = React.useState('md');
return (
<Stack spacing={2} direction="row" alignItems="center">
<Button
variant="outlined"
color="neutral"
size="sm"
onClick={() => {
setOpen(true);
setSize('sm');
}}
>
sm
</Button>
<Button
variant="outlined"
color="neutral"
size="md"
onClick={() => {
setOpen(true);
setSize('md');
}}
>
md
</Button>
<Button
variant="outlined"
color="neutral"
size="lg"
onClick={() => {
setOpen(true);
setSize('lg');
}}
>
lg
</Button>
<Snackbar
autoHideDuration={3000}
open={open}
size={size}
onClose={(event, reason) => {
if (reason === 'clickaway') {
return;
}
setOpen(false);
}}
>
A snackbar with {size} size.
</Snackbar>
</Stack>
);
}
| 1,517 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarSizes.tsx | import * as React from 'react';
import Button from '@mui/joy/Button';
import Stack from '@mui/joy/Stack';
import Snackbar, { SnackbarProps } from '@mui/joy/Snackbar';
export default function SnackbarSizes() {
const [open, setOpen] = React.useState(false);
const [size, setSize] = React.useState<SnackbarProps['size']>('md');
return (
<Stack spacing={2} direction="row" alignItems="center">
<Button
variant="outlined"
color="neutral"
size="sm"
onClick={() => {
setOpen(true);
setSize('sm');
}}
>
sm
</Button>
<Button
variant="outlined"
color="neutral"
size="md"
onClick={() => {
setOpen(true);
setSize('md');
}}
>
md
</Button>
<Button
variant="outlined"
color="neutral"
size="lg"
onClick={() => {
setOpen(true);
setSize('lg');
}}
>
lg
</Button>
<Snackbar
autoHideDuration={3000}
open={open}
size={size}
onClose={(event, reason) => {
if (reason === 'clickaway') {
return;
}
setOpen(false);
}}
>
A snackbar with {size} size.
</Snackbar>
</Stack>
);
}
| 1,518 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarUsage.js | import * as React from 'react';
import Snackbar from '@mui/joy/Snackbar';
import Button from '@mui/joy/Button';
import IconButton from '@mui/joy/IconButton';
import Typography from '@mui/joy/Typography';
import Close from '@mui/icons-material/Close';
import JoyUsageDemo from 'docs/src/modules/components/JoyUsageDemo';
import InfoOutlined from '@mui/icons-material/InfoOutlined';
export default function SnackbarUsage() {
const [open, setOpen] = React.useState(false);
return (
<JoyUsageDemo
componentName="Snackbar"
data={[
{
propName: 'variant',
knob: 'radio',
defaultValue: 'outlined',
options: ['plain', 'outlined', 'soft', 'solid'],
},
{
propName: 'color',
knob: 'color',
defaultValue: 'neutral',
},
{
propName: 'size',
knob: 'radio',
options: ['sm', 'md', 'lg'],
defaultValue: 'md',
},
{
propName: 'autoHideDuration',
helperText: 'The duration to be shown (in ms)',
knob: 'number',
},
]}
renderDemo={(props) => (
<React.Fragment>
<Button variant="outlined" color="neutral" onClick={() => setOpen(true)}>
Show Snackbar
</Button>
<Snackbar
open={open}
onClose={(event, reason) => {
if (reason === 'clickaway') {
return;
}
setOpen(false);
}}
startDecorator={<InfoOutlined />}
endDecorator={
<IconButton
onClick={() => setOpen(false)}
sx={{ color: 'inherit', '--Icon-color': 'inherit' }}
>
<Close />
</IconButton>
}
{...props}
>
<div>
<Typography level="title-md" sx={{ color: 'inherit' }}>
Notification alert
</Typography>
<Typography level="body-sm" sx={{ color: 'inherit', opacity: 0.6 }}>
102 unread messages since last month.
</Typography>
</div>
</Snackbar>
</React.Fragment>
)}
/>
);
}
| 1,519 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarVariants.js | import * as React from 'react';
import Button from '@mui/joy/Button';
import Stack from '@mui/joy/Stack';
import Snackbar from '@mui/joy/Snackbar';
export default function SnackbarVariants() {
const [open, setOpen] = React.useState(false);
const [variant, setVariant] = React.useState('outlined');
return (
<Stack spacing={2} direction="row">
<Button
variant="plain"
color="neutral"
onClick={() => {
setOpen(true);
setVariant('plain');
}}
>
plain
</Button>
<Button
variant="outlined"
color="neutral"
onClick={() => {
setOpen(true);
setVariant('outlined');
}}
>
outlined
</Button>
<Button
variant="soft"
color="neutral"
onClick={() => {
setOpen(true);
setVariant('soft');
}}
>
soft
</Button>
<Button
variant="solid"
color="neutral"
onClick={() => {
setOpen(true);
setVariant('solid');
}}
>
solid
</Button>
<Snackbar
autoHideDuration={3000}
open={open}
variant={variant}
onClose={(event, reason) => {
if (reason === 'clickaway') {
return;
}
setOpen(false);
}}
>
A snackbar with {variant} variant.
</Snackbar>
</Stack>
);
}
| 1,520 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarVariants.tsx | import * as React from 'react';
import Button from '@mui/joy/Button';
import Stack from '@mui/joy/Stack';
import Snackbar, { SnackbarProps } from '@mui/joy/Snackbar';
export default function SnackbarVariants() {
const [open, setOpen] = React.useState(false);
const [variant, setVariant] = React.useState<SnackbarProps['variant']>('outlined');
return (
<Stack spacing={2} direction="row">
<Button
variant="plain"
color="neutral"
onClick={() => {
setOpen(true);
setVariant('plain');
}}
>
plain
</Button>
<Button
variant="outlined"
color="neutral"
onClick={() => {
setOpen(true);
setVariant('outlined');
}}
>
outlined
</Button>
<Button
variant="soft"
color="neutral"
onClick={() => {
setOpen(true);
setVariant('soft');
}}
>
soft
</Button>
<Button
variant="solid"
color="neutral"
onClick={() => {
setOpen(true);
setVariant('solid');
}}
>
solid
</Button>
<Snackbar
autoHideDuration={3000}
open={open}
variant={variant}
onClose={(event, reason) => {
if (reason === 'clickaway') {
return;
}
setOpen(false);
}}
>
A snackbar with {variant} variant.
</Snackbar>
</Stack>
);
}
| 1,521 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarWithDecorators.js | import * as React from 'react';
import Button from '@mui/joy/Button';
import Snackbar from '@mui/joy/Snackbar';
import PlaylistAddCheckCircleRoundedIcon from '@mui/icons-material/PlaylistAddCheckCircleRounded';
export default function SnackbarWithDecorators() {
const [open, setOpen] = React.useState(false);
return (
<React.Fragment>
<Button variant="outlined" color="neutral" onClick={() => setOpen(true)}>
Show Snackbar
</Button>
<Snackbar
variant="soft"
color="success"
open={open}
onClose={() => setOpen(false)}
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
startDecorator={<PlaylistAddCheckCircleRoundedIcon />}
endDecorator={
<Button
onClick={() => setOpen(false)}
size="sm"
variant="soft"
color="success"
>
Dismiss
</Button>
}
>
Your message was sent successfully.
</Snackbar>
</React.Fragment>
);
}
| 1,522 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/SnackbarWithDecorators.tsx | import * as React from 'react';
import Button from '@mui/joy/Button';
import Snackbar from '@mui/joy/Snackbar';
import PlaylistAddCheckCircleRoundedIcon from '@mui/icons-material/PlaylistAddCheckCircleRounded';
export default function SnackbarWithDecorators() {
const [open, setOpen] = React.useState(false);
return (
<React.Fragment>
<Button variant="outlined" color="neutral" onClick={() => setOpen(true)}>
Show Snackbar
</Button>
<Snackbar
variant="soft"
color="success"
open={open}
onClose={() => setOpen(false)}
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
startDecorator={<PlaylistAddCheckCircleRoundedIcon />}
endDecorator={
<Button
onClick={() => setOpen(false)}
size="sm"
variant="soft"
color="success"
>
Dismiss
</Button>
}
>
Your message was sent successfully.
</Snackbar>
</React.Fragment>
);
}
| 1,523 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/snackbar/snackbar.md | ---
productId: joy-ui
title: React Snackbar component
components: Snackbar
githubLabel: 'component: snackbar'
waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/alert/
---
# Snackbar
<p class="description">The Snackbar, also commonly referred to as Toast, component informs users that an action has been or will be performed by the app.</p>
{{"component": "modules/components/ComponentLinkHeader.js"}}
## Introduction
Snackbars are designed to provide brief, non-intrusive notifications to users, informing them about processes an app has performed or will perform.
By default, the snackbar is displayed in the lower-right corner of the screen. They are designed not to disrupt the user's workflow and can be dismissed automatically without the need of any user interaction.
Snackbars contain a single line of text directly related to the operation performed. They can contain text actions, but no icons.
{{"demo": "SnackbarUsage.js", "hideToolbar": true, "bg": "gradient"}}
## Basics
```jsx
import Snackbar from '@mui/joy/Snackbar';
```
### Position
The position of the snackbar can be controlled by specifying the `anchorOrigin` prop.
In wider layouts, snackbars can be aligned to the left or centered, especially if they are consistently positioned in a specific location at the bottom of the screen. However, in some cases, you may need more flexible positioning.
{{"demo": "PositionedSnackbar.js"}}
## Customization
### Variants
The Snackbar component supports Joy UI's four [global variants](/joy-ui/main-features/global-variants/): `plain`, `outlined` (default), `soft`, and `solid`.
{{"demo": "SnackbarVariants.js"}}
:::info
To learn how to add your own variants, check out [Themed components—Extend variants](/joy-ui/customization/themed-components/#extend-variants).
Note that you lose the global variants when you add custom variants.
:::
### Sizes
The Snackbar component comes in three sizes: `sm`, `md` (default), and `lg`.
{{"demo": "SnackbarSizes.js"}}
:::info
To learn how to add custom sizes to the component, check out [Themed components—Extend sizes](/joy-ui/customization/themed-components/#extend-sizes).
:::
### Colors
Every palette included in the theme is available via the `color` prop.
Play around combining different colors with different variants.
{{"demo": "SnackbarColors.js"}}
### Hide duration
Use `autoHideDuration` prop to control how long the Snackbar is displayed. If it is not provided, the Snackbar will be displayed until the user dismisses it.
{{"demo": "SnackbarHideDuration.js"}}
### Close reason
There are three reasons for the Snackbar to close:
- `timeout`: The Snackbar is closed after the `autoHideDuration` prop timer expires.
- `clickaway`: The Snackbar is closed when the user interacts outside of the Snackbar.
- `escapeKeyDown`: The Snackbar is closed when the user presses the escape key.
You can access the value from the second argument of the `onClose` callback.
```js
<Snackbar onClose={(event, reason) => {
// reason will be one of: timeout, clickaway, escapeKeyDown
}}>
```
{{"demo": "SnackbarCloseReason.js"}}
#### Ignore clickaway
This pattern is useful when you don't want the Snackbar to close when the user clicks outside of it.
```js
<Snackbar
onClose={(event, reason) => {
if (reason === 'clickaway') {
return;
}
}}
>
```
### Decorators
Use the `startDecorator` and `endDecorator` props to append icons and/or actions to either side of the Snackbar.
{{"demo": "SnackbarWithDecorators.js"}}
### Inverted colors
When the Snackbar's variant is `soft` or `solid`, you can set `invertedColors` prop to `true` to invert the colors of the children for increasing the contrast.
To learn more about this, check out [Color Inversion](/joy-ui/main-features/color-inversion/) feature.
{{"demo": "SnackbarInvertedColors.js"}}
### Animation
To apply a custom animation, provide the `animationDuration` prop, which we'll use to match the component's unmount animation accurately.
{{"demo": "CustomAnimatedSnackbar.js"}}
| 1,524 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/BasicStack.js | import * as React from 'react';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import Box from '@mui/joy/Box';
import { styled } from '@mui/joy/styles';
const Item = styled(Sheet)(({ theme }) => ({
...theme.typography['body-sm'],
textAlign: 'center',
fontWeight: theme.fontWeight.md,
color: theme.vars.palette.text.secondary,
border: '1px solid',
borderColor: theme.palette.divider,
padding: theme.spacing(1),
borderRadius: theme.radius.md,
}));
export default function BasicStack() {
return (
<Box sx={{ width: '100%' }}>
<Stack spacing={2}>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack>
</Box>
);
}
| 1,525 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/BasicStack.tsx | import * as React from 'react';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import Box from '@mui/joy/Box';
import { styled } from '@mui/joy/styles';
const Item = styled(Sheet)(({ theme }) => ({
...theme.typography['body-sm'],
textAlign: 'center',
fontWeight: theme.fontWeight.md,
color: theme.vars.palette.text.secondary,
border: '1px solid',
borderColor: theme.palette.divider,
padding: theme.spacing(1),
borderRadius: theme.radius.md,
}));
export default function BasicStack() {
return (
<Box sx={{ width: '100%' }}>
<Stack spacing={2}>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack>
</Box>
);
}
| 1,526 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/BasicStack.tsx.preview | <Stack spacing={2}>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack> | 1,527 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/DirectionStack.js | import * as React from 'react';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';
const Item = styled(Sheet)(({ theme }) => ({
...theme.typography['body-sm'],
textAlign: 'center',
fontWeight: theme.fontWeight.md,
color: theme.vars.palette.text.secondary,
border: '1px solid',
borderColor: theme.palette.divider,
padding: theme.spacing(1),
borderRadius: theme.radius.md,
}));
export default function DirectionStack() {
return (
<div>
<Stack direction="row" spacing={1}>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack>
</div>
);
}
| 1,528 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/DirectionStack.tsx | import * as React from 'react';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';
const Item = styled(Sheet)(({ theme }) => ({
...theme.typography['body-sm'],
textAlign: 'center',
fontWeight: theme.fontWeight.md,
color: theme.vars.palette.text.secondary,
border: '1px solid',
borderColor: theme.palette.divider,
padding: theme.spacing(1),
borderRadius: theme.radius.md,
}));
export default function DirectionStack() {
return (
<div>
<Stack direction="row" spacing={1}>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack>
</div>
);
}
| 1,529 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/DirectionStack.tsx.preview | <Stack direction="row" spacing={1}>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack> | 1,530 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/DividerStack.js | import * as React from 'react';
import Divider from '@mui/joy/Divider';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import Box from '@mui/joy/Box';
import { styled } from '@mui/joy/styles';
const Item = styled(Sheet)(({ theme }) => ({
...theme.typography['body-sm'],
textAlign: 'center',
fontWeight: theme.fontWeight.md,
color: theme.vars.palette.text.secondary,
border: '1px solid',
borderColor: theme.palette.divider,
padding: theme.spacing(1),
borderRadius: theme.radius.md,
}));
export default function DividerStack() {
return (
<Box sx={{ width: '100%' }}>
<Stack
direction="row"
divider={<Divider orientation="vertical" />}
spacing={2}
justifyContent="center"
>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack>
</Box>
);
}
| 1,531 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/DividerStack.tsx | import * as React from 'react';
import Divider from '@mui/joy/Divider';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import Box from '@mui/joy/Box';
import { styled } from '@mui/joy/styles';
const Item = styled(Sheet)(({ theme }) => ({
...theme.typography['body-sm'],
textAlign: 'center',
fontWeight: theme.fontWeight.md,
color: theme.vars.palette.text.secondary,
border: '1px solid',
borderColor: theme.palette.divider,
padding: theme.spacing(1),
borderRadius: theme.radius.md,
}));
export default function DividerStack() {
return (
<Box sx={{ width: '100%' }}>
<Stack
direction="row"
divider={<Divider orientation="vertical" />}
spacing={2}
justifyContent="center"
>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack>
</Box>
);
}
| 1,532 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/DividerStack.tsx.preview | <Stack
direction="row"
divider={<Divider orientation="vertical" />}
spacing={2}
justifyContent="center"
>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack> | 1,533 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/FlexboxGapStack.js | import * as React from 'react';
import Box from '@mui/joy/Box';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';
const Item = styled(Sheet)(({ theme }) => ({
...theme.typography['body-sm'],
textAlign: 'center',
fontWeight: theme.fontWeight.md,
color: theme.vars.palette.text.secondary,
border: '1px solid',
borderColor: theme.palette.divider,
padding: theme.spacing(1),
borderRadius: theme.radius.md,
flexGrow: 1,
}));
export default function FlexboxGapStack() {
return (
<Box sx={{ width: 200 }}>
<Stack spacing={1} direction="row" flexWrap="wrap" useFlexGap>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Long content</Item>
</Stack>
</Box>
);
}
| 1,534 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/FlexboxGapStack.tsx | import * as React from 'react';
import Box from '@mui/joy/Box';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';
const Item = styled(Sheet)(({ theme }) => ({
...theme.typography['body-sm'],
textAlign: 'center',
fontWeight: theme.fontWeight.md,
color: theme.vars.palette.text.secondary,
border: '1px solid',
borderColor: theme.palette.divider,
padding: theme.spacing(1),
borderRadius: theme.radius.md,
flexGrow: 1,
}));
export default function FlexboxGapStack() {
return (
<Box sx={{ width: 200 }}>
<Stack spacing={1} direction="row" flexWrap="wrap" useFlexGap>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Long content</Item>
</Stack>
</Box>
);
}
| 1,535 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/FlexboxGapStack.tsx.preview | <Stack spacing={1} direction="row" flexWrap="wrap" useFlexGap>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Long content</Item>
</Stack> | 1,536 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/InteractiveStack.js | import * as React from 'react';
import FormControl from '@mui/joy/FormControl';
import FormLabel from '@mui/joy/FormLabel';
import Grid from '@mui/joy/Grid';
import Sheet from '@mui/joy/Sheet';
import RadioGroup from '@mui/joy/RadioGroup';
import Radio from '@mui/joy/Radio';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';
import HighlightedCode from 'docs/src/modules/components/HighlightedCode';
import BrandingProvider from 'docs/src/BrandingProvider';
const Item = styled(Sheet)(({ theme }) => ({
...theme.typography['body-sm'],
textAlign: 'center',
fontWeight: theme.fontWeight.md,
color: theme.vars.palette.text.secondary,
border: '1px solid',
borderColor: theme.palette.divider,
borderRadius: theme.radius.md,
}));
export default function InteractiveStack() {
const [direction, setDirection] = React.useState('row');
const [justifyContent, setJustifyContent] = React.useState('center');
const [alignItems, setAlignItems] = React.useState('center');
const [spacing, setSpacing] = React.useState(2);
const jsx = `
<Stack
direction="${direction}"
justifyContent="${justifyContent}"
alignItems="${alignItems}"
spacing={${spacing}}
>
`;
return (
<Stack sx={{ flexGrow: 1, '* pre': { mb: 0 } }}>
<Stack
direction={direction}
justifyContent={justifyContent}
alignItems={alignItems}
spacing={spacing}
sx={{ minHeight: 200, pb: 3 }}
>
{[0, 1, 2].map((value) => (
<Item
key={value}
sx={{
p: 2,
pt: value + 1,
pb: value + 1,
}}
>
{`Item ${value + 1}`}
</Item>
))}
</Stack>
<Sheet
variant="outlined"
sx={(theme) => ({
p: 2,
borderRadius: 'md',
bgcolor: theme.palette.neutral[50],
borderColor: theme.palette.neutral[100],
[theme.getColorSchemeSelector('dark')]: {
borderColor: theme.palette.neutral[800],
backgroundColor: theme.palette.neutral[900],
},
})}
>
<Grid container spacing={3}>
<Grid xs={12}>
<FormControl>
<FormLabel sx={{ mb: 0.5 }}>direction</FormLabel>
<RadioGroup
size="sm"
orientation="horizontal"
name="direction"
aria-label="direction"
value={direction}
onChange={(event) => {
setDirection(event.target.value);
}}
sx={{ flexWrap: 'wrap', gap: 2, '--RadioGroup-gap': '0px' }}
>
<Radio label="row" value="row" />
<Radio label="row-reverse" value="row-reverse" />
<Radio label="column" value="column" />
<Radio label="column-reverse" value="column-reverse" />
</RadioGroup>
</FormControl>
</Grid>
<Grid xs={12}>
<FormControl>
<FormLabel sx={{ mb: 0.5 }}>alignItems</FormLabel>
<RadioGroup
size="sm"
orientation="horizontal"
name="alignItems"
aria-label="align items"
value={alignItems}
onChange={(event) => {
setAlignItems(event.target.value);
}}
sx={{ flexWrap: 'wrap', gap: 2, '--RadioGroup-gap': '0px' }}
>
<Radio label="flex-start" value="flex-start" />
<Radio label="center" value="center" />
<Radio label="flex-end" value="flex-end" />
<Radio label="stretch" value="stretch" />
<Radio label="baseline" value="baseline" />
</RadioGroup>
</FormControl>
</Grid>
<Grid xs={12}>
<FormControl>
<FormLabel sx={{ mb: 0.5 }}>justifyContent</FormLabel>
<RadioGroup
size="sm"
orientation="horizontal"
name="justifyContent"
aria-label="justifyContent"
value={justifyContent}
onChange={(event) => {
setJustifyContent(event.target.value);
}}
sx={{ flexWrap: 'wrap', gap: 2, '--RadioGroup-gap': '0px' }}
>
<Radio label="flex-start" value="flex-start" />
<Radio label="center" value="center" />
<Radio label="flex-end" value="flex-end" />
<Radio label="space-between" value="space-between" />
<Radio label="space-around" value="space-around" />
<Radio label="space-evenly" value="space-evenly" />
</RadioGroup>
</FormControl>
</Grid>
<Grid xs={12}>
<FormControl>
<FormLabel sx={{ mb: 0.5 }}>spacing</FormLabel>
<RadioGroup
size="sm"
orientation="horizontal"
name="spacing"
aria-label="spacing"
value={spacing.toString()}
onChange={(event) => {
setSpacing(Number(event.target.value));
}}
sx={{ flexWrap: 'wrap', gap: 2, '--RadioGroup-gap': '0px' }}
>
{[0, 0.5, 1, 2, 3, 4, 8, 12].map((value) => (
<Radio
key={value}
label={value.toString()}
value={value.toString()}
/>
))}
</RadioGroup>
</FormControl>
</Grid>
</Grid>
</Sheet>
<BrandingProvider mode="dark">
<HighlightedCode code={jsx} language="jsx" />
</BrandingProvider>
</Stack>
);
}
| 1,537 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/InteractiveStack.tsx | import * as React from 'react';
import FormControl from '@mui/joy/FormControl';
import FormLabel from '@mui/joy/FormLabel';
import Grid from '@mui/joy/Grid';
import Sheet from '@mui/joy/Sheet';
import RadioGroup from '@mui/joy/RadioGroup';
import Radio from '@mui/joy/Radio';
import Stack, { StackProps } from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';
import HighlightedCode from 'docs/src/modules/components/HighlightedCode';
import BrandingProvider from 'docs/src/BrandingProvider';
const Item = styled(Sheet)(({ theme }) => ({
...theme.typography['body-sm'],
textAlign: 'center',
fontWeight: theme.fontWeight.md,
color: theme.vars.palette.text.secondary,
border: '1px solid',
borderColor: theme.palette.divider,
borderRadius: theme.radius.md,
}));
export default function InteractiveStack() {
const [direction, setDirection] = React.useState<StackProps['direction']>('row');
const [justifyContent, setJustifyContent] = React.useState('center');
const [alignItems, setAlignItems] = React.useState('center');
const [spacing, setSpacing] = React.useState(2);
const jsx = `
<Stack
direction="${direction}"
justifyContent="${justifyContent}"
alignItems="${alignItems}"
spacing={${spacing}}
>
`;
return (
<Stack sx={{ flexGrow: 1, '* pre': { mb: 0 } }}>
<Stack
direction={direction}
justifyContent={justifyContent}
alignItems={alignItems}
spacing={spacing}
sx={{ minHeight: 200, pb: 3 }}
>
{[0, 1, 2].map((value) => (
<Item
key={value}
sx={{
p: 2,
pt: value + 1,
pb: value + 1,
}}
>
{`Item ${value + 1}`}
</Item>
))}
</Stack>
<Sheet
variant="outlined"
sx={(theme) => ({
p: 2,
borderRadius: 'md',
bgcolor: theme.palette.neutral[50],
borderColor: theme.palette.neutral[100],
[theme.getColorSchemeSelector('dark')]: {
borderColor: theme.palette.neutral[800],
backgroundColor: theme.palette.neutral[900],
},
})}
>
<Grid container spacing={3}>
<Grid xs={12}>
<FormControl>
<FormLabel sx={{ mb: 0.5 }}>direction</FormLabel>
<RadioGroup
size="sm"
orientation="horizontal"
name="direction"
aria-label="direction"
value={direction}
onChange={(event) => {
setDirection(event.target.value as StackProps['direction']);
}}
sx={{ flexWrap: 'wrap', gap: 2, '--RadioGroup-gap': '0px' }}
>
<Radio label="row" value="row" />
<Radio label="row-reverse" value="row-reverse" />
<Radio label="column" value="column" />
<Radio label="column-reverse" value="column-reverse" />
</RadioGroup>
</FormControl>
</Grid>
<Grid xs={12}>
<FormControl>
<FormLabel sx={{ mb: 0.5 }}>alignItems</FormLabel>
<RadioGroup
size="sm"
orientation="horizontal"
name="alignItems"
aria-label="align items"
value={alignItems}
onChange={(event) => {
setAlignItems(event.target.value);
}}
sx={{ flexWrap: 'wrap', gap: 2, '--RadioGroup-gap': '0px' }}
>
<Radio label="flex-start" value="flex-start" />
<Radio label="center" value="center" />
<Radio label="flex-end" value="flex-end" />
<Radio label="stretch" value="stretch" />
<Radio label="baseline" value="baseline" />
</RadioGroup>
</FormControl>
</Grid>
<Grid xs={12}>
<FormControl>
<FormLabel sx={{ mb: 0.5 }}>justifyContent</FormLabel>
<RadioGroup
size="sm"
orientation="horizontal"
name="justifyContent"
aria-label="justifyContent"
value={justifyContent}
onChange={(event) => {
setJustifyContent(event.target.value);
}}
sx={{ flexWrap: 'wrap', gap: 2, '--RadioGroup-gap': '0px' }}
>
<Radio label="flex-start" value="flex-start" />
<Radio label="center" value="center" />
<Radio label="flex-end" value="flex-end" />
<Radio label="space-between" value="space-between" />
<Radio label="space-around" value="space-around" />
<Radio label="space-evenly" value="space-evenly" />
</RadioGroup>
</FormControl>
</Grid>
<Grid xs={12}>
<FormControl>
<FormLabel sx={{ mb: 0.5 }}>spacing</FormLabel>
<RadioGroup
size="sm"
orientation="horizontal"
name="spacing"
aria-label="spacing"
value={spacing.toString()}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
setSpacing(Number((event.target as HTMLInputElement).value));
}}
sx={{ flexWrap: 'wrap', gap: 2, '--RadioGroup-gap': '0px' }}
>
{[0, 0.5, 1, 2, 3, 4, 8, 12].map((value) => (
<Radio
key={value}
label={value.toString()}
value={value.toString()}
/>
))}
</RadioGroup>
</FormControl>
</Grid>
</Grid>
</Sheet>
<BrandingProvider mode="dark">
<HighlightedCode code={jsx} language="jsx" />
</BrandingProvider>
</Stack>
);
}
| 1,538 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/ResponsiveStack.js | import * as React from 'react';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';
const Item = styled(Sheet)(({ theme }) => ({
...theme.typography['body-sm'],
textAlign: 'center',
fontWeight: theme.fontWeight.md,
color: theme.vars.palette.text.secondary,
border: '1px solid',
borderColor: theme.palette.divider,
padding: theme.spacing(1),
borderRadius: theme.radius.md,
}));
export default function ResponsiveStack() {
return (
<div>
<Stack
direction={{ xs: 'column', sm: 'row' }}
spacing={{ xs: 1, sm: 2, md: 4 }}
>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack>
</div>
);
}
| 1,539 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/ResponsiveStack.tsx | import * as React from 'react';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';
const Item = styled(Sheet)(({ theme }) => ({
...theme.typography['body-sm'],
textAlign: 'center',
fontWeight: theme.fontWeight.md,
color: theme.vars.palette.text.secondary,
border: '1px solid',
borderColor: theme.palette.divider,
padding: theme.spacing(1),
borderRadius: theme.radius.md,
}));
export default function ResponsiveStack() {
return (
<div>
<Stack
direction={{ xs: 'column', sm: 'row' }}
spacing={{ xs: 1, sm: 2, md: 4 }}
>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack>
</div>
);
}
| 1,540 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/ResponsiveStack.tsx.preview | <Stack
direction={{ xs: 'column', sm: 'row' }}
spacing={{ xs: 1, sm: 2, md: 4 }}
>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack> | 1,541 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/ZeroWidthStack.js | import * as React from 'react';
import Avatar from '@mui/joy/Avatar';
import Box from '@mui/joy/Box';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';
import Typography from '@mui/joy/Typography';
const Item = styled(Sheet)(({ theme }) => ({
...theme.typography['body-sm'],
padding: theme.spacing(1),
textAlign: 'center',
borderRadius: 4,
color: theme.vars.palette.text.secondary,
maxWidth: 400,
}));
const message = `Truncation should be conditionally applicable on this long line of text
as this is a much longer line than what the container can support.`;
export default function ZeroWidthStack() {
return (
<Box sx={{ flexGrow: 1, overflow: 'hidden', px: 3 }}>
<Item
variant="outlined"
sx={{
my: 1,
mx: 'auto',
p: 2,
}}
>
<Stack spacing={2} direction="row" alignItems="center">
<Avatar>W</Avatar>
<Typography noWrap>{message}</Typography>
</Stack>
</Item>
<Item
variant="outlined"
sx={{
my: 1,
mx: 'auto',
p: 2,
}}
>
<Stack spacing={2} direction="row" alignItems="center">
<Stack>
<Avatar>W</Avatar>
</Stack>
<Stack sx={{ minWidth: 0 }}>
<Typography noWrap>{message}</Typography>
</Stack>
</Stack>
</Item>
</Box>
);
}
| 1,542 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/ZeroWidthStack.tsx | import * as React from 'react';
import Avatar from '@mui/joy/Avatar';
import Box from '@mui/joy/Box';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';
import Typography from '@mui/joy/Typography';
const Item = styled(Sheet)(({ theme }) => ({
...theme.typography['body-sm'],
padding: theme.spacing(1),
textAlign: 'center',
borderRadius: 4,
color: theme.vars.palette.text.secondary,
maxWidth: 400,
}));
const message = `Truncation should be conditionally applicable on this long line of text
as this is a much longer line than what the container can support.`;
export default function ZeroWidthStack() {
return (
<Box sx={{ flexGrow: 1, overflow: 'hidden', px: 3 }}>
<Item
variant="outlined"
sx={{
my: 1,
mx: 'auto',
p: 2,
}}
>
<Stack spacing={2} direction="row" alignItems="center">
<Avatar>W</Avatar>
<Typography noWrap>{message}</Typography>
</Stack>
</Item>
<Item
variant="outlined"
sx={{
my: 1,
mx: 'auto',
p: 2,
}}
>
<Stack spacing={2} direction="row" alignItems="center">
<Stack>
<Avatar>W</Avatar>
</Stack>
<Stack sx={{ minWidth: 0 }}>
<Typography noWrap>{message}</Typography>
</Stack>
</Stack>
</Item>
</Box>
);
}
| 1,543 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stack/stack.md | ---
productId: joy-ui
title: React Stack component
components: Stack
githubLabel: 'component: Stack'
---
# Stack
<p class="description">Stack is a container component for arranging elements vertically or horizontally.</p>
{{"component": "modules/components/ComponentLinkHeader.js"}}
## Introduction
The Stack component manages the layout of its immediate children along the vertical or horizontal axis, with optional spacing and dividers between each child.
{{"demo": "InteractiveStack.js", "hideToolbar": true}}
## Basics
```jsx
import Stack from '@mui/joy/Stack';
```
The Stack component acts as a generic container, wrapping around the elements to be arranged.
Use the `spacing` prop to control the space between children.
The spacing value can be any number, including decimals, or a string.
(The prop is converted into a CSS property using the [`theme.spacing()`](/material-ui/customization/spacing/) helper.)
{{"demo": "BasicStack.js"}}
### Stack vs. Grid
Stack is ideal for one-dimensional layouts, while [Grid](/joy-ui/react-grid/) is preferable when you need both vertical _and_ horizontal arrangement.
## Customization
### Direction
By default, Stack arranges items vertically in a column.
Use the `direction` prop to position items horizontally in a row:
{{"demo": "DirectionStack.js"}}
### Dividers
Use the `divider` prop to insert an element between each child.
This works particularly well with the [Divider](/joy-ui/react-divider/) component, as shown below:
{{"demo": "DividerStack.js"}}
### Responsive values
You can switch the `direction` or `spacing` values based on the active breakpoint.
{{"demo": "ResponsiveStack.js"}}
### Flexbox gap
To use [flexbox `gap`](https://developer.mozilla.org/en-US/docs/Web/CSS/gap) for the spacing implementation, set the `useFlexGap` prop to true.
It removes the [known limitations](#limitations) of the default implementation that uses a CSS nested selector.
:::info
The CSS flexbox gap property is not fully supported in some browsers.
We recommend checking the [support percentage](https://caniuse.com/?search=flex%20gap) before using it.
:::
{{"demo": "FlexboxGapStack.js"}}
To set the prop to all stack instances, create a theme with default props:
```js
import { CssVarsProvider, extendTheme } from '@mui/joy/styles';
import Stack from '@mui/joy/Stack';
const theme = extendTheme({
components: {
JoyStack: {
defaultProps: {
useFlexGap: true,
},
},
},
});
function App() {
return (
<CssVarsProvider theme={theme}>
<Stack>…</Stack> {/* uses flexbox gap by default */}
</CssVarsProvider>
);
}
```
### System props
As a CSS utility component, Stack supports all [MUI System properties](/system/properties/).
You can use them as props directly on the component.
For instance, a margin-top:
```jsx
<Stack mt={2}>
```
## Limitations
### Margin on the children
Customizing the margin on the children is not supported by default.
For instance, the top-margin on the `Button` component below will be ignored.
```jsx
<Stack>
<Button sx={{ marginTop: '30px' }}>...</Button>
</Stack>
```
:::success
To overcome this limitation, set [`useFlexGap`](#flexbox-gap) prop to true to switch to CSS flexbox gap implementation.
You can learn more about this limitation by visiting this [RFC](https://github.com/mui/material-ui/issues/33754).
:::
### white-space: nowrap
The initial setting on flex items is `min-width: auto`.
This causes a positioning conflict when children use `white-space: nowrap;`.
You can reproduce the issue with:
```jsx
<Stack direction="row">
<Typography noWrap>
```
In order for the item to stay within the container you need to set `min-width: 0`.
```jsx
<Stack direction="row" sx={{ minWidth: 0 }}>
<Typography noWrap>
```
{{"demo": "ZeroWidthStack.js"}}
## Anatomy
The Stack component is composed of a single root `<div>` element:
```html
<div class="MuiStack-root">
<!-- Stack contents -->
</div>
```
| 1,544 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/BasicStepper.js | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
export default function BasicStepper() {
return (
<Stepper sx={{ width: '100%' }}>
<Step>Step 1</Step>
<Step>Step 2</Step>
<Step>Step 3</Step>
</Stepper>
);
}
| 1,545 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/BasicStepper.tsx | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
export default function BasicStepper() {
return (
<Stepper sx={{ width: '100%' }}>
<Step>Step 1</Step>
<Step>Step 2</Step>
<Step>Step 3</Step>
</Stepper>
);
}
| 1,546 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/BasicStepper.tsx.preview | <Stepper sx={{ width: '100%' }}>
<Step>Step 1</Step>
<Step>Step 2</Step>
<Step>Step 3</Step>
</Stepper> | 1,547 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/ButtonStepper.js | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import StepButton from '@mui/joy/StepButton';
import StepIndicator from '@mui/joy/StepIndicator';
import Check from '@mui/icons-material/Check';
const steps = ['Order placed', 'In review', 'Approved'];
export default function ButtonStepper() {
const [activeStep, setActiveStep] = React.useState(1);
return (
<Stepper sx={{ width: '100%' }}>
{steps.map((step, index) => (
<Step
key={step}
indicator={
<StepIndicator
variant={activeStep <= index ? 'soft' : 'solid'}
color={activeStep < index ? 'neutral' : 'primary'}
>
{activeStep <= index ? index + 1 : <Check />}
</StepIndicator>
}
sx={{
'&::after': {
...(activeStep > index &&
index !== 2 && { bgcolor: 'primary.solidBg' }),
},
}}
>
<StepButton onClick={() => setActiveStep(index)}>{step}</StepButton>
</Step>
))}
</Stepper>
);
}
| 1,548 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/ButtonStepper.tsx | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import StepButton from '@mui/joy/StepButton';
import StepIndicator from '@mui/joy/StepIndicator';
import Check from '@mui/icons-material/Check';
const steps = ['Order placed', 'In review', 'Approved'];
export default function ButtonStepper() {
const [activeStep, setActiveStep] = React.useState(1);
return (
<Stepper sx={{ width: '100%' }}>
{steps.map((step, index) => (
<Step
key={step}
indicator={
<StepIndicator
variant={activeStep <= index ? 'soft' : 'solid'}
color={activeStep < index ? 'neutral' : 'primary'}
>
{activeStep <= index ? index + 1 : <Check />}
</StepIndicator>
}
sx={{
'&::after': {
...(activeStep > index &&
index !== 2 && { bgcolor: 'primary.solidBg' }),
},
}}
>
<StepButton onClick={() => setActiveStep(index)}>{step}</StepButton>
</Step>
))}
</Stepper>
);
}
| 1,549 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/CompanyRegistrationStepper.js | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step, { stepClasses } from '@mui/joy/Step';
import StepIndicator, { stepIndicatorClasses } from '@mui/joy/StepIndicator';
import Typography, { typographyClasses } from '@mui/joy/Typography';
import CheckRoundedIcon from '@mui/icons-material/CheckRounded';
import AppRegistrationRoundedIcon from '@mui/icons-material/AppRegistrationRounded';
export default function CompanyRegistrationStepper() {
return (
<Stepper
orientation="vertical"
sx={{
'--Stepper-verticalGap': '2.5rem',
'--StepIndicator-size': '2.5rem',
'--Step-gap': '1rem',
'--Step-connectorInset': '0.5rem',
'--Step-connectorRadius': '1rem',
'--Step-connectorThickness': '4px',
'--joy-palette-success-solidBg': 'var(--joy-palette-success-400)',
[`& .${stepClasses.completed}`]: {
'&::after': { bgcolor: 'success.solidBg' },
},
[`& .${stepClasses.active}`]: {
[`& .${stepIndicatorClasses.root}`]: {
border: '4px solid',
borderColor: '#fff',
boxShadow: (theme) => `0 0 0 1px ${theme.vars.palette.primary[500]}`,
},
},
[`& .${stepClasses.disabled} *`]: {
color: 'neutral.softDisabledColor',
},
[`& .${typographyClasses['title-sm']}`]: {
textTransform: 'uppercase',
letterSpacing: '1px',
fontSize: '10px',
},
}}
>
<Step
completed
indicator={
<StepIndicator variant="solid" color="success">
<CheckRoundedIcon />
</StepIndicator>
}
>
<div>
<Typography level="title-sm">Step 1</Typography>
Basic Details
</div>
</Step>
<Step
completed
indicator={
<StepIndicator variant="solid" color="success">
<CheckRoundedIcon />
</StepIndicator>
}
>
<div>
<Typography level="title-sm">Step 2</Typography>
Company Details
</div>
</Step>
<Step
active
indicator={
<StepIndicator variant="solid" color="primary">
<AppRegistrationRoundedIcon />
</StepIndicator>
}
>
<div>
<Typography level="title-sm">Step 3</Typography>
Subscription plan
</div>
</Step>
<Step disabled indicator={<StepIndicator>3</StepIndicator>}>
<div>
<Typography level="title-sm">Step 4</Typography>
Payment details
</div>
</Step>
</Stepper>
);
}
| 1,550 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/CompanyRegistrationStepper.tsx | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step, { stepClasses } from '@mui/joy/Step';
import StepIndicator, { stepIndicatorClasses } from '@mui/joy/StepIndicator';
import Typography, { typographyClasses } from '@mui/joy/Typography';
import CheckRoundedIcon from '@mui/icons-material/CheckRounded';
import AppRegistrationRoundedIcon from '@mui/icons-material/AppRegistrationRounded';
export default function CompanyRegistrationStepper() {
return (
<Stepper
orientation="vertical"
sx={{
'--Stepper-verticalGap': '2.5rem',
'--StepIndicator-size': '2.5rem',
'--Step-gap': '1rem',
'--Step-connectorInset': '0.5rem',
'--Step-connectorRadius': '1rem',
'--Step-connectorThickness': '4px',
'--joy-palette-success-solidBg': 'var(--joy-palette-success-400)',
[`& .${stepClasses.completed}`]: {
'&::after': { bgcolor: 'success.solidBg' },
},
[`& .${stepClasses.active}`]: {
[`& .${stepIndicatorClasses.root}`]: {
border: '4px solid',
borderColor: '#fff',
boxShadow: (theme) => `0 0 0 1px ${theme.vars.palette.primary[500]}`,
},
},
[`& .${stepClasses.disabled} *`]: {
color: 'neutral.softDisabledColor',
},
[`& .${typographyClasses['title-sm']}`]: {
textTransform: 'uppercase',
letterSpacing: '1px',
fontSize: '10px',
},
}}
>
<Step
completed
indicator={
<StepIndicator variant="solid" color="success">
<CheckRoundedIcon />
</StepIndicator>
}
>
<div>
<Typography level="title-sm">Step 1</Typography>
Basic Details
</div>
</Step>
<Step
completed
indicator={
<StepIndicator variant="solid" color="success">
<CheckRoundedIcon />
</StepIndicator>
}
>
<div>
<Typography level="title-sm">Step 2</Typography>
Company Details
</div>
</Step>
<Step
active
indicator={
<StepIndicator variant="solid" color="primary">
<AppRegistrationRoundedIcon />
</StepIndicator>
}
>
<div>
<Typography level="title-sm">Step 3</Typography>
Subscription plan
</div>
</Step>
<Step disabled indicator={<StepIndicator>3</StepIndicator>}>
<div>
<Typography level="title-sm">Step 4</Typography>
Payment details
</div>
</Step>
</Stepper>
);
}
| 1,551 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/ConnectorStepper.js | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import Stack from '@mui/joy/Stack';
export default function ConnectorStepper() {
return (
<Stack spacing={4} sx={{ width: '100%' }}>
<Stepper>
<Step
sx={{
'&::after': {
height: 2,
borderRadius: '24px',
background:
'linear-gradient(to right, #002f61, #00507b, #006e8e, #008b98, #00a79c)',
},
}}
>
Order placed
</Step>
<Step
sx={{
'&::after': {
height: 2,
borderRadius: '24px',
background:
'linear-gradient(to right, #00c395, #18dc82, #71ee65, #bbf942, #ffff00)',
},
}}
>
In review
</Step>
<Step>Approved</Step>
</Stepper>
</Stack>
);
}
| 1,552 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/ConnectorStepper.tsx | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import Stack from '@mui/joy/Stack';
export default function ConnectorStepper() {
return (
<Stack spacing={4} sx={{ width: '100%' }}>
<Stepper>
<Step
sx={{
'&::after': {
height: 2,
borderRadius: '24px',
background:
'linear-gradient(to right, #002f61, #00507b, #006e8e, #008b98, #00a79c)',
},
}}
>
Order placed
</Step>
<Step
sx={{
'&::after': {
height: 2,
borderRadius: '24px',
background:
'linear-gradient(to right, #00c395, #18dc82, #71ee65, #bbf942, #ffff00)',
},
}}
>
In review
</Step>
<Step>Approved</Step>
</Stepper>
</Stack>
);
}
| 1,553 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/DottedConnector.js | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step, { stepClasses } from '@mui/joy/Step';
import StepIndicator, { stepIndicatorClasses } from '@mui/joy/StepIndicator';
import Typography from '@mui/joy/Typography';
import CheckRoundedIcon from '@mui/icons-material/CheckRounded';
import KeyboardArrowDownRoundedIcon from '@mui/icons-material/KeyboardArrowDownRounded';
export default function DottedConnector() {
return (
<Stepper
sx={{
width: '100%',
[`& .${stepClasses.root}`]: {
flexDirection: 'column-reverse',
'&:after': {
top: 'unset',
bottom:
'calc(var(--StepIndicator-size) / 2 - var(--Step-connectorThickness) / 2)',
},
},
[`& .${stepClasses.completed}::after`]: {
bgcolor: 'primary.500',
},
[`& .${stepClasses.active} .${stepIndicatorClasses.root}`]: {
borderColor: 'primary.500',
},
[`& .${stepClasses.root}:has(+ .${stepClasses.active})::after`]: {
color: 'primary.500',
backgroundColor: 'transparent',
backgroundImage: 'radial-gradient(currentColor 2px, transparent 2px)',
backgroundSize: '7px 7px',
backgroundPosition: 'center left',
},
[`& .${stepClasses.disabled} *`]: {
color: 'neutral.plainDisabledColor',
},
}}
>
<Step
completed
orientation="vertical"
indicator={
<StepIndicator variant="solid" color="primary">
<CheckRoundedIcon />
</StepIndicator>
}
>
<Typography
level="h4"
fontWeight="xl"
endDecorator={
<Typography fontSize="sm" fontWeight="normal">
Preliminary
</Typography>
}
>
01
</Typography>
</Step>
<Step
completed
orientation="vertical"
indicator={
<StepIndicator variant="solid" color="primary">
<CheckRoundedIcon />
</StepIndicator>
}
>
<Typography
level="h4"
fontWeight="xl"
endDecorator={
<Typography fontSize="sm" fontWeight="normal">
Your details
</Typography>
}
>
02
</Typography>
</Step>
<Step
active
orientation="vertical"
indicator={
<StepIndicator variant="outlined" color="primary">
<KeyboardArrowDownRoundedIcon />
</StepIndicator>
}
>
<Typography
level="h4"
fontWeight="xl"
endDecorator={
<Typography fontSize="sm" fontWeight="normal">
KYC
</Typography>
}
>
03
</Typography>
</Step>
<Step
disabled
orientation="vertical"
indicator={<StepIndicator variant="outlined" color="neutral" />}
>
<Typography
level="h4"
fontWeight="xl"
endDecorator={
<Typography fontSize="sm" fontWeight="normal">
KYC
</Typography>
}
>
04
</Typography>
</Step>
</Stepper>
);
}
| 1,554 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/DottedConnector.tsx | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step, { stepClasses } from '@mui/joy/Step';
import StepIndicator, { stepIndicatorClasses } from '@mui/joy/StepIndicator';
import Typography from '@mui/joy/Typography';
import CheckRoundedIcon from '@mui/icons-material/CheckRounded';
import KeyboardArrowDownRoundedIcon from '@mui/icons-material/KeyboardArrowDownRounded';
export default function DottedConnector() {
return (
<Stepper
sx={{
width: '100%',
[`& .${stepClasses.root}`]: {
flexDirection: 'column-reverse',
'&:after': {
top: 'unset',
bottom:
'calc(var(--StepIndicator-size) / 2 - var(--Step-connectorThickness) / 2)',
},
},
[`& .${stepClasses.completed}::after`]: {
bgcolor: 'primary.500',
},
[`& .${stepClasses.active} .${stepIndicatorClasses.root}`]: {
borderColor: 'primary.500',
},
[`& .${stepClasses.root}:has(+ .${stepClasses.active})::after`]: {
color: 'primary.500',
backgroundColor: 'transparent',
backgroundImage: 'radial-gradient(currentColor 2px, transparent 2px)',
backgroundSize: '7px 7px',
backgroundPosition: 'center left',
},
[`& .${stepClasses.disabled} *`]: {
color: 'neutral.plainDisabledColor',
},
}}
>
<Step
completed
orientation="vertical"
indicator={
<StepIndicator variant="solid" color="primary">
<CheckRoundedIcon />
</StepIndicator>
}
>
<Typography
level="h4"
fontWeight="xl"
endDecorator={
<Typography fontSize="sm" fontWeight="normal">
Preliminary
</Typography>
}
>
01
</Typography>
</Step>
<Step
completed
orientation="vertical"
indicator={
<StepIndicator variant="solid" color="primary">
<CheckRoundedIcon />
</StepIndicator>
}
>
<Typography
level="h4"
fontWeight="xl"
endDecorator={
<Typography fontSize="sm" fontWeight="normal">
Your details
</Typography>
}
>
02
</Typography>
</Step>
<Step
active
orientation="vertical"
indicator={
<StepIndicator variant="outlined" color="primary">
<KeyboardArrowDownRoundedIcon />
</StepIndicator>
}
>
<Typography
level="h4"
fontWeight="xl"
endDecorator={
<Typography fontSize="sm" fontWeight="normal">
KYC
</Typography>
}
>
03
</Typography>
</Step>
<Step
disabled
orientation="vertical"
indicator={<StepIndicator variant="outlined" color="neutral" />}
>
<Typography
level="h4"
fontWeight="xl"
endDecorator={
<Typography fontSize="sm" fontWeight="normal">
KYC
</Typography>
}
>
04
</Typography>
</Step>
</Stepper>
);
}
| 1,555 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/IconStepper.js | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step, { stepClasses } from '@mui/joy/Step';
import StepIndicator, { stepIndicatorClasses } from '@mui/joy/StepIndicator';
import Typography from '@mui/joy/Typography';
import ShoppingCartRoundedIcon from '@mui/icons-material/ShoppingCartRounded';
import ContactsRoundedIcon from '@mui/icons-material/ContactsRounded';
import LocalShippingRoundedIcon from '@mui/icons-material/LocalShippingRounded';
import CreditCardRoundedIcon from '@mui/icons-material/CreditCardRounded';
import CheckCircleRoundedIcon from '@mui/icons-material/CheckCircleRounded';
export default function IconStepper() {
return (
<Stepper
size="lg"
sx={{
width: '100%',
'--StepIndicator-size': '3rem',
'--Step-connectorInset': '0px',
[`& .${stepIndicatorClasses.root}`]: {
borderWidth: 4,
},
[`& .${stepClasses.root}::after`]: {
height: 4,
},
[`& .${stepClasses.completed}`]: {
[`& .${stepIndicatorClasses.root}`]: {
borderColor: 'primary.300',
color: 'primary.300',
},
'&::after': {
bgcolor: 'primary.300',
},
},
[`& .${stepClasses.active}`]: {
[`& .${stepIndicatorClasses.root}`]: {
borderColor: 'currentColor',
},
},
[`& .${stepClasses.disabled} *`]: {
color: 'neutral.outlinedDisabledColor',
},
}}
>
<Step
completed
orientation="vertical"
indicator={
<StepIndicator variant="outlined" color="primary">
<ShoppingCartRoundedIcon />
</StepIndicator>
}
/>
<Step
orientation="vertical"
completed
indicator={
<StepIndicator variant="outlined" color="primary">
<ContactsRoundedIcon />
</StepIndicator>
}
/>
<Step
orientation="vertical"
completed
indicator={
<StepIndicator variant="outlined" color="primary">
<LocalShippingRoundedIcon />
</StepIndicator>
}
/>
<Step
orientation="vertical"
active
indicator={
<StepIndicator variant="solid" color="primary">
<CreditCardRoundedIcon />
</StepIndicator>
}
>
<Typography
sx={{
textTransform: 'uppercase',
fontWeight: 'lg',
fontSize: '0.75rem',
letterSpacing: '0.5px',
}}
>
Payment and Billing
</Typography>
</Step>
<Step
orientation="vertical"
disabled
indicator={
<StepIndicator variant="outlined" color="neutral">
<CheckCircleRoundedIcon />
</StepIndicator>
}
/>
</Stepper>
);
}
| 1,556 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/IconStepper.tsx | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step, { stepClasses } from '@mui/joy/Step';
import StepIndicator, { stepIndicatorClasses } from '@mui/joy/StepIndicator';
import Typography from '@mui/joy/Typography';
import ShoppingCartRoundedIcon from '@mui/icons-material/ShoppingCartRounded';
import ContactsRoundedIcon from '@mui/icons-material/ContactsRounded';
import LocalShippingRoundedIcon from '@mui/icons-material/LocalShippingRounded';
import CreditCardRoundedIcon from '@mui/icons-material/CreditCardRounded';
import CheckCircleRoundedIcon from '@mui/icons-material/CheckCircleRounded';
export default function IconStepper() {
return (
<Stepper
size="lg"
sx={{
width: '100%',
'--StepIndicator-size': '3rem',
'--Step-connectorInset': '0px',
[`& .${stepIndicatorClasses.root}`]: {
borderWidth: 4,
},
[`& .${stepClasses.root}::after`]: {
height: 4,
},
[`& .${stepClasses.completed}`]: {
[`& .${stepIndicatorClasses.root}`]: {
borderColor: 'primary.300',
color: 'primary.300',
},
'&::after': {
bgcolor: 'primary.300',
},
},
[`& .${stepClasses.active}`]: {
[`& .${stepIndicatorClasses.root}`]: {
borderColor: 'currentColor',
},
},
[`& .${stepClasses.disabled} *`]: {
color: 'neutral.outlinedDisabledColor',
},
}}
>
<Step
completed
orientation="vertical"
indicator={
<StepIndicator variant="outlined" color="primary">
<ShoppingCartRoundedIcon />
</StepIndicator>
}
/>
<Step
orientation="vertical"
completed
indicator={
<StepIndicator variant="outlined" color="primary">
<ContactsRoundedIcon />
</StepIndicator>
}
/>
<Step
orientation="vertical"
completed
indicator={
<StepIndicator variant="outlined" color="primary">
<LocalShippingRoundedIcon />
</StepIndicator>
}
/>
<Step
orientation="vertical"
active
indicator={
<StepIndicator variant="solid" color="primary">
<CreditCardRoundedIcon />
</StepIndicator>
}
>
<Typography
sx={{
textTransform: 'uppercase',
fontWeight: 'lg',
fontSize: '0.75rem',
letterSpacing: '0.5px',
}}
>
Payment and Billing
</Typography>
</Step>
<Step
orientation="vertical"
disabled
indicator={
<StepIndicator variant="outlined" color="neutral">
<CheckCircleRoundedIcon />
</StepIndicator>
}
/>
</Stepper>
);
}
| 1,557 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/IndicatorStepper.js | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import StepIndicator from '@mui/joy/StepIndicator';
export default function IndicatorStepper() {
return (
<Stepper sx={{ width: '100%' }}>
<Step
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step indicator={<StepIndicator variant="outlined">2</StepIndicator>}>
In review
</Step>
<Step indicator={<StepIndicator>3</StepIndicator>}>Approved</Step>
</Stepper>
);
}
| 1,558 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/IndicatorStepper.tsx | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import StepIndicator from '@mui/joy/StepIndicator';
export default function IndicatorStepper() {
return (
<Stepper sx={{ width: '100%' }}>
<Step
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step indicator={<StepIndicator variant="outlined">2</StepIndicator>}>
In review
</Step>
<Step indicator={<StepIndicator>3</StepIndicator>}>Approved</Step>
</Stepper>
);
}
| 1,559 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/IndicatorStepper.tsx.preview | <Stepper sx={{ width: '100%' }}>
<Step
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step indicator={<StepIndicator variant="outlined">2</StepIndicator>}>
In review
</Step>
<Step indicator={<StepIndicator>3</StepIndicator>}>Approved</Step>
</Stepper> | 1,560 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/IndicatorTopStepper.js | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import StepIndicator from '@mui/joy/StepIndicator';
export default function IndicatorTopStepper() {
return (
<Stepper sx={{ width: '100%' }}>
<Step
orientation="vertical"
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step
orientation="vertical"
indicator={<StepIndicator variant="outlined">2</StepIndicator>}
>
In review
</Step>
<Step orientation="vertical" indicator={<StepIndicator>3</StepIndicator>}>
Approved
</Step>
</Stepper>
);
}
| 1,561 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/IndicatorTopStepper.tsx | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import StepIndicator from '@mui/joy/StepIndicator';
export default function IndicatorTopStepper() {
return (
<Stepper sx={{ width: '100%' }}>
<Step
orientation="vertical"
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step
orientation="vertical"
indicator={<StepIndicator variant="outlined">2</StepIndicator>}
>
In review
</Step>
<Step orientation="vertical" indicator={<StepIndicator>3</StepIndicator>}>
Approved
</Step>
</Stepper>
);
}
| 1,562 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/SizesStepper.js | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import StepIndicator from '@mui/joy/StepIndicator';
import Stack from '@mui/joy/Stack';
export default function SizesStepper() {
return (
<Stack spacing={2} sx={{ width: '100%' }}>
<Stepper size="sm">
<Step
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step indicator={<StepIndicator>2</StepIndicator>}>In review</Step>
<Step indicator={<StepIndicator>3</StepIndicator>}>Approved</Step>
</Stepper>
<Stepper sx={{ width: '100%' }}>
<Step
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step indicator={<StepIndicator>2</StepIndicator>}>In review</Step>
<Step indicator={<StepIndicator>3</StepIndicator>}>Approved</Step>
</Stepper>
<Stepper size="lg" sx={{ width: '100%' }}>
<Step
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step indicator={<StepIndicator>2</StepIndicator>}>In review</Step>
<Step indicator={<StepIndicator>3</StepIndicator>}>Approved</Step>
</Stepper>
</Stack>
);
}
| 1,563 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/SizesStepper.tsx | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import StepIndicator from '@mui/joy/StepIndicator';
import Stack from '@mui/joy/Stack';
export default function SizesStepper() {
return (
<Stack spacing={2} sx={{ width: '100%' }}>
<Stepper size="sm">
<Step
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step indicator={<StepIndicator>2</StepIndicator>}>In review</Step>
<Step indicator={<StepIndicator>3</StepIndicator>}>Approved</Step>
</Stepper>
<Stepper sx={{ width: '100%' }}>
<Step
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step indicator={<StepIndicator>2</StepIndicator>}>In review</Step>
<Step indicator={<StepIndicator>3</StepIndicator>}>Approved</Step>
</Stepper>
<Stepper size="lg" sx={{ width: '100%' }}>
<Step
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step indicator={<StepIndicator>2</StepIndicator>}>In review</Step>
<Step indicator={<StepIndicator>3</StepIndicator>}>Approved</Step>
</Stepper>
</Stack>
);
}
| 1,564 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/StepperUsage.js | import * as React from 'react';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import StepIndicator from '@mui/joy/StepIndicator';
import Typography from '@mui/joy/Typography';
import JoyUsageDemo from 'docs/src/modules/components/JoyUsageDemo';
import Check from '@mui/icons-material/Check';
export default function StepperUsage() {
return (
<JoyUsageDemo
componentName="Stepper"
data={[
{
propName: 'stepperOrientation',
knob: 'radio',
defaultValue: 'horizontal',
options: ['horizontal', 'vertical'],
},
{
propName: 'stepOrientation',
knob: 'radio',
defaultValue: 'horizontal',
options: ['horizontal', 'vertical'],
},
{
propName: 'size',
knob: 'radio',
options: ['sm', 'md', 'lg'],
defaultValue: 'md',
},
{
propName: 'indicator',
knob: 'switch',
defaultValue: true,
},
]}
getCodeBlock={(code, props) => `<Stepper${
props.orientation === 'vertical' ? ' orientation="vertical"' : ''
}>
<Step${props.stepOrientation === 'vertical' ? ` orientation="vertical"` : ''}${
props.indicator
? `
indicator={
<StepIndicator variant="solid" color="primary">
<Check />
</StepIndicator>
}\n `
: ''
}>First</Step>
...
</Stepper>`}
renderDemo={({ stepperOrientation, stepOrientation, size, indicator }) => (
<Stepper
orientation={stepperOrientation}
size={size}
sx={{ width: 320, mb: 3, py: 3 }}
>
<Step
orientation={stepOrientation}
indicator={
indicator && (
<StepIndicator variant="solid" color="primary">
<Check />
</StepIndicator>
)
}
>
<Typography sx={{ bgcolor: 'background.body' }}>First</Typography>
</Step>
<Step
orientation={stepOrientation}
indicator={indicator && <StepIndicator color="primary">2</StepIndicator>}
>
<Typography sx={{ bgcolor: 'background.body' }}>Second</Typography>
</Step>
</Stepper>
)}
/>
);
}
| 1,565 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/StepperVariables.js | import * as React from 'react';
import Box from '@mui/joy/Box';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import StepIndicator from '@mui/joy/StepIndicator';
import JoyVariablesDemo from 'docs/src/modules/components/JoyVariablesDemo';
export default function StepperVariables() {
return (
<JoyVariablesDemo
componentName="Stepper"
renderCode={(formattedSx) =>
`<Stepper${formattedSx ? `${formattedSx}>` : '>'}`
}
data={[
{
var: '--Step-connectorThickness',
defaultValue: '2px',
},
{
var: '--Step-connectorInset',
defaultValue: '6px',
},
{
var: '--Step-connectorRadius',
},
{
var: '--Step-gap',
defaultValue: '6px',
},
{
var: '--StepIndicator-size',
defaultValue: '32px',
},
[
'Vertical Stepper',
[
{
var: '--Stepper-verticalGap',
defaultValue: '12px',
},
{
var: '--Step-indicatorDotSize',
defaultValue: '6px',
},
],
],
]}
renderDemo={(sx) => (
<Box
sx={{
display: 'grid',
gridTemplateColumns: '1fr 1fr',
gap: 4,
rowGap: 8,
width: 320,
}}
>
<Stepper sx={{ gridColumn: '1/-1', ...sx }}>
<Step
orientation="vertical"
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step
orientation="vertical"
indicator={<StepIndicator>2</StepIndicator>}
>
Order shipped
</Step>
</Stepper>
<Stepper orientation="vertical" sx={sx}>
<Step>Order placed</Step>
<Step>In review</Step>
<Step>Approved</Step>
</Stepper>
<Stepper orientation="vertical" sx={sx}>
<Step
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step indicator={<StepIndicator>2</StepIndicator>}>In review</Step>
<Step indicator={<StepIndicator>3</StepIndicator>}>Approved</Step>
</Stepper>
</Box>
)}
/>
);
}
| 1,566 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/VerticalExtraContentStepper.js | import * as React from 'react';
import ButtonGroup from '@mui/joy/ButtonGroup';
import Chip from '@mui/joy/Chip';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import StepIndicator from '@mui/joy/StepIndicator';
import Typography from '@mui/joy/Typography';
import Stack from '@mui/joy/Stack';
export default function VerticalExtraContentStepper() {
return (
<Stepper orientation="vertical">
<Step
indicator={
<StepIndicator variant="solid" color="primary">
1
</StepIndicator>
}
>
<Typography>Billing Address</Typography>
<Stack spacing={1}>
<Typography level="body-sm">
Ron Swanson <br />
14 Lakeshore Drive <br />
Pawnee, IN 12345 <br />
United States <br />
T: 555-555-5555
</Typography>
<ButtonGroup variant="plain" spacing={1}>
<Chip
color="primary"
variant="solid"
onClick={() => {
// do something...
}}
>
Next
</Chip>
<Chip
color="neutral"
variant="outlined"
onClick={() => {
// do something...
}}
>
Edit
</Chip>
</ButtonGroup>
</Stack>
</Step>
<Step indicator={<StepIndicator>2</StepIndicator>}>
<div>
<Typography level="title-sm">Shipping Address</Typography>
<Typography level="body-xs">Pending</Typography>
</div>
</Step>
<Step indicator={<StepIndicator>3</StepIndicator>}>
<div>
<Typography level="title-sm">Shipping Method</Typography>
<Typography level="body-xs">Pending</Typography>
</div>
</Step>
</Stepper>
);
}
| 1,567 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/VerticalExtraContentStepper.tsx | import * as React from 'react';
import ButtonGroup from '@mui/joy/ButtonGroup';
import Chip from '@mui/joy/Chip';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import StepIndicator from '@mui/joy/StepIndicator';
import Typography from '@mui/joy/Typography';
import Stack from '@mui/joy/Stack';
export default function VerticalExtraContentStepper() {
return (
<Stepper orientation="vertical">
<Step
indicator={
<StepIndicator variant="solid" color="primary">
1
</StepIndicator>
}
>
<Typography>Billing Address</Typography>
<Stack spacing={1}>
<Typography level="body-sm">
Ron Swanson <br />
14 Lakeshore Drive <br />
Pawnee, IN 12345 <br />
United States <br />
T: 555-555-5555
</Typography>
<ButtonGroup variant="plain" spacing={1}>
<Chip
color="primary"
variant="solid"
onClick={() => {
// do something...
}}
>
Next
</Chip>
<Chip
color="neutral"
variant="outlined"
onClick={() => {
// do something...
}}
>
Edit
</Chip>
</ButtonGroup>
</Stack>
</Step>
<Step indicator={<StepIndicator>2</StepIndicator>}>
<div>
<Typography level="title-sm">Shipping Address</Typography>
<Typography level="body-xs">Pending</Typography>
</div>
</Step>
<Step indicator={<StepIndicator>3</StepIndicator>}>
<div>
<Typography level="title-sm">Shipping Method</Typography>
<Typography level="body-xs">Pending</Typography>
</div>
</Step>
</Stepper>
);
}
| 1,568 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/VerticalStepper.js | import * as React from 'react';
import Box from '@mui/joy/Box';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import StepIndicator from '@mui/joy/StepIndicator';
export default function VerticalStepper() {
return (
<Box
sx={{
display: 'grid',
gridTemplateColumns: '1fr 1fr',
gap: 2,
}}
>
<Stepper orientation="vertical" sx={{ width: 200 }}>
<Step
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step indicator={<StepIndicator>2</StepIndicator>}>In review</Step>
<Step indicator={<StepIndicator>3</StepIndicator>}>Approved</Step>
</Stepper>
<Stepper orientation="vertical" sx={{ width: 200 }}>
<Step>Order placed</Step>
<Step>In review</Step>
<Step>Approved</Step>
</Stepper>
</Box>
);
}
| 1,569 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/VerticalStepper.tsx | import * as React from 'react';
import Box from '@mui/joy/Box';
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
import StepIndicator from '@mui/joy/StepIndicator';
export default function VerticalStepper() {
return (
<Box
sx={{
display: 'grid',
gridTemplateColumns: '1fr 1fr',
gap: 2,
}}
>
<Stepper orientation="vertical" sx={{ width: 200 }}>
<Step
indicator={
<StepIndicator variant="solid" color="neutral">
1
</StepIndicator>
}
>
Order placed
</Step>
<Step indicator={<StepIndicator>2</StepIndicator>}>In review</Step>
<Step indicator={<StepIndicator>3</StepIndicator>}>Approved</Step>
</Stepper>
<Stepper orientation="vertical" sx={{ width: 200 }}>
<Step>Order placed</Step>
<Step>In review</Step>
<Step>Approved</Step>
</Stepper>
</Box>
);
}
| 1,570 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/stepper/stepper.md | ---
productId: joy-ui
title: React Stepper component
components: Stepper, Step, StepButton, StepIndicator
githubLabel: 'component: stepper'
materialDesign: https://m1.material.io/components/steppers.html
---
# Stepper
<p class="description">Steppers convey progress through numbered steps. It provides a wizard-like workflow.</p>
## Introduction
Stepper displays progress through a sequence of logical and numbered steps. It support horizontal and vertical orientation for desktop and mobile viewports.
Joy UI Steppers are implemented using a collection of related components:
- [Stepper](#basics) - a required container for steps. Renders as a `<ol>` by default.
- [Step](#basics) - a step. Renders as a `<li>` by default.
- [StepIndicator](#indicator) - an optional indicator of a step.
{{"demo": "StepperUsage.js", "hideToolbar": true, "bg": "gradient"}}
## Basics
```jsx
import Stepper from '@mui/joy/Stepper';
import Step from '@mui/joy/Step';
```
{{"demo": "BasicStepper.js"}}
## Customization
### Indicator
Pass StepIndicator as an element to Step's `indicator` prop to create number or icon indicators.
The StepIndicator supports Joy UI's four [global variants](/joy-ui/main-features/global-variants/): `soft` (default), `solid`, `outlined`, and `plain`.
{{"demo": "IndicatorStepper.js"}}
:::info
To learn how to add your own variants, check out [Themed components—Extend variants](/joy-ui/customization/themed-components/#extend-variants).
Note that you lose the global variants when you add custom variants.
:::
#### Indicator at the top
Set Step's `orientation="vertical"` to show an indicator at the top.
{{"demo": "IndicatorTopStepper.js"}}
### Button
To make the Step clickable, renders the `StepButton` component as a direct child of the Step.
{{"demo": "ButtonStepper.js"}}
### Sizes
The Stepper component comes in three sizes: `sm`, `md` (default), and `lg`.
{{"demo": "SizesStepper.js"}}
:::info
To learn how to add custom sizes to the component, check out [Themed components—Extend sizes](/joy-ui/customization/themed-components/#extend-sizes).
:::
### Vertical
Use `orientation="vertical"` to display the Stepper vertically. If you don't provide an indicator prop to the Step, a dot (pseudo element) will be used as the indicator.
{{"demo": "VerticalStepper.js"}}
#### Extra content
For vertical Steppers, you can pass more content to the Step by grouping it inside an HTML element.
The Step switches its display to CSS `grid` when the Stepper's orientation is vertical.
{{"demo": "VerticalExtraContentStepper.js"}}
### Connector
The connector is a pseudo element of the Step. To customize it, target `::after` element of the Step using `sx` prop.
{{"demo": "ConnectorStepper.js"}}
## CSS Variables
{{"demo": "StepperVariables.js"}}
## Common examples
### Company registration
{{"demo": "CompanyRegistrationStepper.js"}}
### Dotted connector
{{"demo": "DottedConnector.js"}}
### Icon stepper
{{"demo": "IconStepper.js"}}
| 1,571 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleChakraSwitch.js | import * as React from 'react';
import Switch, { switchClasses } from '@mui/joy/Switch';
export default function ExampleChakraSwitch() {
const [checked, setChecked] = React.useState(false);
return (
<Switch
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
sx={(theme) => ({
'--Switch-thumbSize': '16px',
'--Switch-trackWidth': '34px',
'--Switch-trackHeight': '20px',
'--Switch-trackBackground': '#CBD5E0',
'&:hover': {
'--Switch-trackBackground': '#CBD5E0',
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#3182ce',
'&:hover': {
'--Switch-trackBackground': '#3182ce',
},
[`&.${switchClasses.disabled}`]: {
'--Switch-trackBackground': '#3182ce',
},
},
[`&.${switchClasses.disabled}`]: {
'--Switch-trackBackground': '#CBD5E0',
opacity: 0.4,
},
[theme.getColorSchemeSelector('dark')]: {
'--Switch-trackBackground': 'rgba(255, 255, 255, 0.24)',
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#90cdf4',
'&:hover': {
'--Switch-trackBackground': '#90cdf4',
},
[`&.${switchClasses.disabled}`]: {
'--Switch-trackBackground': '#3182ce',
},
},
},
})}
/>
);
}
| 1,572 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleChakraSwitch.tsx | import * as React from 'react';
import Switch, { switchClasses } from '@mui/joy/Switch';
import { Theme } from '@mui/joy';
export default function ExampleChakraSwitch() {
const [checked, setChecked] = React.useState<boolean>(false);
return (
<Switch
checked={checked}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setChecked(event.target.checked)
}
sx={(theme: Theme) => ({
'--Switch-thumbSize': '16px',
'--Switch-trackWidth': '34px',
'--Switch-trackHeight': '20px',
'--Switch-trackBackground': '#CBD5E0',
'&:hover': {
'--Switch-trackBackground': '#CBD5E0',
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#3182ce',
'&:hover': {
'--Switch-trackBackground': '#3182ce',
},
[`&.${switchClasses.disabled}`]: {
'--Switch-trackBackground': '#3182ce',
},
},
[`&.${switchClasses.disabled}`]: {
'--Switch-trackBackground': '#CBD5E0',
opacity: 0.4,
},
[theme.getColorSchemeSelector('dark')]: {
'--Switch-trackBackground': 'rgba(255, 255, 255, 0.24)',
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#90cdf4',
'&:hover': {
'--Switch-trackBackground': '#90cdf4',
},
[`&.${switchClasses.disabled}`]: {
'--Switch-trackBackground': '#3182ce',
},
},
},
})}
/>
);
}
| 1,573 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleFluentSwitch.js | import * as React from 'react';
import Switch, { switchClasses } from '@mui/joy/Switch';
export default function ExampleFluentSwitch() {
const [checked, setChecked] = React.useState(false);
return (
<Switch
variant={checked ? 'solid' : 'outlined'}
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
sx={(theme) => ({
display: 'inherit',
'--Switch-trackWidth': '40px',
'--Switch-trackHeight': '20px',
'--Switch-thumbSize': '12px',
'--Switch-thumbBackground': 'rgb(96, 94, 92)',
'--Switch-trackBorderColor': 'rgb(96, 94, 92)',
'--Switch-trackBackground': theme.vars.palette.background.body,
'&:hover': {
'--Switch-trackBorderColor': 'rgb(50, 49, 48)',
'--Switch-trackBackground': theme.vars.palette.background.body,
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#0078D4',
'&:hover': {
'--Switch-trackBackground': '#106EBE',
},
},
[`&.${switchClasses.disabled}`]: {
'--Switch-thumbColor': '#C8C6C4',
'--Switch-trackBorderColor': '#C8C6C4',
},
[`&.${switchClasses.disabled}.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#C8C6C4',
'--Switch-thumbColor': '#F3F2F1',
},
[theme.getColorSchemeSelector('dark')]: {
'--Switch-trackBorderColor': 'rgb(161, 159, 157)',
'--Switch-trackBackground': 'rgb(27, 26, 25)',
'--Switch-thumbBackground': 'rgb(161, 159, 157)',
'&:hover': {
'--Switch-trackBorderColor': '#fff',
'--Switch-thumbBackground': '#fff',
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': 'rgb(40, 153, 245)',
'--Switch-thumbBackground': 'rgb(27, 26, 25)',
'&:hover': {
'--Switch-trackBackground': 'rgb(108, 184, 246)',
},
},
},
})}
/>
);
}
| 1,574 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleFluentSwitch.tsx | import * as React from 'react';
import Switch, { switchClasses } from '@mui/joy/Switch';
import { Theme } from '@mui/joy';
export default function ExampleFluentSwitch() {
const [checked, setChecked] = React.useState<boolean>(false);
return (
<Switch
variant={checked ? 'solid' : 'outlined'}
checked={checked}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setChecked(event.target.checked)
}
sx={(theme: Theme) => ({
display: 'inherit',
'--Switch-trackWidth': '40px',
'--Switch-trackHeight': '20px',
'--Switch-thumbSize': '12px',
'--Switch-thumbBackground': 'rgb(96, 94, 92)',
'--Switch-trackBorderColor': 'rgb(96, 94, 92)',
'--Switch-trackBackground': theme.vars.palette.background.body,
'&:hover': {
'--Switch-trackBorderColor': 'rgb(50, 49, 48)',
'--Switch-trackBackground': theme.vars.palette.background.body,
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#0078D4',
'&:hover': {
'--Switch-trackBackground': '#106EBE',
},
},
[`&.${switchClasses.disabled}`]: {
'--Switch-thumbColor': '#C8C6C4',
'--Switch-trackBorderColor': '#C8C6C4',
},
[`&.${switchClasses.disabled}.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#C8C6C4',
'--Switch-thumbColor': '#F3F2F1',
},
[theme.getColorSchemeSelector('dark')]: {
'--Switch-trackBorderColor': 'rgb(161, 159, 157)',
'--Switch-trackBackground': 'rgb(27, 26, 25)',
'--Switch-thumbBackground': 'rgb(161, 159, 157)',
'&:hover': {
'--Switch-trackBorderColor': '#fff',
'--Switch-thumbBackground': '#fff',
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': 'rgb(40, 153, 245)',
'--Switch-thumbBackground': 'rgb(27, 26, 25)',
'&:hover': {
'--Switch-trackBackground': 'rgb(108, 184, 246)',
},
},
},
})}
/>
);
}
| 1,575 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleIosSwitch.js | import * as React from 'react';
import Switch, { switchClasses } from '@mui/joy/Switch';
export default function ExampleIosSwitch() {
const [checked, setChecked] = React.useState(false);
return (
<Switch
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
sx={(theme) => ({
'--Switch-thumbShadow': '0 3px 7px 0 rgba(0 0 0 / 0.12)',
'--Switch-thumbSize': '27px',
'--Switch-trackWidth': '51px',
'--Switch-trackHeight': '31px',
'--Switch-trackBackground': theme.vars.palette.background.level3,
[`& .${switchClasses.thumb}`]: {
transition: 'width 0.2s, left 0.2s',
},
'&:hover': {
'--Switch-trackBackground': theme.vars.palette.background.level3,
},
'&:active': {
'--Switch-thumbWidth': '32px',
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': 'rgb(48 209 88)',
'&:hover': {
'--Switch-trackBackground': 'rgb(48 209 88)',
},
},
})}
/>
);
}
| 1,576 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleIosSwitch.tsx | import * as React from 'react';
import Switch, { switchClasses } from '@mui/joy/Switch';
import { Theme } from '@mui/joy';
export default function ExampleIosSwitch() {
const [checked, setChecked] = React.useState<boolean>(false);
return (
<Switch
checked={checked}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setChecked(event.target.checked)
}
sx={(theme: Theme) => ({
'--Switch-thumbShadow': '0 3px 7px 0 rgba(0 0 0 / 0.12)',
'--Switch-thumbSize': '27px',
'--Switch-trackWidth': '51px',
'--Switch-trackHeight': '31px',
'--Switch-trackBackground': theme.vars.palette.background.level3,
[`& .${switchClasses.thumb}`]: {
transition: 'width 0.2s, left 0.2s',
},
'&:hover': {
'--Switch-trackBackground': theme.vars.palette.background.level3,
},
'&:active': {
'--Switch-thumbWidth': '32px',
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': 'rgb(48 209 88)',
'&:hover': {
'--Switch-trackBackground': 'rgb(48 209 88)',
},
},
})}
/>
);
}
| 1,577 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleMantineSwitch.js | import * as React from 'react';
import Switch, { switchClasses } from '@mui/joy/Switch';
export default function ExampleMantineSwitch() {
const [checked, setChecked] = React.useState(false);
return (
<Switch
variant={checked ? 'solid' : 'outlined'}
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
sx={(theme) => ({
display: 'inherit',
'--Switch-thumbSize': '14px',
'--Switch-thumbShadow': 'inset 0 0 0 1px #dee2e6',
'--Switch-trackWidth': '38px',
'--Switch-trackHeight': '20px',
'--Switch-trackBorderColor': '#dee2e6',
'--Switch-trackBackground': '#e9ecef',
'--Switch-thumbBackground': '#fff',
'&:hover': {
'--Switch-thumbBackground': '#fff',
'--Switch-trackBackground': '#e9ecef',
},
[`&.${switchClasses.checked}`]: {
'--Switch-thumbShadow': 'none',
'--Switch-trackBackground': '#228be6',
'&:hover': {
'--Switch-trackBackground': '#228be6',
},
},
[`&.${switchClasses.disabled}`]: {
'--Switch-thumbColor': '#f8f9fa',
'--Switch-trackBackground': '#e9ecef',
},
[theme.getColorSchemeSelector('dark')]: {
'--Switch-trackBorderColor': 'rgb(55, 58, 64)',
'--Switch-trackBackground': 'rgb(55, 58, 64)',
'--Switch-thumbShadow': 'none',
},
})}
/>
);
}
| 1,578 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleMantineSwitch.tsx | import * as React from 'react';
import Switch, { switchClasses } from '@mui/joy/Switch';
import { Theme } from '@mui/joy';
export default function ExampleMantineSwitch() {
const [checked, setChecked] = React.useState<boolean>(false);
return (
<Switch
variant={checked ? 'solid' : 'outlined'}
checked={checked}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setChecked(event.target.checked)
}
sx={(theme: Theme) => ({
display: 'inherit',
'--Switch-thumbSize': '14px',
'--Switch-thumbShadow': 'inset 0 0 0 1px #dee2e6',
'--Switch-trackWidth': '38px',
'--Switch-trackHeight': '20px',
'--Switch-trackBorderColor': '#dee2e6',
'--Switch-trackBackground': '#e9ecef',
'--Switch-thumbBackground': '#fff',
'&:hover': {
'--Switch-thumbBackground': '#fff',
'--Switch-trackBackground': '#e9ecef',
},
[`&.${switchClasses.checked}`]: {
'--Switch-thumbShadow': 'none',
'--Switch-trackBackground': '#228be6',
'&:hover': {
'--Switch-trackBackground': '#228be6',
},
},
[`&.${switchClasses.disabled}`]: {
'--Switch-thumbColor': '#f8f9fa',
'--Switch-trackBackground': '#e9ecef',
},
[theme.getColorSchemeSelector('dark')]: {
'--Switch-trackBorderColor': 'rgb(55, 58, 64)',
'--Switch-trackBackground': 'rgb(55, 58, 64)',
'--Switch-thumbShadow': 'none',
},
})}
/>
);
}
| 1,579 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleStrapiSwitch.js | import * as React from 'react';
import Switch, { switchClasses } from '@mui/joy/Switch';
export default function ExampleStrapiSwitch() {
const [checked, setChecked] = React.useState(false);
return (
<Switch
color={checked ? 'success' : 'danger'}
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
sx={{
'--Switch-thumbSize': '16px',
'--Switch-trackWidth': '40px',
'--Switch-trackHeight': '24px',
'--Switch-trackBackground': '#EE5E52',
'&:hover': {
'--Switch-trackBackground': '#EE5E52',
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#5CB176',
'&:hover': {
'--Switch-trackBackground': '#5CB176',
},
},
}}
/>
);
}
| 1,580 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleStrapiSwitch.tsx | import * as React from 'react';
import Switch, { switchClasses } from '@mui/joy/Switch';
export default function ExampleStrapiSwitch() {
const [checked, setChecked] = React.useState<boolean>(false);
return (
<Switch
color={checked ? 'success' : 'danger'}
checked={checked}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setChecked(event.target.checked)
}
sx={{
'--Switch-thumbSize': '16px',
'--Switch-trackWidth': '40px',
'--Switch-trackHeight': '24px',
'--Switch-trackBackground': '#EE5E52',
'&:hover': {
'--Switch-trackBackground': '#EE5E52',
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#5CB176',
'&:hover': {
'--Switch-trackBackground': '#5CB176',
},
},
}}
/>
);
}
| 1,581 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleTailwindSwitch.js | import * as React from 'react';
import Box from '@mui/joy/Box';
import Switch, { switchClasses } from '@mui/joy/Switch';
export default function ExampleTailwindSwitch() {
const [checked, setChecked] = React.useState(false);
return (
<Box sx={{ display: 'flex', gap: 2 }}>
<Switch
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
sx={(theme) => ({
display: 'inherit',
'--Switch-thumbShadow': theme.vars.shadow.sm,
'--Switch-thumbSize': '18px',
'--Switch-trackWidth': '42px',
'--Switch-trackHeight': '22px',
'--Switch-trackBackground': '#E9E9EA',
'&:hover': {
'--Switch-trackBackground': '#E9E9EA',
},
[theme.getColorSchemeSelector('dark')]: {
'--Switch-trackBackground': 'rgba(255 255 255 / 0.4)',
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#65C466',
'&:hover': {
'--Switch-trackBackground': '#65C466',
},
},
})}
/>
<Switch
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
sx={(theme) => ({
display: 'inherit',
'--Switch-thumbShadow': `0 0 0 1px ${theme.vars.palette.background.level3}, 0 1px 4px 0 rgb(0 0 0 / 0.3), 0 1px 2px 0px rgb(0 0 0 / 0.3)`,
'--Switch-thumbSize': '18px',
'--Switch-trackWidth': '36px',
'--Switch-trackHeight': '14px',
'--Switch-trackBackground': '#E9E9EA',
'&:hover': {
'--Switch-trackBackground': '#E9E9EA',
},
[theme.getColorSchemeSelector('dark')]: {
'--Switch-trackBackground': 'rgba(255 255 255 / 0.4)',
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#65C466',
'&:hover': {
'--Switch-trackBackground': '#65C466',
},
},
})}
/>
</Box>
);
}
| 1,582 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleTailwindSwitch.tsx | import * as React from 'react';
import Box from '@mui/joy/Box';
import Switch, { switchClasses } from '@mui/joy/Switch';
import { Theme } from '@mui/joy';
export default function ExampleTailwindSwitch() {
const [checked, setChecked] = React.useState<boolean>(false);
return (
<Box sx={{ display: 'flex', gap: 2 }}>
<Switch
checked={checked}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setChecked(event.target.checked)
}
sx={(theme: Theme) => ({
display: 'inherit',
'--Switch-thumbShadow': theme.vars.shadow.sm,
'--Switch-thumbSize': '18px',
'--Switch-trackWidth': '42px',
'--Switch-trackHeight': '22px',
'--Switch-trackBackground': '#E9E9EA',
'&:hover': {
'--Switch-trackBackground': '#E9E9EA',
},
[theme.getColorSchemeSelector('dark')]: {
'--Switch-trackBackground': 'rgba(255 255 255 / 0.4)',
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#65C466',
'&:hover': {
'--Switch-trackBackground': '#65C466',
},
},
})}
/>
<Switch
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
sx={(theme) => ({
display: 'inherit',
'--Switch-thumbShadow': `0 0 0 1px ${theme.vars.palette.background.level3}, 0 1px 4px 0 rgb(0 0 0 / 0.3), 0 1px 2px 0px rgb(0 0 0 / 0.3)`,
'--Switch-thumbSize': '18px',
'--Switch-trackWidth': '36px',
'--Switch-trackHeight': '14px',
'--Switch-trackBackground': '#E9E9EA',
'&:hover': {
'--Switch-trackBackground': '#E9E9EA',
},
[theme.getColorSchemeSelector('dark')]: {
'--Switch-trackBackground': 'rgba(255 255 255 / 0.4)',
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#65C466',
'&:hover': {
'--Switch-trackBackground': '#65C466',
},
},
})}
/>
</Box>
);
}
| 1,583 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleThumbChild.js | import * as React from 'react';
import Switch from '@mui/joy/Switch';
import DarkMode from '@mui/icons-material/DarkMode';
export default function ExampleThumbChild() {
return (
<Switch
size="lg"
slotProps={{
input: { 'aria-label': 'Dark mode' },
thumb: {
children: <DarkMode />,
},
}}
sx={{
'--Switch-thumbSize': '16px',
}}
/>
);
}
| 1,584 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleThumbChild.tsx | import * as React from 'react';
import Switch from '@mui/joy/Switch';
import DarkMode from '@mui/icons-material/DarkMode';
export default function ExampleThumbChild() {
return (
<Switch
size="lg"
slotProps={{
input: { 'aria-label': 'Dark mode' },
thumb: {
children: <DarkMode />,
},
}}
sx={{
'--Switch-thumbSize': '16px',
}}
/>
);
}
| 1,585 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleThumbChild.tsx.preview | <Switch
size="lg"
slotProps={{
input: { 'aria-label': 'Dark mode' },
thumb: {
children: <DarkMode />,
},
}}
sx={{
'--Switch-thumbSize': '16px',
}}
/> | 1,586 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleTrackChild.js | import * as React from 'react';
import Switch from '@mui/joy/Switch';
import Stack from '@mui/joy/Stack';
import Typography from '@mui/joy/Typography';
export default function ExampleTrackChild() {
return (
<Stack direction="row" spacing={2}>
<Switch
slotProps={{
track: {
children: (
<React.Fragment>
<Typography component="span" level="inherit" sx={{ ml: '10px' }}>
On
</Typography>
<Typography component="span" level="inherit" sx={{ mr: '8px' }}>
Off
</Typography>
</React.Fragment>
),
},
}}
sx={{
'--Switch-thumbSize': '27px',
'--Switch-trackWidth': '64px',
'--Switch-trackHeight': '31px',
}}
/>
<Switch
color="success"
slotProps={{
track: {
children: (
<React.Fragment>
<span>I</span>
<span>0</span>
</React.Fragment>
),
sx: {
justifyContent: 'space-around',
},
},
}}
sx={{
'--Switch-thumbSize': '27px',
'--Switch-trackWidth': '52px',
'--Switch-trackHeight': '31px',
}}
/>
</Stack>
);
}
| 1,587 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/ExampleTrackChild.tsx | import * as React from 'react';
import Switch from '@mui/joy/Switch';
import Stack from '@mui/joy/Stack';
import Typography from '@mui/joy/Typography';
export default function ExampleTrackChild() {
return (
<Stack direction="row" spacing={2}>
<Switch
slotProps={{
track: {
children: (
<React.Fragment>
<Typography component="span" level="inherit" sx={{ ml: '10px' }}>
On
</Typography>
<Typography component="span" level="inherit" sx={{ mr: '8px' }}>
Off
</Typography>
</React.Fragment>
),
},
}}
sx={{
'--Switch-thumbSize': '27px',
'--Switch-trackWidth': '64px',
'--Switch-trackHeight': '31px',
}}
/>
<Switch
color="success"
slotProps={{
track: {
children: (
<React.Fragment>
<span>I</span>
<span>0</span>
</React.Fragment>
),
sx: {
justifyContent: 'space-around',
},
},
}}
sx={{
'--Switch-thumbSize': '27px',
'--Switch-trackWidth': '52px',
'--Switch-trackHeight': '31px',
}}
/>
</Stack>
);
}
| 1,588 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/SwitchControl.js | import * as React from 'react';
import FormControl from '@mui/joy/FormControl';
import FormLabel from '@mui/joy/FormLabel';
import FormHelperText from '@mui/joy/FormHelperText';
import Switch from '@mui/joy/Switch';
export default function SwitchControl() {
const [checked, setChecked] = React.useState(false);
return (
<FormControl
orientation="horizontal"
sx={{ width: 300, justifyContent: 'space-between' }}
>
<div>
<FormLabel>Show captions</FormLabel>
<FormHelperText sx={{ mt: 0 }}>All languages available.</FormHelperText>
</div>
<Switch
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
color={checked ? 'success' : 'neutral'}
variant={checked ? 'solid' : 'outlined'}
endDecorator={checked ? 'On' : 'Off'}
slotProps={{
endDecorator: {
sx: {
minWidth: 24,
},
},
}}
/>
</FormControl>
);
}
| 1,589 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/SwitchControl.tsx | import * as React from 'react';
import FormControl from '@mui/joy/FormControl';
import FormLabel from '@mui/joy/FormLabel';
import FormHelperText from '@mui/joy/FormHelperText';
import Switch from '@mui/joy/Switch';
export default function SwitchControl() {
const [checked, setChecked] = React.useState<boolean>(false);
return (
<FormControl
orientation="horizontal"
sx={{ width: 300, justifyContent: 'space-between' }}
>
<div>
<FormLabel>Show captions</FormLabel>
<FormHelperText sx={{ mt: 0 }}>All languages available.</FormHelperText>
</div>
<Switch
checked={checked}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setChecked(event.target.checked)
}
color={checked ? 'success' : 'neutral'}
variant={checked ? 'solid' : 'outlined'}
endDecorator={checked ? 'On' : 'Off'}
slotProps={{
endDecorator: {
sx: {
minWidth: 24,
},
},
}}
/>
</FormControl>
);
}
| 1,590 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/SwitchControlled.js | import * as React from 'react';
import Switch from '@mui/joy/Switch';
export default function SwitchControlled() {
const [checked, setChecked] = React.useState(false);
return (
<Switch
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
/>
);
}
| 1,591 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/SwitchControlled.tsx | import * as React from 'react';
import Switch from '@mui/joy/Switch';
export default function SwitchControlled() {
const [checked, setChecked] = React.useState<boolean>(false);
return (
<Switch
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
/>
);
}
| 1,592 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/SwitchControlled.tsx.preview | <Switch
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
/> | 1,593 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/SwitchDecorators.js | import * as React from 'react';
import Switch from '@mui/joy/Switch';
import LocalFireDepartmentRoundedIcon from '@mui/icons-material/LocalFireDepartmentRounded';
import WavesRoundedIcon from '@mui/icons-material/WavesRounded';
export default function SwitchDecorators() {
const [dark, setDark] = React.useState(false);
return (
<Switch
color={dark ? 'primary' : 'danger'}
slotProps={{ input: { 'aria-label': 'dark mode' } }}
startDecorator={
<LocalFireDepartmentRoundedIcon
sx={{ color: dark ? 'text.tertiary' : 'danger.600' }}
/>
}
endDecorator={
<WavesRoundedIcon sx={{ color: dark ? 'primary.500' : 'text.tertiary' }} />
}
checked={dark}
onChange={(event) => setDark(event.target.checked)}
/>
);
}
| 1,594 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/SwitchDecorators.tsx | import * as React from 'react';
import Switch from '@mui/joy/Switch';
import LocalFireDepartmentRoundedIcon from '@mui/icons-material/LocalFireDepartmentRounded';
import WavesRoundedIcon from '@mui/icons-material/WavesRounded';
export default function SwitchDecorators() {
const [dark, setDark] = React.useState<boolean>(false);
return (
<Switch
color={dark ? 'primary' : 'danger'}
slotProps={{ input: { 'aria-label': 'dark mode' } }}
startDecorator={
<LocalFireDepartmentRoundedIcon
sx={{ color: dark ? 'text.tertiary' : 'danger.600' }}
/>
}
endDecorator={
<WavesRoundedIcon sx={{ color: dark ? 'primary.500' : 'text.tertiary' }} />
}
checked={dark}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setDark(event.target.checked)
}
/>
);
}
| 1,595 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/SwitchDecorators.tsx.preview | <Switch
color={dark ? 'primary' : 'danger'}
slotProps={{ input: { 'aria-label': 'dark mode' } }}
startDecorator={
<LocalFireDepartmentRoundedIcon
sx={{ color: dark ? 'text.tertiary' : 'danger.600' }}
/>
}
endDecorator={
<WavesRoundedIcon sx={{ color: dark ? 'primary.500' : 'text.tertiary' }} />
}
checked={dark}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setDark(event.target.checked)
}
/> | 1,596 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/SwitchLabel.js | import * as React from 'react';
import Switch from '@mui/joy/Switch';
import Typography from '@mui/joy/Typography';
export default function SwitchLabel() {
return (
<Typography component="label" endDecorator={<Switch sx={{ ml: 1 }} />}>
Turn alarm on
</Typography>
);
}
| 1,597 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/SwitchLabel.tsx | import * as React from 'react';
import Switch from '@mui/joy/Switch';
import Typography from '@mui/joy/Typography';
export default function SwitchLabel() {
return (
<Typography component="label" endDecorator={<Switch sx={{ ml: 1 }} />}>
Turn alarm on
</Typography>
);
}
| 1,598 |
0 | petrpan-code/mui/material-ui/docs/data/joy/components | petrpan-code/mui/material-ui/docs/data/joy/components/switch/SwitchLabel.tsx.preview | <Typography component="label" endDecorator={<Switch sx={{ ml: 1 }} />}>
Turn alarm on
</Typography> | 1,599 |
Subsets and Splits