diff --git a/docs/data/material/components/drawers/AnchorTemporaryDrawer.js b/docs/data/material/components/drawers/AnchorTemporaryDrawer.js
new file mode 100644
index 00000000000000..0c539ab6419e93
--- /dev/null
+++ b/docs/data/material/components/drawers/AnchorTemporaryDrawer.js
@@ -0,0 +1,81 @@
+import * as React from 'react';
+import Box from '@mui/material/Box';
+import Drawer from '@mui/material/Drawer';
+import Button from '@mui/material/Button';
+import List from '@mui/material/List';
+import Divider from '@mui/material/Divider';
+import ListItem from '@mui/material/ListItem';
+import ListItemButton from '@mui/material/ListItemButton';
+import ListItemIcon from '@mui/material/ListItemIcon';
+import ListItemText from '@mui/material/ListItemText';
+import InboxIcon from '@mui/icons-material/MoveToInbox';
+import MailIcon from '@mui/icons-material/Mail';
+
+export default function AnchorTemporaryDrawer() {
+ const [state, setState] = React.useState({
+ top: false,
+ left: false,
+ bottom: false,
+ right: false,
+ });
+
+ const toggleDrawer = (anchor, open) => (event) => {
+ if (event.type === 'keydown' && (event.key === 'Tab' || event.key === 'Shift')) {
+ return;
+ }
+
+ setState({ ...state, [anchor]: open });
+ };
+
+ const list = (anchor) => (
+
+
+ {['Inbox', 'Starred', 'Send email', 'Drafts'].map((text, index) => (
+
+
+
+ {index % 2 === 0 ? : }
+
+
+
+
+ ))}
+
+
+
+ {['All mail', 'Trash', 'Spam'].map((text, index) => (
+
+
+
+ {index % 2 === 0 ? : }
+
+
+
+
+ ))}
+
+
+ );
+
+ return (
+
+ {['left', 'right', 'top', 'bottom'].map((anchor) => (
+
+ {anchor}
+
+ {list(anchor)}
+
+
+ ))}
+
+ );
+}
diff --git a/docs/data/material/components/drawers/AnchorTemporaryDrawer.tsx b/docs/data/material/components/drawers/AnchorTemporaryDrawer.tsx
new file mode 100644
index 00000000000000..a6f333aa9edc4d
--- /dev/null
+++ b/docs/data/material/components/drawers/AnchorTemporaryDrawer.tsx
@@ -0,0 +1,89 @@
+import * as React from 'react';
+import Box from '@mui/material/Box';
+import Drawer from '@mui/material/Drawer';
+import Button from '@mui/material/Button';
+import List from '@mui/material/List';
+import Divider from '@mui/material/Divider';
+import ListItem from '@mui/material/ListItem';
+import ListItemButton from '@mui/material/ListItemButton';
+import ListItemIcon from '@mui/material/ListItemIcon';
+import ListItemText from '@mui/material/ListItemText';
+import InboxIcon from '@mui/icons-material/MoveToInbox';
+import MailIcon from '@mui/icons-material/Mail';
+
+type Anchor = 'top' | 'left' | 'bottom' | 'right';
+
+export default function AnchorTemporaryDrawer() {
+ const [state, setState] = React.useState({
+ top: false,
+ left: false,
+ bottom: false,
+ right: false,
+ });
+
+ const toggleDrawer =
+ (anchor: Anchor, open: boolean) =>
+ (event: React.KeyboardEvent | React.MouseEvent) => {
+ if (
+ event.type === 'keydown' &&
+ ((event as React.KeyboardEvent).key === 'Tab' ||
+ (event as React.KeyboardEvent).key === 'Shift')
+ ) {
+ return;
+ }
+
+ setState({ ...state, [anchor]: open });
+ };
+
+ const list = (anchor: Anchor) => (
+
+
+ {['Inbox', 'Starred', 'Send email', 'Drafts'].map((text, index) => (
+
+
+
+ {index % 2 === 0 ? : }
+
+
+
+
+ ))}
+
+
+
+ {['All mail', 'Trash', 'Spam'].map((text, index) => (
+
+
+
+ {index % 2 === 0 ? : }
+
+
+
+
+ ))}
+
+
+ );
+
+ return (
+
+ {(['left', 'right', 'top', 'bottom'] as const).map((anchor) => (
+
+ {anchor}
+
+ {list(anchor)}
+
+
+ ))}
+
+ );
+}
diff --git a/docs/data/material/components/drawers/AnchorTemporaryDrawer.tsx.preview b/docs/data/material/components/drawers/AnchorTemporaryDrawer.tsx.preview
new file mode 100644
index 00000000000000..245f5229aeddb8
--- /dev/null
+++ b/docs/data/material/components/drawers/AnchorTemporaryDrawer.tsx.preview
@@ -0,0 +1,12 @@
+{(['left', 'right', 'top', 'bottom'] as const).map((anchor) => (
+
+ {anchor}
+
+ {list(anchor)}
+
+
+))}
\ No newline at end of file
diff --git a/docs/data/material/components/drawers/TemporaryDrawer.js b/docs/data/material/components/drawers/TemporaryDrawer.js
index 7ae148fd43c534..55cc4b06d2d935 100644
--- a/docs/data/material/components/drawers/TemporaryDrawer.js
+++ b/docs/data/material/components/drawers/TemporaryDrawer.js
@@ -12,28 +12,14 @@ import InboxIcon from '@mui/icons-material/MoveToInbox';
import MailIcon from '@mui/icons-material/Mail';
export default function TemporaryDrawer() {
- const [state, setState] = React.useState({
- top: false,
- left: false,
- bottom: false,
- right: false,
- });
+ const [open, setOpen] = React.useState(false);
- const toggleDrawer = (anchor, open) => (event) => {
- if (event.type === 'keydown' && (event.key === 'Tab' || event.key === 'Shift')) {
- return;
- }
-
- setState({ ...state, [anchor]: open });
+ const toggleDrawer = (newOpen) => () => {
+ setOpen(newOpen);
};
- const list = (anchor) => (
-
+ const DrawerList = (
+
{['Inbox', 'Starred', 'Send email', 'Drafts'].map((text, index) => (
@@ -64,18 +50,10 @@ export default function TemporaryDrawer() {
return (
- {['left', 'right', 'top', 'bottom'].map((anchor) => (
-
- {anchor}
-
- {list(anchor)}
-
-
- ))}
+ Open drawer
+
+ {DrawerList}
+
);
}
diff --git a/docs/data/material/components/drawers/TemporaryDrawer.tsx b/docs/data/material/components/drawers/TemporaryDrawer.tsx
index 6453a0bd62dc50..65bf707c0a93e7 100644
--- a/docs/data/material/components/drawers/TemporaryDrawer.tsx
+++ b/docs/data/material/components/drawers/TemporaryDrawer.tsx
@@ -11,37 +11,15 @@ import ListItemText from '@mui/material/ListItemText';
import InboxIcon from '@mui/icons-material/MoveToInbox';
import MailIcon from '@mui/icons-material/Mail';
-type Anchor = 'top' | 'left' | 'bottom' | 'right';
-
export default function TemporaryDrawer() {
- const [state, setState] = React.useState({
- top: false,
- left: false,
- bottom: false,
- right: false,
- });
-
- const toggleDrawer =
- (anchor: Anchor, open: boolean) =>
- (event: React.KeyboardEvent | React.MouseEvent) => {
- if (
- event.type === 'keydown' &&
- ((event as React.KeyboardEvent).key === 'Tab' ||
- (event as React.KeyboardEvent).key === 'Shift')
- ) {
- return;
- }
+ const [open, setOpen] = React.useState(false);
- setState({ ...state, [anchor]: open });
- };
+ const toggleDrawer = (newOpen: boolean) => () => {
+ setOpen(newOpen);
+ };
- const list = (anchor: Anchor) => (
-
+ const DrawerList = (
+
{['Inbox', 'Starred', 'Send email', 'Drafts'].map((text, index) => (
@@ -72,18 +50,10 @@ export default function TemporaryDrawer() {
return (
- {(['left', 'right', 'top', 'bottom'] as const).map((anchor) => (
-
- {anchor}
-
- {list(anchor)}
-
-
- ))}
+ Open drawer
+
+ {DrawerList}
+
);
}
diff --git a/docs/data/material/components/drawers/TemporaryDrawer.tsx.preview b/docs/data/material/components/drawers/TemporaryDrawer.tsx.preview
index 245f5229aeddb8..9a79963627fa1d 100644
--- a/docs/data/material/components/drawers/TemporaryDrawer.tsx.preview
+++ b/docs/data/material/components/drawers/TemporaryDrawer.tsx.preview
@@ -1,12 +1,4 @@
-{(['left', 'right', 'top', 'bottom'] as const).map((anchor) => (
-
- {anchor}
-
- {list(anchor)}
-
-
-))}
\ No newline at end of file
+Open drawer
+
+ {DrawerList}
+
\ No newline at end of file
diff --git a/docs/data/material/components/drawers/drawers.md b/docs/data/material/components/drawers/drawers.md
index 8b386e0cb2516e..8bd8e8048dce8e 100644
--- a/docs/data/material/components/drawers/drawers.md
+++ b/docs/data/material/components/drawers/drawers.md
@@ -25,6 +25,14 @@ It closes when an item is selected, handled by controlling the `open` prop.
{{"demo": "TemporaryDrawer.js"}}
+### Anchor
+
+Use the `anchor` prop to specify which side of the screen the Drawer should originate from.
+
+The default value is `left`.
+
+{{"demo": "AnchorTemporaryDrawer.js"}}
+
### Swipeable
You can make the drawer swipeable with the `SwipeableDrawer` component.