### Install Joy UI with npm/yarn
Source: https://mui.com/joy-ui/getting-started/installation
Installs the Joy UI library along with necessary Emotion packages for styling. Ensure React and ReactDOM are installed as peer dependencies.
```bash
npm install @mui/joy @emotion/react @emotion/styled
```
--------------------------------
### Joy UI Peer Dependencies
Source: https://mui.com/joy-ui/getting-started/installation
Specifies the required React and ReactDOM versions that must be installed alongside Joy UI.
```json
{
"peerDependencies": {
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
}
}
```
--------------------------------
### Use Joy UI Button Component
Source: https://mui.com/joy-ui/getting-started/usage
Demonstrates how to import and use the Joy UI Button component with a 'solid' variant. This is a basic example to get started with Joy UI.
```javascript
import * as React from 'react';
import Button from '@mui/joy/Button';
export default function ButtonUsage() {
return ;
}
```
--------------------------------
### Install Inter Font with Fontsource
Source: https://mui.com/joy-ui/getting-started/installation
Adds the Inter font to your project using the Fontsource package manager.
```bash
npm install @fontsource/inter
```
--------------------------------
### Import Inter Font in Entry Point
Source: https://mui.com/joy-ui/getting-started/installation
Imports the Inter font from Fontsource into your application's main entry file.
```javascript
import '@fontsource/inter';
```
--------------------------------
### Add Inter Font via Google Fonts CDN
Source: https://mui.com/joy-ui/getting-started/installation
Includes the Inter font in your project by adding a link tag to the Google Fonts CDN in the `
My inbox
5 emails
` section of your HTML.
```html
```
--------------------------------
### GitHub Issue Title Convention for Joy UI
Source: https://mui.com/joy-ui/getting-started/support
This snippet demonstrates the recommended format for GitHub issue titles when reporting bugs or suggesting features for Joy UI components. It emphasizes clarity and component specificity.
```Markdown
❌ _"It doesn't work"_
✅ _"[button] Add support for {{new feature}}"_
```
--------------------------------
### Joy UI Email Template
Source: https://mui.com/joy-ui/getting-started/templates
The Email template for Joy UI, built by MUI. This template can be used as a starting point for email client interfaces or notification systems.
```React.js
SourceCodeSandbox
```
--------------------------------
### FormControl Accessibility Example (Joy UI)
Source: https://mui.com/joy-ui/getting-started/index
Illustrates the accessibility features of Joy UI's FormControl component. It automatically generates unique IDs to link the Input, FormLabel, and FormHelperText components, ensuring compliance with accessibility guidelines.
```jsx
LabelThis is a helper text.
```
--------------------------------
### Joy UI Order Dashboard Template
Source: https://mui.com/joy-ui/getting-started/templates
The Order Dashboard template for Joy UI, built by MUI and designed by Untitled UI. It offers a starting point for e-commerce or order management applications.
```React.js
SourceCodeSandbox
```
--------------------------------
### Import Joy UI Button and Link Components
Source: https://mui.com/joy-ui/getting-started/tutorial
Imports Button and Link components from MUI Joy UI, which provide enhanced styling and functionality over standard HTML button and anchor tags.
```javascript
import Button from '@mui/joy/Button';
import Link from '@mui/joy/Link';
```
--------------------------------
### Style Sheet Component with sx Prop
Source: https://mui.com/joy-ui/getting-started/tutorial
Shows how to apply custom styles to the Joy UI Sheet component using the `sx` prop. This allows for one-off customizations and experimentation with CSS properties like width, margin, padding, display, gap, and border-radius.
```jsx
Welcome!
```
--------------------------------
### Add Login Button and Sign-up Link
Source: https://mui.com/joy-ui/getting-started/tutorial
Implements a 'Log in' button and a 'Don't have an account? Sign up' link using MUI Joy UI components. The sign-up link is nested within the Typography component's endDecorator prop.
```jsx
Sign up}
fontSize="sm"
sx={{ alignSelf: 'center' }}
>
Don't have an account?
```
--------------------------------
### Import and Use Sheet Component with CssVarsProvider
Source: https://mui.com/joy-ui/getting-started/tutorial
Demonstrates how to import the Sheet and CssVarsProvider components from MUI Joy UI and use the Sheet with a 'outlined' variant. This sets up the basic structure for styling with global variants.
```jsx
import * as React from 'react';
import { CssVarsProvider } from '@mui/joy/styles';
import Sheet from '@mui/joy/Sheet';
export default function App() {
return (
Welcome!
);
}
```
--------------------------------
### Create Email and Password Input Fields
Source: https://mui.com/joy-ui/getting-started/tutorial
Defines JSX structure for email and password input fields using MUI Joy UI's FormControl, FormLabel, and Input components. Includes placeholders and type attributes for standard HTML input behavior.
```jsx
EmailPassword
```
--------------------------------
### Import Typography Component
Source: https://mui.com/joy-ui/getting-started/tutorial
Illustrates the import statement for the Typography component from MUI Joy UI, which is used for managing text hierarchy and styles within the application.
```jsx
import Typography from '@mui/joy/Typography';
```
--------------------------------
### Add Typography Components for Headings
Source: https://mui.com/joy-ui/getting-started/tutorial
Demonstrates how to use the Joy UI Typography component to render a main heading and a subheading. It shows the usage of the `level` prop for typographic scale and the `component` prop to override the default HTML element.
```jsx
Welcome!
Sign in to continue.
```
--------------------------------
### Import Joy UI Form Components
Source: https://mui.com/joy-ui/getting-started/tutorial
Imports necessary components (FormControl, FormLabel, Input) from the MUI Joy UI library for creating user input fields.
```javascript
import FormControl from '@mui/joy/FormControl';
import FormLabel from '@mui/joy/FormLabel';
import Input from '@mui/joy/Input';
```
--------------------------------
### Integrate Mode Toggle into App Component
Source: https://mui.com/joy-ui/getting-started/tutorial
Shows how to integrate the `ModeToggle` component into the main `App` component, placing it within the `CssVarsProvider` and before the main `Sheet` component.
```jsx
export default function App() {
return (
+ ...
);
}
```
--------------------------------
### Import useColorScheme Hook for Mode Toggle
Source: https://mui.com/joy-ui/getting-started/tutorial
Imports the CssVarsProvider and useColorScheme hook from '@mui/joy/styles' to manage application theme modes (light/dark).
```javascript
import { CssVarsProvider, useColorScheme } from '@mui/joy/styles';
```
--------------------------------
### Implement Light/Dark Mode Toggle Component
Source: https://mui.com/joy-ui/getting-started/tutorial
Creates a React functional component `ModeToggle` that utilizes the `useColorScheme` hook to allow users to switch between light, dark, and system default modes via a Select dropdown. Includes a `useEffect` hook to handle server-side rendering compatibility.
```javascript
import Select from '@mui/joy/Select';
import Option from '@mui/joy/Option';
function ModeToggle() {
const { mode, setMode } = useColorScheme();
const [mounted, setMounted] = React.useState(false);
// necessary for server-side rendering
// because mode is undefined on the server
React.useEffect(() => {
setMounted(true);
}, []);
if (!mounted) {
return null;
}
return (
);
}
```
--------------------------------
### Email Client Structure with MUI Joy UI
Source: https://mui.com/joy-ui/getting-started/templates/email
This snippet outlines the basic HTML structure for an email client, utilizing MUI Joy UI components for navigation, email list display, and message viewing. It serves as a foundational layout for the application.
```html