index
int64
0
0
repo_id
stringlengths
16
181
file_path
stringlengths
28
270
content
stringlengths
1
11.6M
__index_level_0__
int64
0
10k
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaColors.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Textarea from '@mui/joy/Textarea'; export default function TextareaColors() { return ( <Box sx={{ py: 2, display: 'grid', gap: 2, alignItems: 'center', flexWrap: 'wrap', }} > <Textarea name="Primary" placeholder="Type in here…" variant="outlined" color="primary" /> <Textarea name="Neutral" placeholder="Type in here…" variant="outlined" color="neutral" /> <Textarea name="Danger" placeholder="Type in here…" variant="outlined" color="danger" /> <Textarea name="Warning" placeholder="Type in here…" variant="outlined" color="warning" /> </Box> ); }
1,700
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaColors.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Textarea from '@mui/joy/Textarea'; export default function TextareaColors() { return ( <Box sx={{ py: 2, display: 'grid', gap: 2, alignItems: 'center', flexWrap: 'wrap', }} > <Textarea name="Primary" placeholder="Type in here…" variant="outlined" color="primary" /> <Textarea name="Neutral" placeholder="Type in here…" variant="outlined" color="neutral" /> <Textarea name="Danger" placeholder="Type in here…" variant="outlined" color="danger" /> <Textarea name="Warning" placeholder="Type in here…" variant="outlined" color="warning" /> </Box> ); }
1,701
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaDecorators.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import Textarea from '@mui/joy/Textarea'; import Typography from '@mui/joy/Typography'; export default function TextareaDecorators() { const [text, setText] = React.useState(''); const addEmoji = (emoji) => () => setText(`${text}${emoji}`); return ( <Textarea placeholder="Type in here…" value={text} onChange={(event) => setText(event.target.value)} minRows={2} maxRows={4} startDecorator={ <Box sx={{ display: 'flex', gap: 0.5, flex: 1 }}> <IconButton variant="outlined" color="neutral" onClick={addEmoji('👍')}> 👍 </IconButton> <IconButton variant="outlined" color="neutral" onClick={addEmoji('🏖')}> 🏖 </IconButton> <IconButton variant="outlined" color="neutral" onClick={addEmoji('😍')}> 😍 </IconButton> <Button variant="outlined" color="neutral" sx={{ ml: 'auto' }}> See all </Button> </Box> } endDecorator={ <Typography level="body-xs" sx={{ ml: 'auto' }}> {text.length} character(s) </Typography> } sx={{ minWidth: 300 }} /> ); }
1,702
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaDecorators.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import Textarea from '@mui/joy/Textarea'; import Typography from '@mui/joy/Typography'; export default function TextareaDecorators() { const [text, setText] = React.useState(''); const addEmoji = (emoji: string) => () => setText(`${text}${emoji}`); return ( <Textarea placeholder="Type in here…" value={text} onChange={(event) => setText(event.target.value)} minRows={2} maxRows={4} startDecorator={ <Box sx={{ display: 'flex', gap: 0.5, flex: 1 }}> <IconButton variant="outlined" color="neutral" onClick={addEmoji('👍')}> 👍 </IconButton> <IconButton variant="outlined" color="neutral" onClick={addEmoji('🏖')}> 🏖 </IconButton> <IconButton variant="outlined" color="neutral" onClick={addEmoji('😍')}> 😍 </IconButton> <Button variant="outlined" color="neutral" sx={{ ml: 'auto' }}> See all </Button> </Box> } endDecorator={ <Typography level="body-xs" sx={{ ml: 'auto' }}> {text.length} character(s) </Typography> } sx={{ minWidth: 300 }} /> ); }
1,703
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaField.js
import * as React from 'react'; import FormControl from '@mui/joy/FormControl'; import FormLabel from '@mui/joy/FormLabel'; import FormHelperText from '@mui/joy/FormHelperText'; import Textarea from '@mui/joy/Textarea'; export default function TextareaField() { return ( <FormControl> <FormLabel>Label</FormLabel> <Textarea placeholder="Placeholder" minRows={2} /> <FormHelperText>This is a helper text.</FormHelperText> </FormControl> ); }
1,704
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaField.tsx
import * as React from 'react'; import FormControl from '@mui/joy/FormControl'; import FormLabel from '@mui/joy/FormLabel'; import FormHelperText from '@mui/joy/FormHelperText'; import Textarea from '@mui/joy/Textarea'; export default function TextareaField() { return ( <FormControl> <FormLabel>Label</FormLabel> <Textarea placeholder="Placeholder" minRows={2} /> <FormHelperText>This is a helper text.</FormHelperText> </FormControl> ); }
1,705
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaField.tsx.preview
<FormControl> <FormLabel>Label</FormLabel> <Textarea placeholder="Placeholder" minRows={2} /> <FormHelperText>This is a helper text.</FormHelperText> </FormControl>
1,706
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaFormProps.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import Textarea from '@mui/joy/Textarea'; export default function TextareaFormProps() { return ( <Box sx={{ py: 2, display: 'flex', flexDirection: 'column', gap: 2, alignItems: 'center', flexWrap: 'wrap', }} > <form onSubmit={(event) => { event.preventDefault(); }} > <Textarea placeholder="Try to submit with no text!" required sx={{ mb: 1 }} /> <Textarea placeholder="It is disabled" disabled sx={{ mb: 1 }} /> <Button type="submit">Submit</Button> </form> </Box> ); }
1,707
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaFormProps.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import Textarea from '@mui/joy/Textarea'; export default function TextareaFormProps() { return ( <Box sx={{ py: 2, display: 'flex', flexDirection: 'column', gap: 2, alignItems: 'center', flexWrap: 'wrap', }} > <form onSubmit={(event) => { event.preventDefault(); }} > <Textarea placeholder="Try to submit with no text!" required sx={{ mb: 1 }} /> <Textarea placeholder="It is disabled" disabled sx={{ mb: 1 }} /> <Button type="submit">Submit</Button> </form> </Box> ); }
1,708
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaFormProps.tsx.preview
<form onSubmit={(event) => { event.preventDefault(); }} > <Textarea placeholder="Try to submit with no text!" required sx={{ mb: 1 }} /> <Textarea placeholder="It is disabled" disabled sx={{ mb: 1 }} /> <Button type="submit">Submit</Button> </form>
1,709
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaRef.js
import * as React from 'react'; import Button from '@mui/joy/Button'; import Textarea from '@mui/joy/Textarea'; import Stack from '@mui/joy/Stack'; export default function TextareaRef() { const textareaRef = React.useRef(null); const handleTextareaFocus = () => { textareaRef.current?.focus(); }; return ( <Stack direction="row" gap={1}> <Textarea placeholder="Placeholder" slotProps={{ textarea: { ref: textareaRef } }} /> <Button onClick={handleTextareaFocus}>Focus textarea element</Button> </Stack> ); }
1,710
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaRef.tsx
import * as React from 'react'; import Button from '@mui/joy/Button'; import Textarea from '@mui/joy/Textarea'; import Stack from '@mui/joy/Stack'; export default function TextareaRef() { const textareaRef = React.useRef<HTMLTextAreaElement | null>(null); const handleTextareaFocus = () => { textareaRef.current?.focus(); }; return ( <Stack direction="row" gap={1}> <Textarea placeholder="Placeholder" slotProps={{ textarea: { ref: textareaRef } }} /> <Button onClick={handleTextareaFocus}>Focus textarea element</Button> </Stack> ); }
1,711
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaRef.tsx.preview
<Textarea placeholder="Placeholder" slotProps={{ textarea: { ref: textareaRef } }} /> <Button onClick={handleTextareaFocus}>Focus textarea element</Button>
1,712
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaRows.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Textarea from '@mui/joy/Textarea'; export default function TextareaRows() { return ( <Box sx={{ p: 2 }}> <Textarea placeholder="Type in here…" defaultValue="Try to put text longer than 4 lines." minRows={2} maxRows={4} /> </Box> ); }
1,713
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaRows.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Textarea from '@mui/joy/Textarea'; export default function TextareaRows() { return ( <Box sx={{ p: 2 }}> <Textarea placeholder="Type in here…" defaultValue="Try to put text longer than 4 lines." minRows={2} maxRows={4} /> </Box> ); }
1,714
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaRows.tsx.preview
<Textarea placeholder="Type in here…" defaultValue="Try to put text longer than 4 lines." minRows={2} maxRows={4} />
1,715
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaSizes.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Textarea from '@mui/joy/Textarea'; export default function TextareaSizes() { return ( <Box sx={{ display: 'flex', gap: 2, alignItems: 'center', flexWrap: 'wrap' }}> <Textarea size="sm" name="Size" placeholder="Small" /> <Textarea size="md" name="Size" placeholder="Medium" /> <Textarea size="lg" name="Size" placeholder="Large" /> </Box> ); }
1,716
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaSizes.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Textarea from '@mui/joy/Textarea'; export default function TextareaSizes() { return ( <Box sx={{ display: 'flex', gap: 2, alignItems: 'center', flexWrap: 'wrap' }}> <Textarea size="sm" name="Size" placeholder="Small" /> <Textarea size="md" name="Size" placeholder="Medium" /> <Textarea size="lg" name="Size" placeholder="Large" /> </Box> ); }
1,717
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaSizes.tsx.preview
<Textarea size="sm" name="Size" placeholder="Small" /> <Textarea size="md" name="Size" placeholder="Medium" /> <Textarea size="lg" name="Size" placeholder="Large" />
1,718
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaUsage.js
import * as React from 'react'; import Textarea from '@mui/joy/Textarea'; import JoyUsageDemo from 'docs/src/modules/components/JoyUsageDemo'; export default function TextareaUsage() { return ( <JoyUsageDemo componentName="Textarea" data={[ { propName: 'variant', knob: 'radio', defaultValue: 'outlined', options: ['plain', 'outlined', 'soft', 'solid'], }, { propName: 'color', knob: 'color', defaultValue: 'neutral', }, { propName: 'size', knob: 'radio', options: ['sm', 'md', 'lg'], defaultValue: 'md', }, { propName: 'placeholder', knob: 'input', defaultValue: 'Type something…', }, { propName: 'disabled', knob: 'switch', defaultValue: false, }, { propName: 'minRows', defaultValue: 2, codeBlockDisplay: true, }, ]} renderDemo={(props) => <Textarea {...props} />} /> ); }
1,719
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaValidation.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Textarea from '@mui/joy/Textarea'; export default function TextareaValidation() { return ( <Box sx={{ p: 2 }}> <Textarea placeholder="Type in here…" error defaultValue="Oh no! Something is definitely wrong." /> </Box> ); }
1,720
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaValidation.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Textarea from '@mui/joy/Textarea'; export default function TextareaValidation() { return ( <Box sx={{ p: 2 }}> <Textarea placeholder="Type in here…" error defaultValue="Oh no! Something is definitely wrong." /> </Box> ); }
1,721
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaValidation.tsx.preview
<Textarea placeholder="Type in here…" error defaultValue="Oh no! Something is definitely wrong." />
1,722
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaVariants.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Textarea from '@mui/joy/Textarea'; export default function TextareaVariants() { return ( <Box sx={{ py: 2, display: 'grid', gap: 2, alignItems: 'center', flexWrap: 'wrap', }} > <Textarea name="Solid" placeholder="Type in here…" variant="solid" /> <Textarea name="Soft" placeholder="Type in here…" variant="soft" /> <Textarea name="Outlined" placeholder="Type in here…" variant="outlined" /> <Textarea name="Plain" placeholder="Type in here…" variant="plain" /> </Box> ); }
1,723
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaVariants.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Textarea from '@mui/joy/Textarea'; export default function TextareaVariants() { return ( <Box sx={{ py: 2, display: 'grid', gap: 2, alignItems: 'center', flexWrap: 'wrap', }} > <Textarea name="Solid" placeholder="Type in here…" variant="solid" /> <Textarea name="Soft" placeholder="Type in here…" variant="soft" /> <Textarea name="Outlined" placeholder="Type in here…" variant="outlined" /> <Textarea name="Plain" placeholder="Type in here…" variant="plain" /> </Box> ); }
1,724
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TextareaVariants.tsx.preview
<Textarea name="Solid" placeholder="Type in here…" variant="solid" /> <Textarea name="Soft" placeholder="Type in here…" variant="soft" /> <Textarea name="Outlined" placeholder="Type in here…" variant="outlined" /> <Textarea name="Plain" placeholder="Type in here…" variant="plain" />
1,725
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TriggerFocusTextarea.js
import * as React from 'react'; import Textarea from '@mui/joy/Textarea'; export default function TriggerFocusTextarea() { return ( <Textarea placeholder="Looks like I'm focused but no" sx={{ '--Textarea-focused': 1, }} /> ); }
1,726
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TriggerFocusTextarea.tsx
import * as React from 'react'; import Textarea from '@mui/joy/Textarea'; export default function TriggerFocusTextarea() { return ( <Textarea placeholder="Looks like I'm focused but no" sx={{ '--Textarea-focused': 1, }} /> ); }
1,727
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/TriggerFocusTextarea.tsx.preview
<Textarea placeholder="Looks like I'm focused but no" sx={{ '--Textarea-focused': 1, }} />
1,728
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/UnderlineTextarea.js
import * as React from 'react'; import Textarea from '@mui/joy/Textarea'; import Stack from '@mui/joy/Stack'; export default function UnderlineTextarea() { return ( <Stack spacing={2}> <Textarea minRows={2} placeholder="Type in here…" sx={{ '&::before': { border: '1.5px solid var(--Textarea-focusedHighlight)', transform: 'scaleX(0)', left: '2.5px', right: '2.5px', bottom: 0, top: 'unset', transition: 'transform .15s cubic-bezier(0.1,0.9,0.2,1)', borderRadius: 0, borderBottomLeftRadius: '64px 20px', borderBottomRightRadius: '64px 20px', }, '&:focus-within::before': { transform: 'scaleX(1)', }, }} /> <Textarea minRows={2} placeholder="Type in here…" variant="soft" sx={{ borderBottom: '2px solid', borderColor: 'neutral.outlinedBorder', borderRadius: 0, '&:hover': { borderColor: 'neutral.outlinedHoverBorder', }, '&::before': { border: '1px solid var(--Textarea-focusedHighlight)', transform: 'scaleX(0)', left: 0, right: 0, bottom: '-2px', top: 'unset', transition: 'transform .15s cubic-bezier(0.1,0.9,0.2,1)', borderRadius: 0, }, '&:focus-within::before': { transform: 'scaleX(1)', }, }} /> </Stack> ); }
1,729
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/UnderlineTextarea.tsx
import * as React from 'react'; import Textarea from '@mui/joy/Textarea'; import Stack from '@mui/joy/Stack'; export default function UnderlineTextarea() { return ( <Stack spacing={2}> <Textarea minRows={2} placeholder="Type in here…" sx={{ '&::before': { border: '1.5px solid var(--Textarea-focusedHighlight)', transform: 'scaleX(0)', left: '2.5px', right: '2.5px', bottom: 0, top: 'unset', transition: 'transform .15s cubic-bezier(0.1,0.9,0.2,1)', borderRadius: 0, borderBottomLeftRadius: '64px 20px', borderBottomRightRadius: '64px 20px', }, '&:focus-within::before': { transform: 'scaleX(1)', }, }} /> <Textarea minRows={2} placeholder="Type in here…" variant="soft" sx={{ borderBottom: '2px solid', borderColor: 'neutral.outlinedBorder', borderRadius: 0, '&:hover': { borderColor: 'neutral.outlinedHoverBorder', }, '&::before': { border: '1px solid var(--Textarea-focusedHighlight)', transform: 'scaleX(0)', left: 0, right: 0, bottom: '-2px', top: 'unset', transition: 'transform .15s cubic-bezier(0.1,0.9,0.2,1)', borderRadius: 0, }, '&:focus-within::before': { transform: 'scaleX(1)', }, }} /> </Stack> ); }
1,730
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/textarea/textarea.md
--- productId: joy-ui title: React Textarea component components: Textarea githubLabel: 'component: TextareaAutosize' unstyled: /base-ui/react-textarea-autosize/ --- # Textarea <p class="description">Textarea component gives you a textarea HTML element that automatically adjusts its height to match the length of the content within.</p> {{"component": "modules/components/ComponentLinkHeader.js", "design": false}} ## Introduction Joy UI's textarea component is built on top of the Base UI [`TextareaAutoSize`](/base-ui/react-textarea-autosize/) component. {{"demo": "TextareaUsage.js", "hideToolbar": true, "bg": "gradient"}} ## Component After [installation](/joy-ui/getting-started/installation/), you can start building with this component using the following basic elements: ```jsx import Textarea from '@mui/joy/Textarea'; export default function MyApp() { return <Textarea placeholder="Type anything…" />; } ``` ### Variants The textarea component supports the four global variants: solid (default), soft, outlined, and plain. {{"demo": "TextareaVariants.js"}} ### Sizes The textarea component comes with three sizes out of the box: `sm`, `md` (the default), and `lg`. {{"demo": "TextareaSizes.js"}} ### Colors Toggle the palette that's being used to color the by text field by using the `color` prop. {{"demo": "TextareaColors.js"}} ### Form props Standard form attributes are supported e.g. `required`, `disabled`, etc. {{"demo": "TextareaFormProps.js"}} ### Focused ring Provide these CSS variables to `sx` prop to control the focused ring appearance: - `--Textarea-focusedInset`: the focused ring's **position**, either inside(`inset`) or outside(`var(--any, )`) of the Textarea. - `--Textarea-focusedThickness`: the **size** of the focused ring. - `--Textarea-focusedHighlight`: the **color** of the focused ring. {{"demo": "FocusedRingTextarea.js"}} :::success To get full control of the focused ring, customize the `box-shadow` of the `::before` pseudo element directly ```js <Textarea sx={{ '&:focus-within::before': { boxShadow: '...your custom value' } }} /> ``` ::: #### Debugging the focus ring To display the Textarea's focus ring by simulating user's focus, inspect the Textarea element and toggle the [pseudostate panel](https://developer.chrome.com/docs/devtools/css/#pseudostates). - If you inspect the Textarea's root element, with `.MuiTextarea-root` class, you have to toggle on the `:focus-within` state. - If you inspect the `<input>` element, you have to toggle on the `:focus` state. ### Triggering the focus ring To trigger the focus ring programmatically, set the CSS variable `--Textarea-focused: 1`. {{"demo": "TriggerFocusTextarea.js"}} :::info The focus ring still appear on focus even though you set `--Textarea-focused: 0`. ::: ### Validation To toggle the error state, use the `error` prop. {{"demo": "TextareaValidation.js"}} Note that using the `color` prop with danger as value gets the same result: ```js <Textarea color="danger" /> ``` ### Rows Use the `minRows` to set the minimum number of lines to show and `maxRows` to limit the number of lines that users will see. {{"demo": "TextareaRows.js"}} ### Decorators Use the `startDecorator` and/or `endDecorator` props to add supporting icons or elements to the textarea. It's usually more common to see textarea components using decorators at the top and bottom. {{"demo": "TextareaDecorators.js"}} ### HTML textarea ref Use the `slotProps.textarea` attribute to pass props to the `ref` and other [supported HTML attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attributes) to the textarea element. {{"demo": "TextareaRef.js"}} ## Accessibility In order for the textarea to be accessible, **it should be linked to a label**. The `FormControl` automatically generates a unique id that links the textarea with the `FormLabel` component: {{"demo": "TextareaField.js"}} Alternatively, you can do it manually by targeting the textarea slot: ```jsx <label htmlFor="unique-id">Label</label> <Textarea slotProps={{ textarea: { id: 'unique-id', } }} /> ``` ## Common examples ### Focus outline This example shows how to replace the default focus ring appearance with CSS outline. {{"demo": "FocusOutlineTextarea.js"}} ### Floating label To create a floating label textarea, a custom component (combination of `<textarea>` and `<label>`) is required to replace the default textarea slot. {{"demo": "FloatingLabelTextarea.js"}} ### Underline input {{"demo": "UnderlineTextarea.js"}} ### Comment box {{"demo": "ExampleTextareaComment.js"}}
1,731
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ExclusiveSelection.js
import * as React from 'react'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; import FormatBoldIcon from '@mui/icons-material/FormatBold'; import FormatItalicIcon from '@mui/icons-material/FormatItalic'; import FormatUnderlinedIcon from '@mui/icons-material/FormatUnderlined'; export default function ExclusiveSelection() { const [value, setValue] = React.useState('default'); return ( <ToggleButtonGroup value={value} onChange={(event, newValue) => { setValue(newValue); }} > <Button value="default">Default</Button> <IconButton value="bold"> <FormatBoldIcon /> </IconButton> <IconButton value="italic"> <FormatItalicIcon /> </IconButton> <IconButton value="underlined"> <FormatUnderlinedIcon /> </IconButton> </ToggleButtonGroup> ); }
1,732
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ExclusiveSelection.tsx
import * as React from 'react'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; import FormatBoldIcon from '@mui/icons-material/FormatBold'; import FormatItalicIcon from '@mui/icons-material/FormatItalic'; import FormatUnderlinedIcon from '@mui/icons-material/FormatUnderlined'; export default function ExclusiveSelection() { const [value, setValue] = React.useState<string | null>('default'); return ( <ToggleButtonGroup value={value} onChange={(event, newValue) => { setValue(newValue); }} > <Button value="default">Default</Button> <IconButton value="bold"> <FormatBoldIcon /> </IconButton> <IconButton value="italic"> <FormatItalicIcon /> </IconButton> <IconButton value="underlined"> <FormatUnderlinedIcon /> </IconButton> </ToggleButtonGroup> ); }
1,733
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/FigmaButtonGroup.js
import * as React from 'react'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; import IconButton from '@mui/joy/IconButton'; import FormatAlignLeftIcon from '@mui/icons-material/FormatAlignLeft'; import FormatAlignCenterIcon from '@mui/icons-material/FormatAlignCenter'; import FormatAlignRightIcon from '@mui/icons-material/FormatAlignRight'; import FormatAlignJustifyIcon from '@mui/icons-material/FormatAlignJustify'; export default function FigmaButtonGroup() { const [index, setIndex] = React.useState('0'); return ( <ToggleButtonGroup variant="plain" value={index} onChange={(event, newIndex) => { setIndex(newIndex); }} aria-label="figma button group" sx={{ '--ButtonGroup-radius': '3px', '--ButtonGroup-separatorSize': '0px', '--ButtonGroup-connected': '0', '&:hover': { boxShadow: 'inset 0px 0px 0px 1px var(--joy-palette-neutral-softBg)', '--ButtonGroup-connected': '1', }, }} > <IconButton value={0}> <FormatAlignLeftIcon /> </IconButton> <IconButton value={1}> <FormatAlignCenterIcon /> </IconButton> <IconButton value={2}> <FormatAlignRightIcon /> </IconButton> <IconButton value={3}> <FormatAlignJustifyIcon /> </IconButton> </ToggleButtonGroup> ); }
1,734
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/FigmaButtonGroup.tsx
import * as React from 'react'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; import IconButton from '@mui/joy/IconButton'; import FormatAlignLeftIcon from '@mui/icons-material/FormatAlignLeft'; import FormatAlignCenterIcon from '@mui/icons-material/FormatAlignCenter'; import FormatAlignRightIcon from '@mui/icons-material/FormatAlignRight'; import FormatAlignJustifyIcon from '@mui/icons-material/FormatAlignJustify'; export default function FigmaButtonGroup() { const [index, setIndex] = React.useState<string | null>('0'); return ( <ToggleButtonGroup variant="plain" value={index} onChange={(event, newIndex) => { setIndex(newIndex); }} aria-label="figma button group" sx={{ '--ButtonGroup-radius': '3px', '--ButtonGroup-separatorSize': '0px', '--ButtonGroup-connected': '0', '&:hover': { boxShadow: 'inset 0px 0px 0px 1px var(--joy-palette-neutral-softBg)', '--ButtonGroup-connected': '1', }, }} > <IconButton value={0}> <FormatAlignLeftIcon /> </IconButton> <IconButton value={1}> <FormatAlignCenterIcon /> </IconButton> <IconButton value={2}> <FormatAlignRightIcon /> </IconButton> <IconButton value={3}> <FormatAlignJustifyIcon /> </IconButton> </ToggleButtonGroup> ); }
1,735
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleButtons.js
import * as React from 'react'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import Stack from '@mui/joy/Stack'; import FormatBold from '@mui/icons-material/FormatBold'; export default function ToggleButtons() { const [pressed, setPressed] = React.useState(false); return ( <Stack spacing={2} direction="row"> <Button variant="outlined" color="neutral" onClick={() => setPressed(!pressed)} aria-pressed={pressed ? 'true' : 'false'} sx={(theme) => ({ [`&[aria-pressed="true"]`]: { ...theme.variants.outlinedActive.neutral, borderColor: theme.vars.palette.neutral.outlinedHoverBorder, }, })} > Button </Button> <IconButton variant="outlined" color="neutral" onClick={() => setPressed(!pressed)} aria-pressed={pressed ? 'true' : 'false'} sx={(theme) => ({ [`&[aria-pressed="true"]`]: { ...theme.variants.outlinedActive.neutral, borderColor: theme.vars.palette.neutral.outlinedHoverBorder, }, })} > <FormatBold /> </IconButton> </Stack> ); }
1,736
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleButtons.tsx
import * as React from 'react'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import Stack from '@mui/joy/Stack'; import FormatBold from '@mui/icons-material/FormatBold'; export default function ToggleButtons() { const [pressed, setPressed] = React.useState(false); return ( <Stack spacing={2} direction="row"> <Button variant="outlined" color="neutral" onClick={() => setPressed(!pressed)} aria-pressed={pressed ? 'true' : 'false'} sx={(theme) => ({ [`&[aria-pressed="true"]`]: { ...theme.variants.outlinedActive.neutral, borderColor: theme.vars.palette.neutral.outlinedHoverBorder, }, })} > Button </Button> <IconButton variant="outlined" color="neutral" onClick={() => setPressed(!pressed)} aria-pressed={pressed ? 'true' : 'false'} sx={(theme) => ({ [`&[aria-pressed="true"]`]: { ...theme.variants.outlinedActive.neutral, borderColor: theme.vars.palette.neutral.outlinedHoverBorder, }, })} > <FormatBold /> </IconButton> </Stack> ); }
1,737
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroup.js
import * as React from 'react'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; import FormatBoldIcon from '@mui/icons-material/FormatBold'; import FormatItalicIcon from '@mui/icons-material/FormatItalic'; import FormatUnderlinedIcon from '@mui/icons-material/FormatUnderlined'; export default function ToggleGroup() { const [value, setValue] = React.useState(['default']); return ( <ToggleButtonGroup value={value} onChange={(event, newValue) => { setValue(newValue); }} > <Button value="default">Default</Button> <IconButton value="bold"> <FormatBoldIcon /> </IconButton> <IconButton value="italic"> <FormatItalicIcon /> </IconButton> <IconButton value="underlined"> <FormatUnderlinedIcon /> </IconButton> </ToggleButtonGroup> ); }
1,738
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroup.tsx
import * as React from 'react'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; import FormatBoldIcon from '@mui/icons-material/FormatBold'; import FormatItalicIcon from '@mui/icons-material/FormatItalic'; import FormatUnderlinedIcon from '@mui/icons-material/FormatUnderlined'; export default function ToggleGroup() { const [value, setValue] = React.useState(['default']); return ( <ToggleButtonGroup value={value} onChange={(event, newValue) => { setValue(newValue); }} > <Button value="default">Default</Button> <IconButton value="bold"> <FormatBoldIcon /> </IconButton> <IconButton value="italic"> <FormatItalicIcon /> </IconButton> <IconButton value="underlined"> <FormatUnderlinedIcon /> </IconButton> </ToggleButtonGroup> ); }
1,739
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroupColors.js
import * as React from 'react'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import FormControl from '@mui/joy/FormControl'; import FormLabel from '@mui/joy/FormLabel'; import RadioGroup from '@mui/joy/RadioGroup'; import Radio from '@mui/joy/Radio'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; import Stack from '@mui/joy/Stack'; import FormatBoldIcon from '@mui/icons-material/FormatBold'; import FormatItalicIcon from '@mui/icons-material/FormatItalic'; import FormatUnderlinedIcon from '@mui/icons-material/FormatUnderlined'; export default function ToggleGroupColors() { const [variant, setVariant] = React.useState('plain'); const [color, setColor] = React.useState('neutral'); return ( <Stack spacing={2}> <ToggleButtonGroup variant={variant || undefined} color={color || undefined} value="pressed" > <Button value="pressed">I&apos;m pressed</Button> <IconButton value="bold"> <FormatBoldIcon /> </IconButton> <IconButton value="italic"> <FormatItalicIcon /> </IconButton> <IconButton value="underlined"> <FormatUnderlinedIcon /> </IconButton> </ToggleButtonGroup> <FormControl> <FormLabel>Variant</FormLabel> <RadioGroup orientation="horizontal" value={variant} onChange={(event) => setVariant(event.target.value)} > <Radio value="plain" label="plain" /> <Radio value="outlined" label="outlined" /> <Radio value="soft" label="soft" /> <Radio value="solid" label="solid" /> </RadioGroup> </FormControl> <FormControl> <FormLabel>Color</FormLabel> <RadioGroup orientation="horizontal" value={color} onChange={(event) => setColor(event.target.value)} > <Radio value="primary" label="primary" /> <Radio value="neutral" label="neutral" /> <Radio value="danger" label="danger" /> <Radio value="success" label="success" /> <Radio value="warning" label="warning" /> </RadioGroup> </FormControl> </Stack> ); }
1,740
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroupColors.tsx
import * as React from 'react'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import FormControl from '@mui/joy/FormControl'; import FormLabel from '@mui/joy/FormLabel'; import RadioGroup from '@mui/joy/RadioGroup'; import Radio from '@mui/joy/Radio'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; import Stack from '@mui/joy/Stack'; import FormatBoldIcon from '@mui/icons-material/FormatBold'; import FormatItalicIcon from '@mui/icons-material/FormatItalic'; import FormatUnderlinedIcon from '@mui/icons-material/FormatUnderlined'; import { VariantProp, ColorPaletteProp } from '@mui/joy/styles'; export default function ToggleGroupColors() { const [variant, setVariant] = React.useState<VariantProp | null>('plain'); const [color, setColor] = React.useState<ColorPaletteProp | null>('neutral'); return ( <Stack spacing={2}> <ToggleButtonGroup variant={variant || undefined} color={color || undefined} value="pressed" > <Button value="pressed">I&apos;m pressed</Button> <IconButton value="bold"> <FormatBoldIcon /> </IconButton> <IconButton value="italic"> <FormatItalicIcon /> </IconButton> <IconButton value="underlined"> <FormatUnderlinedIcon /> </IconButton> </ToggleButtonGroup> <FormControl> <FormLabel>Variant</FormLabel> <RadioGroup orientation="horizontal" value={variant} onChange={(event) => setVariant(event.target.value as VariantProp)} > <Radio value="plain" label="plain" /> <Radio value="outlined" label="outlined" /> <Radio value="soft" label="soft" /> <Radio value="solid" label="solid" /> </RadioGroup> </FormControl> <FormControl> <FormLabel>Color</FormLabel> <RadioGroup orientation="horizontal" value={color} onChange={(event) => setColor(event.target.value as ColorPaletteProp)} > <Radio value="primary" label="primary" /> <Radio value="neutral" label="neutral" /> <Radio value="danger" label="danger" /> <Radio value="success" label="success" /> <Radio value="warning" label="warning" /> </RadioGroup> </FormControl> </Stack> ); }
1,741
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroupSizes.js
import * as React from 'react'; import Button from '@mui/joy/Button'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; export default function ToggleGroupSizes() { const [value, setValue] = React.useState('md'); return ( <ToggleButtonGroup size={value || undefined} value={value} onChange={(event, newValue) => { setValue(newValue); }} > <Button value="sm">Small</Button> <Button value="md">Medium</Button> <Button value="lg">Large</Button> </ToggleButtonGroup> ); }
1,742
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroupSizes.tsx
import * as React from 'react'; import Button from '@mui/joy/Button'; import ToggleButtonGroup, { ToggleButtonGroupStaticProps, } from '@mui/joy/ToggleButtonGroup'; export default function ToggleGroupSizes() { const [value, setValue] = React.useState< ToggleButtonGroupStaticProps['size'] | null >('md'); return ( <ToggleButtonGroup size={value || undefined} value={value} onChange={(event, newValue) => { setValue(newValue); }} > <Button value="sm">Small</Button> <Button value="md">Medium</Button> <Button value="lg">Large</Button> </ToggleButtonGroup> ); }
1,743
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroupSizes.tsx.preview
<ToggleButtonGroup size={value || undefined} value={value} onChange={(event, newValue) => { setValue(newValue); }} > <Button value="sm">Small</Button> <Button value="md">Medium</Button> <Button value="lg">Large</Button> </ToggleButtonGroup>
1,744
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroupSpacing.js
import * as React from 'react'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; import FormatBoldIcon from '@mui/icons-material/FormatBold'; import FormatItalicIcon from '@mui/icons-material/FormatItalic'; import FormatUnderlinedIcon from '@mui/icons-material/FormatUnderlined'; export default function ToggleGroupSpacing() { const [value, setValue] = React.useState(['default']); return ( <ToggleButtonGroup spacing={2} value={value} onChange={(event, newValue) => { setValue(newValue); }} > <Button value="default">Default</Button> <IconButton value="bold"> <FormatBoldIcon /> </IconButton> <IconButton value="italic"> <FormatItalicIcon /> </IconButton> <IconButton value="underlined"> <FormatUnderlinedIcon /> </IconButton> </ToggleButtonGroup> ); }
1,745
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroupSpacing.tsx
import * as React from 'react'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; import FormatBoldIcon from '@mui/icons-material/FormatBold'; import FormatItalicIcon from '@mui/icons-material/FormatItalic'; import FormatUnderlinedIcon from '@mui/icons-material/FormatUnderlined'; export default function ToggleGroupSpacing() { const [value, setValue] = React.useState(['default']); return ( <ToggleButtonGroup spacing={2} value={value} onChange={(event, newValue) => { setValue(newValue); }} > <Button value="default">Default</Button> <IconButton value="bold"> <FormatBoldIcon /> </IconButton> <IconButton value="italic"> <FormatItalicIcon /> </IconButton> <IconButton value="underlined"> <FormatUnderlinedIcon /> </IconButton> </ToggleButtonGroup> ); }
1,746
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroupToolbar.js
import * as React from 'react'; import AspectRatio from '@mui/joy/AspectRatio'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import Divider from '@mui/joy/Divider'; import Sheet from '@mui/joy/Sheet'; import IconButton from '@mui/joy/IconButton'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; import SvgIcon from '@mui/joy/SvgIcon'; import FormatAlignLeftIcon from '@mui/icons-material/FormatAlignLeft'; import FormatAlignCenterIcon from '@mui/icons-material/FormatAlignCenter'; import FormatAlignRightIcon from '@mui/icons-material/FormatAlignRight'; import FormatAlignJustifyIcon from '@mui/icons-material/FormatAlignJustify'; import FormatBoldIcon from '@mui/icons-material/FormatBold'; import FormatItalicIcon from '@mui/icons-material/FormatItalic'; import FormatUnderlinedIcon from '@mui/icons-material/FormatUnderlined'; export default function ToggleGroupToolbar() { const [alignment, setAlignment] = React.useState('left'); const [formats, setFormats] = React.useState(() => ['italic']); const [color, setColor] = React.useState('#ff5252'); return ( <Sheet variant="outlined" sx={{ borderRadius: 'md', display: 'flex', gap: 2, p: 0.5 }} > <ToggleButtonGroup variant="plain" spacing={0.5} value={alignment} onChange={(event, newAlignment) => { setAlignment(newAlignment); }} aria-label="text alignment" > <IconButton value="left" aria-label="left aligned"> <FormatAlignLeftIcon /> </IconButton> <IconButton value="center" aria-label="centered"> <FormatAlignCenterIcon /> </IconButton> <IconButton value="right" aria-label="right aligned"> <FormatAlignRightIcon /> </IconButton> <IconButton value="justify" aria-label="justified" disabled> <FormatAlignJustifyIcon /> </IconButton> </ToggleButtonGroup> <Divider orientation="vertical" sx={{ height: '60%', alignSelf: 'center' }} /> <ToggleButtonGroup variant="plain" spacing={0.5} value={formats} onChange={(event, newFormats) => { setFormats(newFormats); }} aria-label="text formatting" > <IconButton value="bold" aria-label="bold"> <FormatBoldIcon /> </IconButton> <IconButton value="italic" aria-label="italic"> <FormatItalicIcon /> </IconButton> <IconButton value="underlined" aria-label="underlined"> <FormatUnderlinedIcon /> </IconButton> </ToggleButtonGroup> <Divider orientation="vertical" sx={{ height: '60%', alignSelf: 'center' }} /> <Button component="label" tabIndex={-1} role={undefined} aria-label="fill color" variant="outlined" color="neutral" endDecorator={ <SvgIcon fontSize="md"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={2} stroke="currentColor" > <path strokeLinecap="round" strokeLinejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" /> </svg> </SvgIcon> } sx={{ pl: 1 }} > <AspectRatio variant="plain" ratio="1" sx={{ borderRadius: '50%', width: '1.5em', bgcolor: color, }} > <div /> </AspectRatio> <Box component="input" type="color" value={color} onChange={(event) => setColor(event.target.value)} sx={{ clip: 'rect(0 0 0 0)', clipPath: 'inset(50%)', height: '1px', overflow: 'hidden', position: 'absolute', bottom: 0, left: 0, whiteSpace: 'nowrap', width: '1px', }} /> </Button> </Sheet> ); }
1,747
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroupToolbar.tsx
import * as React from 'react'; import AspectRatio from '@mui/joy/AspectRatio'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import Divider from '@mui/joy/Divider'; import Sheet from '@mui/joy/Sheet'; import IconButton from '@mui/joy/IconButton'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; import SvgIcon from '@mui/joy/SvgIcon'; import FormatAlignLeftIcon from '@mui/icons-material/FormatAlignLeft'; import FormatAlignCenterIcon from '@mui/icons-material/FormatAlignCenter'; import FormatAlignRightIcon from '@mui/icons-material/FormatAlignRight'; import FormatAlignJustifyIcon from '@mui/icons-material/FormatAlignJustify'; import FormatBoldIcon from '@mui/icons-material/FormatBold'; import FormatItalicIcon from '@mui/icons-material/FormatItalic'; import FormatUnderlinedIcon from '@mui/icons-material/FormatUnderlined'; export default function ToggleGroupToolbar() { const [alignment, setAlignment] = React.useState<string | null>('left'); const [formats, setFormats] = React.useState(() => ['italic']); const [color, setColor] = React.useState('#ff5252'); return ( <Sheet variant="outlined" sx={{ borderRadius: 'md', display: 'flex', gap: 2, p: 0.5 }} > <ToggleButtonGroup variant="plain" spacing={0.5} value={alignment} onChange={(event, newAlignment) => { setAlignment(newAlignment); }} aria-label="text alignment" > <IconButton value="left" aria-label="left aligned"> <FormatAlignLeftIcon /> </IconButton> <IconButton value="center" aria-label="centered"> <FormatAlignCenterIcon /> </IconButton> <IconButton value="right" aria-label="right aligned"> <FormatAlignRightIcon /> </IconButton> <IconButton value="justify" aria-label="justified" disabled> <FormatAlignJustifyIcon /> </IconButton> </ToggleButtonGroup> <Divider orientation="vertical" sx={{ height: '60%', alignSelf: 'center' }} /> <ToggleButtonGroup variant="plain" spacing={0.5} value={formats} onChange={(event, newFormats) => { setFormats(newFormats); }} aria-label="text formatting" > <IconButton value="bold" aria-label="bold"> <FormatBoldIcon /> </IconButton> <IconButton value="italic" aria-label="italic"> <FormatItalicIcon /> </IconButton> <IconButton value="underlined" aria-label="underlined"> <FormatUnderlinedIcon /> </IconButton> </ToggleButtonGroup> <Divider orientation="vertical" sx={{ height: '60%', alignSelf: 'center' }} /> <Button component="label" tabIndex={-1} role={undefined} aria-label="fill color" variant="outlined" color="neutral" endDecorator={ <SvgIcon fontSize="md"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={2} stroke="currentColor" > <path strokeLinecap="round" strokeLinejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" /> </svg> </SvgIcon> } sx={{ pl: 1 }} > <AspectRatio variant="plain" ratio="1" sx={{ borderRadius: '50%', width: '1.5em', bgcolor: color, }} > <div /> </AspectRatio> <Box component="input" type="color" value={color} onChange={(event) => setColor(event.target.value)} sx={{ clip: 'rect(0 0 0 0)', clipPath: 'inset(50%)', height: '1px', overflow: 'hidden', position: 'absolute', bottom: 0, left: 0, whiteSpace: 'nowrap', width: '1px', }} /> </Button> </Sheet> ); }
1,748
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroupUsage.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; import FormatItalicIcon from '@mui/icons-material/FormatItalic'; import FormatUnderlinedIcon from '@mui/icons-material/FormatUnderlined'; import JoyUsageDemo from 'docs/src/modules/components/JoyUsageDemo'; export default function ToggleGroupUsage() { const [value, setValue] = React.useState('bold'); const [values, setValues] = React.useState([value]); return ( <JoyUsageDemo componentName="ToggleButtonGroup" data={[ { propName: 'variant', knob: 'radio', defaultValue: 'outlined', options: ['plain', 'outlined', 'soft', 'solid'], }, { propName: 'color', knob: 'color', defaultValue: 'neutral', }, { propName: 'size', knob: 'radio', options: ['sm', 'md', 'lg'], defaultValue: 'md', }, { propName: 'children', defaultValue: `<Button /> <IconButton /> <IconButton />`, }, ]} renderDemo={(props) => ( <Box sx={{ display: 'flex', gap: 2 }}> <ToggleButtonGroup value={props.exclusive ? value : values} onChange={(event, newValue) => { if (Array.isArray(newValue)) { setValues(newValue); } else { setValue(newValue); } }} {...props} > <Button value="bold">Bold</Button> <IconButton value="italic"> <FormatItalicIcon /> </IconButton> <IconButton value="underlined"> <FormatUnderlinedIcon /> </IconButton> </ToggleButtonGroup> </Box> )} /> ); }
1,749
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroupVariants.js
import * as React from 'react'; import Button from '@mui/joy/Button'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; export default function ToggleGroupVariants() { const [value, setValue] = React.useState('plain'); return ( <ToggleButtonGroup variant={value || undefined} value={value} onChange={(event, newValue) => { setValue(newValue); }} > <Button value="plain">plain</Button> <Button value="outlined">outlined</Button> <Button value="soft">soft</Button> <Button value="solid">solid</Button> </ToggleButtonGroup> ); }
1,750
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroupVariants.tsx
import * as React from 'react'; import { VariantProp } from '@mui/joy/styles'; import Button from '@mui/joy/Button'; import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; export default function ToggleGroupVariants() { const [value, setValue] = React.useState<VariantProp | null>('plain'); return ( <ToggleButtonGroup variant={value || undefined} value={value} onChange={(event, newValue) => { setValue(newValue); }} > <Button value="plain">plain</Button> <Button value="outlined">outlined</Button> <Button value="soft">soft</Button> <Button value="solid">solid</Button> </ToggleButtonGroup> ); }
1,751
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/ToggleGroupVariants.tsx.preview
<ToggleButtonGroup variant={value || undefined} value={value} onChange={(event, newValue) => { setValue(newValue); }} > <Button value="plain">plain</Button> <Button value="outlined">outlined</Button> <Button value="soft">soft</Button> <Button value="solid">solid</Button> </ToggleButtonGroup>
1,752
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/toggle-button-group/toggle-button-group.md
--- productId: joy-ui title: React Toggle Button Group component githubLabel: 'component: toggle button' components: ToggleButtonGroup, Button, IconButton --- # Toggle Button Group <p class="description">A group of mutually exclusive buttons.</p> ## Introduction Toggle Button Group provides a way to get mutually exclusive actions closer together by sharing a common container. It controls the selected state of its child buttons when given its own `value` prop. {{"demo": "ToggleGroupUsage.js", "hideToolbar": true, "bg": "gradient"}} ## Basics ```jsx import ToggleButtonGroup from '@mui/joy/ToggleButtonGroup'; ``` Note that Joy UI doesn't provide a Toggle Button component but rather a Toggle Button Group container component. The reason for that is that according to the [WAI ARIA pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/), it's better to use `aria-pressed` on the Button or Icon Button component instead. {{"demo": "ToggleButtons.js"}} That said, when using the Toggle Button Group component, pass a value as an array. When a button within the group is pressed, the Toggle Button Group component triggers the `onChange` prop of it and passes the updated array as a parameter. The Toggle Button Group component uses the same styles as the [Button Group](/joy-ui/react-button-group/) component to ensure a consistent visual connection between all of the Joy UI buttons. {{"demo": "ToggleGroup.js"}} ### Exclusive selection When the value provided to the Toggle Button Group component is not an array, it operates in the exclusive selection mode, which means that only one button can be selected at a single time within the group. {{"demo": "ExclusiveSelection.js"}} ## Customization ### Variants The Toggle Button Group component supports Joy UI's four [global variants](/joy-ui/main-features/global-variants/): `outlined` (default), `plain`, `soft`, and `solid`. {{"demo": "ToggleGroupVariants.js"}} :::info To learn how to add your own variants, check out [Themed components—Extend variants](/joy-ui/customization/themed-components/#extend-variants). Note that you lose the global variants when you add custom variants. ::: ### Sizes The Toggle Button Group component comes in three sizes: `sm`, `md` (default), and `lg`. {{"demo": "ToggleGroupSizes.js"}} :::info To learn how to add custom sizes to the component, check out [Themed components—Extend sizes](/joy-ui/customization/themed-components/#extend-sizes). ::: ### Colors Every palette included in the theme is available via the color prop. {{"demo": "ToggleGroupColors.js"}} ### Spacing By default, there's no spacing between the buttons within a Toggle Button Group. Use the `spacing` prop with a value greater than 0 to separate each button. The spacing is applied using the `gap` CSS property and its value is determined on the theme `theme.spacing(<value>)`). {{"demo": "ToggleGroupSpacing.js"}} To create a responsive spacing scale, the `<value>` can be an object or an array. ```js <ToggleButtonGroup spacing={{ xs: 0, md: 2, lg: 3 }}>…</ToggleButtonGroup> ``` ## Common examples ### Figma-like toggle group Use the CSS variable `--ButtonGroup-connected` to control when border radius of the buttons in-between should be removed. To create a Figma-like button group where the buttons are connected when users hover on any of the buttons, set the `--ButtonGroup-connected` to `0` and change to `1` on hover. {{"demo": "FigmaButtonGroup.js"}} ### Editor toolbar {{"demo": "ToggleGroupToolbar.js"}} ## Accessibility ### ARIA - The Toggle Button Group component has `role="group"`. Make sure to provide an accessible label with `aria-label="label"`, `aria-labelledby="id"` or `<label>`. - For the toggle button, set `aria-pressed="<bool>"` according to the button state. Make sure to label an icon button with `aria-label`. ### Keyboard Buttons within a Toggle Button Group component are in the same order as in the DOM. Use the tab key to navigate them.
1,753
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/AccessibilityTooltip.js
import * as React from 'react'; import DeleteIcon from '@mui/icons-material/Delete'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import Tooltip from '@mui/joy/Tooltip'; import Box from '@mui/joy/Box'; export default function AccessibilityTooltip() { return ( <Box sx={{ display: 'flex', gap: 2, width: '100%', justifyContent: 'center' }}> <Tooltip title="Delete"> <IconButton> <DeleteIcon /> </IconButton> </Tooltip> <Tooltip describeChild title="Does not add if it already exists."> <Button>Add</Button> </Tooltip> </Box> ); }
1,754
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/AccessibilityTooltip.tsx
import * as React from 'react'; import DeleteIcon from '@mui/icons-material/Delete'; import Button from '@mui/joy/Button'; import IconButton from '@mui/joy/IconButton'; import Tooltip from '@mui/joy/Tooltip'; import Box from '@mui/joy/Box'; export default function AccessibilityTooltip() { return ( <Box sx={{ display: 'flex', gap: 2, width: '100%', justifyContent: 'center' }}> <Tooltip title="Delete"> <IconButton> <DeleteIcon /> </IconButton> </Tooltip> <Tooltip describeChild title="Does not add if it already exists."> <Button>Add</Button> </Tooltip> </Box> ); }
1,755
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/AccessibilityTooltip.tsx.preview
<Tooltip title="Delete"> <IconButton> <DeleteIcon /> </IconButton> </Tooltip> <Tooltip describeChild title="Does not add if it already exists."> <Button>Add</Button> </Tooltip>
1,756
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/ArrowTooltips.js
import * as React from 'react'; import Button from '@mui/joy/Button'; import Sheet from '@mui/joy/Sheet'; import Tooltip from '@mui/joy/Tooltip'; export default function ArrowTooltips() { return ( <Sheet sx={{ pr: 7 }}> <Tooltip title="Add" arrow open placement="right"> <Button variant="plain">Arrow</Button> </Tooltip> </Sheet> ); }
1,757
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/ArrowTooltips.tsx
import * as React from 'react'; import Button from '@mui/joy/Button'; import Sheet from '@mui/joy/Sheet'; import Tooltip from '@mui/joy/Tooltip'; export default function ArrowTooltips() { return ( <Sheet sx={{ pr: 7 }}> <Tooltip title="Add" arrow open placement="right"> <Button variant="plain">Arrow</Button> </Tooltip> </Sheet> ); }
1,758
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/ArrowTooltips.tsx.preview
<Sheet sx={{ pr: 7 }}> <Tooltip title="Add" arrow open placement="right"> <Button variant="plain">Arrow</Button> </Tooltip> </Sheet>
1,759
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/GitHubTooltip.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Tooltip from '@mui/joy/Tooltip'; import Typography from '@mui/joy/Typography'; import Link from '@mui/joy/Link'; import Chip from '@mui/joy/Chip'; import AdjustIcon from '@mui/icons-material/Adjust'; export default function GitHubTooltip() { return ( <Tooltip placement="top-end" variant="outlined" arrow title={ <Box sx={{ display: 'flex', flexDirection: 'column', maxWidth: 320, justifyContent: 'center', p: 1, }} > <Typography fontSize="sm" textColor="grey" startDecorator={ <Link underline="always" href="#common-examples" color="neutral" fontSize="sm" > mui/material-ui </Link> } > on Feb 25 </Typography> <Box sx={{ display: 'flex', gap: 1, width: '100%', mt: 1 }}> <AdjustIcon color="success" /> <div> <Typography fontWeight="lg" fontSize="sm"> [system] grey is no more recognized as color with the sx prop </Typography> <Typography textColor="text.secondary" fontSize="sm" sx={{ mb: 1 }}> Duplicates I have searched the existing issues Latest version I have tested the … </Typography> <Chip size="sm" color="danger" sx={{ fontWeight: 'lg' }}> bug 🐛 </Chip> <Chip size="sm" color="primary" sx={{ ml: 1, fontWeight: 'lg' }}> package: system </Chip> </div> </Box> </Box> } > <Link href="#common-examples" underline="none" startDecorator={<AdjustIcon color="success" />} sx={{ fontWeight: 'lg' }} > [system] grey is no more recognized as color with the sx prop </Link> </Tooltip> ); }
1,760
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/GitHubTooltip.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Tooltip from '@mui/joy/Tooltip'; import Typography from '@mui/joy/Typography'; import Link from '@mui/joy/Link'; import Chip from '@mui/joy/Chip'; import AdjustIcon from '@mui/icons-material/Adjust'; export default function GitHubTooltip() { return ( <Tooltip placement="top-end" variant="outlined" arrow title={ <Box sx={{ display: 'flex', flexDirection: 'column', maxWidth: 320, justifyContent: 'center', p: 1, }} > <Typography fontSize="sm" textColor="grey" startDecorator={ <Link underline="always" href="#common-examples" color="neutral" fontSize="sm" > mui/material-ui </Link> } > on Feb 25 </Typography> <Box sx={{ display: 'flex', gap: 1, width: '100%', mt: 1 }}> <AdjustIcon color="success" /> <div> <Typography fontWeight="lg" fontSize="sm"> [system] grey is no more recognized as color with the sx prop </Typography> <Typography textColor="text.secondary" fontSize="sm" sx={{ mb: 1 }}> Duplicates I have searched the existing issues Latest version I have tested the … </Typography> <Chip size="sm" color="danger" sx={{ fontWeight: 'lg' }}> bug 🐛 </Chip> <Chip size="sm" color="primary" sx={{ ml: 1, fontWeight: 'lg' }}> package: system </Chip> </div> </Box> </Box> } > <Link href="#common-examples" underline="none" startDecorator={<AdjustIcon color="success" />} sx={{ fontWeight: 'lg' }} > [system] grey is no more recognized as color with the sx prop </Link> </Tooltip> ); }
1,761
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/PositionedTooltips.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Grid from '@mui/material/Grid'; import Button from '@mui/joy/Button'; import Tooltip from '@mui/joy/Tooltip'; export default function PositionedTooltips() { return ( <Box sx={{ width: 500 }}> <Grid container justifyContent="center"> <Grid item> <Tooltip title="Add" placement="top-start"> <Button variant="plain">top-start</Button> </Tooltip> <Tooltip title="Add" placement="top"> <Button variant="plain">top</Button> </Tooltip> <Tooltip title="Add" placement="top-end"> <Button variant="plain">top-end</Button> </Tooltip> </Grid> </Grid> <Grid container justifyContent="center"> <Grid item xs={6}> <Tooltip title="Add" placement="left-start"> <Button variant="plain">left-start</Button> </Tooltip> <br /> <Tooltip title="Add" placement="left"> <Button variant="plain">left</Button> </Tooltip> <br /> <Tooltip title="Add" placement="left-end"> <Button variant="plain">left-end</Button> </Tooltip> </Grid> <Grid item container xs={6} alignItems="flex-end" direction="column"> <Grid item> <Tooltip title="Add" placement="right-start"> <Button variant="plain">right-start</Button> </Tooltip> </Grid> <Grid item> <Tooltip title="Add" placement="right"> <Button variant="plain">right</Button> </Tooltip> </Grid> <Grid item> <Tooltip title="Add" placement="right-end"> <Button variant="plain">right-end</Button> </Tooltip> </Grid> </Grid> </Grid> <Grid container justifyContent="center"> <Grid item> <Tooltip title="Add" placement="bottom-start"> <Button variant="plain">bottom-start</Button> </Tooltip> <Tooltip title="Add" placement="bottom"> <Button variant="plain">bottom</Button> </Tooltip> <Tooltip title="Add" placement="bottom-end"> <Button variant="plain">bottom-end</Button> </Tooltip> </Grid> </Grid> </Box> ); }
1,762
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/PositionedTooltips.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Grid from '@mui/material/Grid'; import Button from '@mui/joy/Button'; import Tooltip from '@mui/joy/Tooltip'; export default function PositionedTooltips() { return ( <Box sx={{ width: 500 }}> <Grid container justifyContent="center"> <Grid item> <Tooltip title="Add" placement="top-start"> <Button variant="plain">top-start</Button> </Tooltip> <Tooltip title="Add" placement="top"> <Button variant="plain">top</Button> </Tooltip> <Tooltip title="Add" placement="top-end"> <Button variant="plain">top-end</Button> </Tooltip> </Grid> </Grid> <Grid container justifyContent="center"> <Grid item xs={6}> <Tooltip title="Add" placement="left-start"> <Button variant="plain">left-start</Button> </Tooltip> <br /> <Tooltip title="Add" placement="left"> <Button variant="plain">left</Button> </Tooltip> <br /> <Tooltip title="Add" placement="left-end"> <Button variant="plain">left-end</Button> </Tooltip> </Grid> <Grid item container xs={6} alignItems="flex-end" direction="column"> <Grid item> <Tooltip title="Add" placement="right-start"> <Button variant="plain">right-start</Button> </Tooltip> </Grid> <Grid item> <Tooltip title="Add" placement="right"> <Button variant="plain">right</Button> </Tooltip> </Grid> <Grid item> <Tooltip title="Add" placement="right-end"> <Button variant="plain">right-end</Button> </Tooltip> </Grid> </Grid> </Grid> <Grid container justifyContent="center"> <Grid item> <Tooltip title="Add" placement="bottom-start"> <Button variant="plain">bottom-start</Button> </Tooltip> <Tooltip title="Add" placement="bottom"> <Button variant="plain">bottom</Button> </Tooltip> <Tooltip title="Add" placement="bottom-end"> <Button variant="plain">bottom-end</Button> </Tooltip> </Grid> </Grid> </Box> ); }
1,763
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/TooltipColors.js
import * as React from 'react'; import Button from '@mui/joy/Button'; import Tooltip from '@mui/joy/Tooltip'; import Box from '@mui/joy/Box'; import Radio from '@mui/joy/Radio'; import RadioGroup from '@mui/joy/RadioGroup'; import Sheet from '@mui/joy/Sheet'; import Typography from '@mui/joy/Typography'; export default function TooltipColors() { const [variant, setVariant] = React.useState('solid'); return ( <Box sx={{ display: 'flex', alignItems: 'center', gap: 3, }} > <Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(3, minmax(150px, 1fr))', gap: 1, }} > <Tooltip title="Delete" color="primary" placement="top" variant={variant}> <Button variant="plain" color="primary"> Primary </Button> </Tooltip> <Tooltip title="Delete" color="neutral" placement="top" variant={variant}> <Button variant="plain" color="neutral"> Neutral </Button> </Tooltip> <Tooltip title="Delete" color="danger" placement="top" variant={variant}> <Button variant="plain" color="danger"> Danger </Button> </Tooltip> <Tooltip title="Delete" color="success" variant={variant}> <Button variant="plain" color="success"> Success </Button> </Tooltip> <Tooltip title="Delete" color="warning" variant={variant}> <Button variant="plain" color="warning"> Warning </Button> </Tooltip> </Box> <Sheet sx={{ background: 'transparent', pl: 4, borderLeft: '1px solid', borderColor: 'divider', }} > <Typography level="body-sm" fontWeight="xl" id="variant-label" textColor="text.primary" mb={1} > Variant: </Typography> <RadioGroup size="sm" aria-labelledby="variant-label" name="variant" value={variant} onChange={(event) => setVariant(event.target.value)} > <Radio label="Solid" value="solid" /> <Radio label="Soft" value="soft" /> <Radio label="Outlined" value="outlined" /> <Radio label="Plain" value="plain" /> </RadioGroup> </Sheet> </Box> ); }
1,764
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/TooltipColors.tsx
import * as React from 'react'; import Button from '@mui/joy/Button'; import Tooltip from '@mui/joy/Tooltip'; import Box from '@mui/joy/Box'; import Radio from '@mui/joy/Radio'; import RadioGroup from '@mui/joy/RadioGroup'; import Sheet from '@mui/joy/Sheet'; import Typography from '@mui/joy/Typography'; import { VariantProp } from '@mui/joy/styles'; export default function TooltipColors() { const [variant, setVariant] = React.useState<VariantProp>('solid'); return ( <Box sx={{ display: 'flex', alignItems: 'center', gap: 3, }} > <Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(3, minmax(150px, 1fr))', gap: 1, }} > <Tooltip title="Delete" color="primary" placement="top" variant={variant}> <Button variant="plain" color="primary"> Primary </Button> </Tooltip> <Tooltip title="Delete" color="neutral" placement="top" variant={variant}> <Button variant="plain" color="neutral"> Neutral </Button> </Tooltip> <Tooltip title="Delete" color="danger" placement="top" variant={variant}> <Button variant="plain" color="danger"> Danger </Button> </Tooltip> <Tooltip title="Delete" color="success" variant={variant}> <Button variant="plain" color="success"> Success </Button> </Tooltip> <Tooltip title="Delete" color="warning" variant={variant}> <Button variant="plain" color="warning"> Warning </Button> </Tooltip> </Box> <Sheet sx={{ background: 'transparent', pl: 4, borderLeft: '1px solid', borderColor: 'divider', }} > <Typography level="body-sm" fontWeight="xl" id="variant-label" textColor="text.primary" mb={1} > Variant: </Typography> <RadioGroup size="sm" aria-labelledby="variant-label" name="variant" value={variant} onChange={(event) => setVariant(event.target.value as VariantProp)} > <Radio label="Solid" value="solid" /> <Radio label="Soft" value="soft" /> <Radio label="Outlined" value="outlined" /> <Radio label="Plain" value="plain" /> </RadioGroup> </Sheet> </Box> ); }
1,765
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/TooltipSizes.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Tooltip from '@mui/joy/Tooltip'; import Button from '@mui/joy/Button'; export default function TooltipSizes() { return ( <Box sx={{ display: 'flex', gap: 4, width: '100%', justifyContent: 'center' }}> <Tooltip title="Delete" size="sm"> <Button variant="plain">Small</Button> </Tooltip> <Tooltip title="Delete" size="md"> <Button variant="plain">Medium</Button> </Tooltip> <Tooltip title="Delete" size="lg"> <Button variant="plain">Large</Button> </Tooltip> </Box> ); }
1,766
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/TooltipSizes.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Tooltip from '@mui/joy/Tooltip'; import Button from '@mui/joy/Button'; export default function TooltipSizes() { return ( <Box sx={{ display: 'flex', gap: 4, width: '100%', justifyContent: 'center' }}> <Tooltip title="Delete" size="sm"> <Button variant="plain">Small</Button> </Tooltip> <Tooltip title="Delete" size="md"> <Button variant="plain">Medium</Button> </Tooltip> <Tooltip title="Delete" size="lg"> <Button variant="plain">Large</Button> </Tooltip> </Box> ); }
1,767
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/TooltipSizes.tsx.preview
<Tooltip title="Delete" size="sm"> <Button variant="plain">Small</Button> </Tooltip> <Tooltip title="Delete" size="md"> <Button variant="plain">Medium</Button> </Tooltip> <Tooltip title="Delete" size="lg"> <Button variant="plain">Large</Button> </Tooltip>
1,768
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/TooltipUsage.js
import * as React from 'react'; import DeleteIcon from '@mui/icons-material/Delete'; import IconButton from '@mui/joy/IconButton'; import Tooltip from '@mui/joy/Tooltip'; import JoyUsageDemo from 'docs/src/modules/components/JoyUsageDemo'; export default function TooltipUsage() { return ( <JoyUsageDemo componentName="Tooltip" data={[ { propName: 'variant', knob: 'radio', defaultValue: 'solid', options: ['plain', 'outlined', 'soft', 'solid'], }, { propName: 'color', knob: 'color', defaultValue: 'neutral', }, { propName: 'size', knob: 'radio', options: ['sm', 'md', 'lg'], defaultValue: 'md', }, { propName: 'open', knob: 'controlled', }, { propName: 'placement', knob: 'placement', defaultValue: 'bottom', }, { propName: 'arrow', knob: 'switch', defaultValue: false, }, ]} renderDemo={({ open, ...props }) => ( <React.Fragment> {open === undefined && ( <Tooltip title="This is a tooltip" {...props}> <IconButton size="lg" variant="soft" color="neutral"> <DeleteIcon /> </IconButton> </Tooltip> )} {typeof open === 'boolean' && ( <Tooltip title="This is a tooltip" open={open} {...props}> <IconButton size="lg" variant="soft" color="neutral"> <DeleteIcon /> </IconButton> </Tooltip> )} </React.Fragment> )} /> ); }
1,769
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/TooltipVariants.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Tooltip from '@mui/joy/Tooltip'; import Button from '@mui/joy/Button'; export default function TooltipVariants() { return ( <Box sx={{ display: 'flex', gap: 4, width: '100%', justifyContent: 'center' }}> <Tooltip title="Delete" variant="solid"> <Button variant="solid">Solid</Button> </Tooltip> <Tooltip title="Delete" variant="soft"> <Button variant="soft">Soft</Button> </Tooltip> <Tooltip title="Delete" variant="outlined"> <Button variant="outlined">Outlined</Button> </Tooltip> <Tooltip title="Delete" variant="plain"> <Button variant="plain">Plain</Button> </Tooltip> </Box> ); }
1,770
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/TooltipVariants.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Tooltip from '@mui/joy/Tooltip'; import Button from '@mui/joy/Button'; export default function TooltipVariants() { return ( <Box sx={{ display: 'flex', gap: 4, width: '100%', justifyContent: 'center' }}> <Tooltip title="Delete" variant="solid"> <Button variant="solid">Solid</Button> </Tooltip> <Tooltip title="Delete" variant="soft"> <Button variant="soft">Soft</Button> </Tooltip> <Tooltip title="Delete" variant="outlined"> <Button variant="outlined">Outlined</Button> </Tooltip> <Tooltip title="Delete" variant="plain"> <Button variant="plain">Plain</Button> </Tooltip> </Box> ); }
1,771
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/TooltipVariants.tsx.preview
<Tooltip title="Delete" variant="solid"> <Button variant="solid">Solid</Button> </Tooltip> <Tooltip title="Delete" variant="soft"> <Button variant="soft">Soft</Button> </Tooltip> <Tooltip title="Delete" variant="outlined"> <Button variant="outlined">Outlined</Button> </Tooltip> <Tooltip title="Delete" variant="plain"> <Button variant="plain">Plain</Button> </Tooltip>
1,772
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/tooltip/tooltip.md
--- productId: joy-ui title: React Tooltip component components: Tooltip githubLabel: 'component: tooltip' waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/ --- # Tooltip <p class="description">Tooltips display informative text when users hover over, focus on, or tap an element.</p> {{"component": "modules/components/ComponentLinkHeader.js"}} ## Introduction {{"demo": "TooltipUsage.js", "hideToolbar": true, "bg": "gradient"}} ## Component After [installation](/joy-ui/getting-started/installation/), you can start building with this component using the following basic elements: ```jsx import Tooltip from '@mui/joy/Tooltip'; export default function MyApp() { return <Tooltip />; } ``` ### Variants The tooltip component supports the four global variants: `solid` (default), `soft`, `outlined` and `plain`. {{"demo": "TooltipVariants.js"}} ### Colors Every palette included in the theme is available via the `color` prop. Play around combining different colors with different variants. {{"demo": "TooltipColors.js"}} ### Sizes The tooltip component comes with three sizes out of the box: `sm`, `md` (the default), and `lg`. {{"demo": "TooltipSizes.js"}} ## Positioned tooltips The `Tooltip` has 12 **placement** choices. They don't have directional arrows; instead, they rely on motion emanating from the source to convey direction. {{"demo": "PositionedTooltips.js"}} ## Arrow tooltips You can use the `arrow` prop to give your tooltip an arrow indicating which element it refers to. {{"demo": "ArrowTooltips.js"}} ## Common examples ### GitHub tooltip The `title` prop can receive a custom React element. {{"demo": "GitHubTooltip.js"}} ## Accessibility (WAI-ARIA: https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/) By default, the tooltip only labels its child element. This is notably different from `title` which can either label **or** describe its child depending on whether the child already has a label. For example, in: ```html <button title="some more information">A button</button> ``` the `title` acts as an accessible description. If you want the tooltip to act as an accessible description you can pass `describeChild`. Note that you shouldn't use `describeChild` if the tooltip provides the only visual label. Otherwise, the child would have no accessible name and the tooltip would violate [success criterion 2.5.3 in WCAG 2.1](https://www.w3.org/WAI/WCAG21/Understanding/label-in-name.html). {{"demo": "AccessibilityTooltip.js"}}
1,773
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/DecoratorExamples.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Typography from '@mui/joy/Typography'; import SvgIcon from '@mui/joy/SvgIcon'; import InfoOutlined from '@mui/icons-material/InfoOutlined'; export default function DecoratorExamples() { return ( <Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 2 }} > <Typography startDecorator={ <Box component="span" sx={{ bgcolor: 'neutral.400', width: '0.5em', height: '0.5em', borderRadius: '50%', }} /> } > Inactive </Typography> <Typography fontSize="xl4" lineHeight={1} startDecorator={ <Typography fontSize="lg" textColor="text.secondary"> $ </Typography> } sx={{ alignItems: 'flex-start' }} > 25 </Typography> <Typography level="body-sm" startDecorator={<InfoOutlined />} sx={{ alignItems: 'flex-start', maxWidth: 240, wordBreak: 'break-all' }} > This example demonstrates multiple lines of the text. </Typography> <Typography variant="soft" color="danger" startDecorator="🚨" fontSize="sm" sx={{ '--Typography-gap': '0.5rem', p: 1 }} > Simple alert using only Typography. </Typography> <Typography color="success"> <SvgIcon fontSize="md" sx={{ m: '-2px', mr: '2px' }}> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" > <path strokeLinecap="round" strokeLinejoin="round" d="M4.5 10.5L12 3m0 0l7.5 7.5M12 3v18" /> </svg> </SvgIcon> +8.2% <Typography level="body-xs" sx={{ ml: 1 }}> Since last month </Typography> </Typography> </Box> ); }
1,774
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/DecoratorExamples.tsx
import * as React from 'react'; import Box from '@mui/joy/Box'; import Typography from '@mui/joy/Typography'; import SvgIcon from '@mui/joy/SvgIcon'; import InfoOutlined from '@mui/icons-material/InfoOutlined'; export default function DecoratorExamples() { return ( <Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 2 }} > <Typography startDecorator={ <Box component="span" sx={{ bgcolor: 'neutral.400', width: '0.5em', height: '0.5em', borderRadius: '50%', }} /> } > Inactive </Typography> <Typography fontSize="xl4" lineHeight={1} startDecorator={ <Typography fontSize="lg" textColor="text.secondary"> $ </Typography> } sx={{ alignItems: 'flex-start' }} > 25 </Typography> <Typography level="body-sm" startDecorator={<InfoOutlined />} sx={{ alignItems: 'flex-start', maxWidth: 240, wordBreak: 'break-all' }} > This example demonstrates multiple lines of the text. </Typography> <Typography variant="soft" color="danger" startDecorator="🚨" fontSize="sm" sx={{ '--Typography-gap': '0.5rem', p: 1 }} > Simple alert using only Typography. </Typography> <Typography color="success"> <SvgIcon fontSize="md" sx={{ m: '-2px', mr: '2px' }}> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" > <path strokeLinecap="round" strokeLinejoin="round" d="M4.5 10.5L12 3m0 0l7.5 7.5M12 3v18" /> </svg> </SvgIcon> +8.2% <Typography level="body-xs" sx={{ ml: 1 }}> Since last month </Typography> </Typography> </Box> ); }
1,775
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/NestedTypography.js
import * as React from 'react'; import Typography from '@mui/joy/Typography'; export default function NestedTypography() { return ( <Typography maxWidth={400}> Typography lets you create <Typography variant="soft">nested</Typography>{' '} typography. Use your{' '} <Typography variant="outlined" color="success"> imagination </Typography>{' '} to build wonderful{' '} <Typography variant="solid" color="primary" noWrap> user interface </Typography> . </Typography> ); }
1,776
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/NestedTypography.tsx
import * as React from 'react'; import Typography from '@mui/joy/Typography'; export default function NestedTypography() { return ( <Typography maxWidth={400}> Typography lets you create <Typography variant="soft">nested</Typography>{' '} typography. Use your{' '} <Typography variant="outlined" color="success"> imagination </Typography>{' '} to build wonderful{' '} <Typography variant="solid" color="primary" noWrap> user interface </Typography> . </Typography> ); }
1,777
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/NestedTypography.tsx.preview
<Typography maxWidth={400}> Typography lets you create <Typography variant="soft">nested</Typography>{' '} typography. Use your{' '} <Typography variant="outlined" color="success"> imagination </Typography>{' '} to build wonderful{' '} <Typography variant="solid" color="primary" noWrap> user interface </Typography> . </Typography>
1,778
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyBasics.js
import * as React from 'react'; import Card from '@mui/joy/Card'; import Typography from '@mui/joy/Typography'; export default function TypographyBasics() { return ( <Card variant="outlined" sx={{ maxWidth: 400 }}> <Typography level="h1">National Parks</Typography> <Typography level="h2" fontSize="xl" sx={{ mb: 0.5 }}> Yosemite National Park </Typography> <Typography> Yosemite National Park is a national park spanning 747,956 acres (1,169.4 sq mi; 3,025.2 km2) in the western Sierra Nevada of Central California. </Typography> </Card> ); }
1,779
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyBasics.tsx
import * as React from 'react'; import Card from '@mui/joy/Card'; import Typography from '@mui/joy/Typography'; export default function TypographyBasics() { return ( <Card variant="outlined" sx={{ maxWidth: 400 }}> <Typography level="h1">National Parks</Typography> <Typography level="h2" fontSize="xl" sx={{ mb: 0.5 }}> Yosemite National Park </Typography> <Typography> Yosemite National Park is a national park spanning 747,956 acres (1,169.4 sq mi; 3,025.2 km2) in the western Sierra Nevada of Central California. </Typography> </Card> ); }
1,780
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyBasics.tsx.preview
<Card variant="outlined" sx={{ maxWidth: 400 }}> <Typography level="h1">National Parks</Typography> <Typography level="h2" fontSize="xl" sx={{ mb: 0.5 }}> Yosemite National Park </Typography> <Typography> Yosemite National Park is a national park spanning 747,956 acres (1,169.4 sq mi; 3,025.2 km2) in the western Sierra Nevada of Central California. </Typography> </Card>
1,781
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyDecorators.js
import * as React from 'react'; import Typography from '@mui/joy/Typography'; import Chip from '@mui/joy/Chip'; import InfoOutlined from '@mui/icons-material/InfoOutlined'; export default function TypographyDecorators() { return ( <div> <Typography startDecorator={<InfoOutlined />} mb={2}> The icon automatically adjusts to the scale </Typography> <Typography level="body-lg" endDecorator={ <Chip component="span" size="sm"> 123 </Chip> } justifyContent="center" > The display also changes to flexbox </Typography> </div> ); }
1,782
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyDecorators.tsx
import * as React from 'react'; import Typography from '@mui/joy/Typography'; import Chip from '@mui/joy/Chip'; import InfoOutlined from '@mui/icons-material/InfoOutlined'; export default function TypographyDecorators() { return ( <div> <Typography startDecorator={<InfoOutlined />} mb={2}> The icon automatically adjusts to the scale </Typography> <Typography level="body-lg" endDecorator={ <Chip component="span" size="sm"> 123 </Chip> } justifyContent="center" > The display also changes to flexbox </Typography> </div> ); }
1,783
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyDecorators.tsx.preview
<Typography startDecorator={<InfoOutlined />} mb={2}> The icon automatically adjusts to the scale </Typography> <Typography level="body-lg" endDecorator={ <Chip component="span" size="sm"> 123 </Chip> } justifyContent="center" > The display also changes to flexbox </Typography>
1,784
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyHeadline.js
import * as React from 'react'; import Stack from '@mui/joy/Stack'; import Typography from '@mui/joy/Typography'; export default function TypographyHeadline() { return ( <Stack spacing={1.5}> <Typography level="h1">h1: Lorem ipsum</Typography> <Typography level="h2">h2: What is Lorem Ipsum?</Typography> <Typography level="h3">h3: The standard Lorem Ipsum passage.</Typography> <Typography level="h4">h4: The smallest headline of the page</Typography> </Stack> ); }
1,785
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyHeadline.tsx
import * as React from 'react'; import Stack from '@mui/joy/Stack'; import Typography from '@mui/joy/Typography'; export default function TypographyHeadline() { return ( <Stack spacing={1.5}> <Typography level="h1">h1: Lorem ipsum</Typography> <Typography level="h2">h2: What is Lorem Ipsum?</Typography> <Typography level="h3">h3: The standard Lorem Ipsum passage.</Typography> <Typography level="h4">h4: The smallest headline of the page</Typography> </Stack> ); }
1,786
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyHeadline.tsx.preview
<Typography level="h1">h1: Lorem ipsum</Typography> <Typography level="h2">h2: What is Lorem Ipsum?</Typography> <Typography level="h3">h3: The standard Lorem Ipsum passage.</Typography> <Typography level="h4">h4: The smallest headline of the page</Typography>
1,787
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyScales.js
import * as React from 'react'; import Typography from '@mui/joy/Typography'; export default function TypographyScales() { return ( <div> <Typography level="h1">h1</Typography> <Typography level="h2">h2</Typography> <Typography level="h3">h3</Typography> <Typography level="h4">h4</Typography> <Typography level="title-lg">title-lg</Typography> <Typography level="title-md">title-md</Typography> <Typography level="title-sm">title-sm</Typography> <Typography level="body-lg">body-lg</Typography> <Typography level="body-md">body-md</Typography> <Typography level="body-sm">body-sm</Typography> <Typography level="body-xs">body-xs</Typography> </div> ); }
1,788
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyScales.tsx
import * as React from 'react'; import Typography from '@mui/joy/Typography'; export default function TypographyScales() { return ( <div> <Typography level="h1">h1</Typography> <Typography level="h2">h2</Typography> <Typography level="h3">h3</Typography> <Typography level="h4">h4</Typography> <Typography level="title-lg">title-lg</Typography> <Typography level="title-md">title-md</Typography> <Typography level="title-sm">title-sm</Typography> <Typography level="body-lg">body-lg</Typography> <Typography level="body-md">body-md</Typography> <Typography level="body-sm">body-sm</Typography> <Typography level="body-xs">body-xs</Typography> </div> ); }
1,789
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyScales.tsx.preview
<Typography level="h1">h1</Typography> <Typography level="h2">h2</Typography> <Typography level="h3">h3</Typography> <Typography level="h4">h4</Typography> <Typography level="title-lg">title-lg</Typography> <Typography level="title-md">title-md</Typography> <Typography level="title-sm">title-sm</Typography> <Typography level="body-lg">body-lg</Typography> <Typography level="body-md">body-md</Typography> <Typography level="body-sm">body-sm</Typography> <Typography level="body-xs">body-xs</Typography>
1,790
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyTitleBody.js
import * as React from 'react'; import Typography from '@mui/joy/Typography'; import Card from '@mui/joy/Card'; import Stack from '@mui/joy/Stack'; export default function TypographyTitleBody() { return ( <Stack spacing={2} sx={{ maxWidth: '60ch', }} > <Card> <Typography level="title-lg"> Title of the component{' '} <Typography level="title-lg" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > title-lg </Typography> </Typography> <Typography level="body-md"> This is the description of the component that contain some information of it.{' '} <Typography level="body-md" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > body-md </Typography> </Typography> </Card> <Card> <Typography level="title-md"> Title of the component{' '} <Typography level="title-md" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > title-md </Typography> </Typography> <Typography level="body-md"> This is the description of the component that contain some information of it.{' '} <Typography level="body-md" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > body-md </Typography> </Typography> <Typography level="body-sm"> Metadata, e.g. a date.{' '} <Typography level="body-sm" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > body-sm </Typography> </Typography> </Card> <Card> <Typography level="title-sm"> Title of the component{' '} <Typography level="title-sm" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > title-sm </Typography> </Typography> <Typography level="body-sm"> This is the description of the component that contain some information of it.{' '} <Typography level="body-sm" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > body-sm </Typography> </Typography> <Typography level="body-xs"> Metadata, e.g. a date.{' '} <Typography level="body-xs" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > body-xs </Typography> </Typography> </Card> </Stack> ); }
1,791
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyTitleBody.tsx
import * as React from 'react'; import Typography from '@mui/joy/Typography'; import Card from '@mui/joy/Card'; import Stack from '@mui/joy/Stack'; export default function TypographyTitleBody() { return ( <Stack spacing={2} sx={{ maxWidth: '60ch', }} > <Card> <Typography level="title-lg"> Title of the component{' '} <Typography level="title-lg" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > title-lg </Typography> </Typography> <Typography level="body-md"> This is the description of the component that contain some information of it.{' '} <Typography level="body-md" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > body-md </Typography> </Typography> </Card> <Card> <Typography level="title-md"> Title of the component{' '} <Typography level="title-md" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > title-md </Typography> </Typography> <Typography level="body-md"> This is the description of the component that contain some information of it.{' '} <Typography level="body-md" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > body-md </Typography> </Typography> <Typography level="body-sm"> Metadata, e.g. a date.{' '} <Typography level="body-sm" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > body-sm </Typography> </Typography> </Card> <Card> <Typography level="title-sm"> Title of the component{' '} <Typography level="title-sm" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > title-sm </Typography> </Typography> <Typography level="body-sm"> This is the description of the component that contain some information of it.{' '} <Typography level="body-sm" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > body-sm </Typography> </Typography> <Typography level="body-xs"> Metadata, e.g. a date.{' '} <Typography level="body-xs" textColor="var(--joy-palette-success-plainColor)" fontFamily="monospace" sx={{ opacity: '50%' }} > body-xs </Typography> </Typography> </Card> </Stack> ); }
1,792
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/TypographyUsage.js
import * as React from 'react'; import Box from '@mui/joy/Box'; import Typography from '@mui/joy/Typography'; import JoyUsageDemo from 'docs/src/modules/components/JoyUsageDemo'; export default function TypographyUsage() { return ( <JoyUsageDemo componentName="Typography" data={[ { propName: 'level', knob: 'select', defaultValue: 'h1', options: [ 'h1', 'h2', 'h3', 'h4', 'title-lg', 'title-md', 'title-sm', 'body-lg', 'body-md', 'body-sm', 'body-xs', ], }, { propName: 'color', knob: 'color', }, { propName: 'variant', knob: 'radio', options: ['plain', 'outlined', 'soft', 'solid'], }, { propName: 'children', knob: 'input', defaultValue: 'Lorem ipsum is placeholder text commonly used in the graphic, print, and publishing industries for previewing layouts and visual mockups.', }, { propName: 'noWrap', knob: 'switch', defaultValue: false, }, ]} renderDemo={(props) => ( <Box sx={{ maxWidth: '400px' }}> <Typography {...props} sx={ !props.noWrap && { overflow: 'hidden', display: '-webkit-box', '-webkit-line-clamp': '3', '-webkit-box-orient': 'vertical', } } > {props.children} </Typography> </Box> )} /> ); }
1,793
0
petrpan-code/mui/material-ui/docs/data/joy/components
petrpan-code/mui/material-ui/docs/data/joy/components/typography/typography.md
--- productId: joy-ui title: React Typography component components: Typography githubLabel: 'component: Typography' --- # Typography <p class="description">The Typography component helps present design and content clearly and efficiently.</p> ## Introduction The Typography component helps maintain a consistent design by providing a limited set of values to choose from and convenient props for building common designs faster. {{"demo": "TypographyUsage.js", "hideToolbar": true, "bg": "gradient"}} ## Basics ```jsx import Typography from '@mui/joy/Typography'; ``` The Typography component wraps around its content, and displays text with specific typographic styles and properties. {{"demo": "TypographyBasics.js"}} ### Heading Use `h1` through `h4` to render a headline. The produced HTML element will match the semantic [headings](https://www.w3.org/WAI/tutorials/page-structure/headings/) of the page structure. {{"demo": "TypographyHeadline.js"}} :::info The `h5` and `h6` levels are not provided by default given that they are not commonly used. However, you can add them by [customizing the theme's typography](#typography-scale). ::: ### Title and body Aside from the heading typographic levels, the Typography component also provides the `title-*` and `body-*` type levels. To ensure proper information hierarchy, we recommend combining them using either the same size or a lower one. For example, using `title-lg` with `body-lg` or `title-md` with `body-sm`. {{"demo": "TypographyTitleBody.js"}} ### Nested Typography The Typography component renders as a `<p>` by default. Nested Typography components are rendered as `<span>` elements (unless customized by [the `component` prop](#semantic-elements)). {{"demo": "NestedTypography.js"}} ## Customization ### System props As a CSS utility component, Typography supports every [MUI System](/system/properties/) property. These properties can be used to customize the styling of the component and make it fit seamlessly with the overall design. :::warning Note that the `color` prop is an exception, it refers to the palette instead of the text color specifically. To set the text color, use the `textColor` prop. ::: ```jsx // Using the neutral color palette that defaults to the 500 value <Typography color="neutral" fontSize="sm" fontWeight="lg" /> // Changing the specific element's color to neutral <Typography textColor="neutral.300" fontSize="sm" fontWeight="lg" > ``` ### Levels The `level` prop gives access to a pre-defined scale of typographic values defined in the theme. These values include various heading levels (h1, h2, h3, etc.) as well as body text levels (body-md, body-sm, etc) and can be used to apply consistent typography throughout your application. Additionally, you can also use the level prop to control the font size, weight, line height, and other typographic properties. :::warning Keep in mind that each level renders a specific HTML tag (e.g. "h1" renders as an `<h1>` element, "body-md" renders as a `<p>`, etc.) ::: {{"demo": "TypographyScales.js"}} ### Semantic elements To customize the semantic element used, you can use the `component` prop. This can be useful in situations where you want to use a different semantic element than the one assigned by the `level` prop. The component will render as the HTML element defined by `component`, but with the styles assigned to its respective `level`. ```jsx // There's already an h1 on the page so let's not add another one. <Typography level="h1" component="h2"> I render as an h2, but I have h1 styles </Typography> ``` In a more efficient way, you can change the HTML mapping tags at the theme level. ```js const theme = extendTheme({ components: { JoyTypography: { defaultProps: { levelMapping: { h1: 'h2', h2: 'h2', h3: 'h3', h4: 'h3', 'title-lg': 'p', 'title-md': 'p', 'title-sm': 'p', 'body-md': 'p', 'body-sm': 'p', 'body-xs': 'span', }, }, }, }, }); ``` ### Decorators Use the `startDecorator` and `endDecorator` props to add supporting icons or elements to the Typography. {{"demo": "TypographyDecorators.js"}} ### Typography scale To create a custom typographic scale, you can define the keys and values in the `theme.typography` node at the theme level. ```js extendTheme({ typography: { subtitle: { fontSize: 'var(--joy-fontSize-lg)', fontWeight: 'var(--joy-fontWeight-md)', // CSS selectors are also supported! '& + p': { marginTop: '4px', }, }, label: { fontSize: 'var(--joy-fontSize-sm)', fontWeight: 'var(--joy-fontWeight-lg)', lineHeight: 'var(--joy-lineHeight-lg)', marginBottom: '3px', }, }, }); ``` You can also access the newly created levels from the `level` prop: ```js <Typography level="subtitle"> <Typography level="label"> ``` :::warning When using TypeScript, make sure to add module augmentation for the new theme values. ```ts // in your theme or index file declare module '@mui/joy/styles' { interface TypographySystemOverrides { subtitle: true; label: true; } } ``` ::: #### Removing the default scale To remove any unused typographic levels (for example, if you're building your own fully custom scale), you can clear the built-in values by assigning `undefined` to them in the theme. ```js extendTheme({ typography: { h1: undefined, h2: undefined, h3: undefined, h4: undefined, 'title-lg': undefined, 'title-md': undefined, 'title-sm': undefined, 'body-lg': undefined, 'body-md': undefined, 'body-sm': undefined, 'body-xs': undefined, // ...your scale }, }); ``` When using TypeScript, be sure to also remove the built-in typography tokens from the types. ```ts // in your theme or index file declare module '@mui/joy/styles' { interface TypographySystemOverrides { h1: false; h2: false; h3: false; h4: false; 'title-lg': false; 'title-md': false; 'title-sm': false; 'body-lg': false; 'body-md': false; 'body-sm': false; 'body-xs': false; } } ``` ## Common examples The demo below illustrates multiple uses of the Typography component with others as [decorators](#decorators). {{"demo": "DecoratorExamples.js"}} ## Accessibility Here are some factors to ensure that your Typography components are accessible: - Ensure sufficient color contrast between text and background, using a minimum of [WCAG 2.0's color contrast ratio](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html) of 4.5:1. - Use [relative units](/material-ui/customization/typography/#font-size) such as rem for `fontSize` to accommodate the user's settings. - Use a consistent [heading hierarchy](https://www.w3.org/WAI/tutorials/page-structure/headings/), and avoid skipping levels. - Keep semantics and style separate by using the appropriate semantic elements(#semantic-elements). ## Anatomy The Typography component is composed of a single root `<p>` that's assigned the `body-md` class, unless these defaults are overridden by the [`level`](#levels) and/or [`component`](#semantic-elements) props. When one Typography component is nested within another, the nested component renders as a `<span>` (unless customized as described above). ```html <p class="MuiTypography-root MuiTypography-body-md"> <!-- Typography content --> <span class="MuiTypography-root MuiTypography-inherit"> <!-- Nested Typography content --> </span> </p> ```
1,794
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/approaches/ButtonThemes.js
import * as React from 'react'; import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import FormLabel from '@mui/joy/FormLabel'; import Select from '@mui/joy/Select'; import Option from '@mui/joy/Option'; import HighlightedCode from 'docs/src/modules/components/HighlightedCode'; import BrandingProvider from 'docs/src/BrandingProvider'; const githubTheme = extendTheme({ cssVarPrefix: 'gh', colorSchemes: { light: { palette: { success: { solidBg: '#2DA44E', solidHoverBg: '#2C974B', solidActiveBg: '#298E46', }, neutral: { outlinedBg: '#F6F8FA', outlinedHoverBg: '#F3F4F6', outlinedActiveBg: 'rgba(238, 239, 242, 1)', outlinedBorder: 'rgba(27, 31, 36, 0.15)', }, focusVisible: 'rgba(3, 102, 214, 0.3)', }, }, }, focus: { default: { outlineWidth: '3px', }, }, fontFamily: { body: 'SF Pro Text, var(--gh-fontFamily-fallback)', }, components: { JoyButton: { styleOverrides: { root: ({ ownerState }) => ({ borderRadius: '6px', boxShadow: '0 1px 0 0 rgba(27, 31, 35, 0.04)', transition: '80ms cubic-bezier(0.33, 1, 0.68, 1)', transitionProperty: 'color,background-color,box-shadow,border-color', ...(ownerState.size === 'md' && { fontWeight: 600, minHeight: '32px', fontSize: '14px', '--Button-paddingInline': '1rem', }), ...(ownerState.color === 'success' && ownerState.variant === 'solid' && { '--gh-palette-focusVisible': 'rgba(46, 164, 79, 0.4)', border: '1px solid rgba(27, 31, 36, 0.15)', '&:active': { boxShadow: 'inset 0px 1px 0px rgba(20, 70, 32, 0.2)', }, }), ...(ownerState.color === 'neutral' && ownerState.variant === 'outlined' && { '&:active': { boxShadow: 'none', }, }), }), }, }, }, }); const githubCode = `const githubTheme = extendTheme({ colorSchemes: { light: { palette: { success: { solidBg: '#2DA44E', solidHoverBg: '#2C974B', solidActiveBg: '#298E46', }, neutral: { outlinedBg: '#F6F8FA', outlinedHoverBg: '#F3F4F6', outlinedActiveBg: 'rgba(238, 239, 242, 1)', outlinedBorder: 'rgba(27, 31, 36, 0.15)', }, focusVisible: 'rgba(3, 102, 214, 0.3)', }, }, }, focus: { default: { outlineWidth: '3px', }, }, fontFamily: { body: 'SF Pro Text, var(--gh-fontFamily-fallback)', }, components: { JoyButton: { styleOverrides: { root: ({ ownerState }) => ({ borderRadius: '6px', boxShadow: '0 1px 0 0 rgba(27, 31, 35, 0.04)', transition: '80ms cubic-bezier(0.33, 1, 0.68, 1)', transitionProperty: 'color,background-color,box-shadow,border-color', ...(ownerState.size === 'md' && { fontWeight: 600, minHeight: '32px', fontSize: '14px', '--Button-paddingInline': '1rem', }), ...(ownerState.color === 'success' && ownerState.variant === 'solid' && { '--gh-palette-focusVisible': 'rgba(46, 164, 79, 0.4)', border: '1px solid rgba(27, 31, 36, 0.15)', '&:active': { boxShadow: 'inset 0px 1px 0px rgba(20, 70, 32, 0.2)', }, }), ...(ownerState.color === 'neutral' && ownerState.variant === 'outlined' && { '&:active': { boxShadow: 'none', }, }), }), }, }, }, });`; const fluentTheme = extendTheme({ cssVarPrefix: 'fluent', colorSchemes: { light: { palette: { primary: { solidBg: '#0078D4', solidHoverBg: '#106EBE', solidActiveBg: '#005A9E', solidDisabledBg: '#F3F2F1', solidDisabledColor: '#A19F9D', }, neutral: { outlinedBg: '#fff', outlinedColor: '#201F1E', outlinedDisabledBg: '#F3F2F1', outlinedDisabledColor: '#A19F9D', outlinedDisabledBorder: '#C8C6C4', outlinedBorder: '#8A8886', outlinedHoverBg: '#F3F2F1', outlinedHoverBorder: undefined, outlinedActiveBg: '#EDEBE9', }, focusVisible: '#323130', }, }, }, focus: { default: { outlineOffset: -1, outlineWidth: '1px', }, }, fontFamily: { body: '"Segoe UI Variable", var(--fluent-fontFamily-fallback)', }, components: { JoyButton: { styleOverrides: { root: ({ ownerState }) => ({ '--Button-iconOffsetStep': 0, ...(ownerState.variant === 'solid' && { '&.Mui-focusVisible, &:focus-visible': { outlineOffset: '-3px', outlineColor: '#fff', }, }), ...(ownerState.variant === 'outlined' && { '&.Mui-focusVisible, &:focus-visible': { outlineOffset: '-3px', }, }), ...(ownerState.size === 'md' && { '--Icon-fontSize': '20px', fontSize: '14px', fontWeight: 600, minHeight: '32px', borderRadius: '2px', paddingLeft: 20, paddingRight: 20, }), }), }, }, }, }); const fluentCode = `const fluentTheme = extendTheme({ colorSchemes: { light: { palette: { primary: { solidBg: '#0078D4', solidHoverBg: '#106EBE', solidActiveBg: '#005A9E', solidDisabledBg: '#F3F2F1', solidDisabledColor: '#A19F9D', }, neutral: { outlinedBg: '#fff', outlinedColor: '#201F1E', outlinedDisabledBg: '#F3F2F1', outlinedDisabledColor: '#A19F9D', outlinedDisabledBorder: '#C8C6C4', outlinedBorder: '#8A8886', outlinedHoverBg: '#F3F2F1', outlinedHoverBorder: undefined, outlinedActiveBg: '#EDEBE9', }, focusVisible: '#323130', }, }, }, focus: { default: { outlineOffset: -1, outlineWidth: '1px', }, }, fontFamily: { body: '"Segoe UI Variable", var(--fluent-fontFamily-fallback)', }, components: { JoyButton: { styleOverrides: { root: ({ ownerState }) => ({ '--Button-iconOffsetStep': 0, ...(ownerState.variant === 'solid' && { '&.Mui-focusVisible, &:focus-visible': { outlineOffset: '-3px', outlineColor: '#fff', }, }), ...(ownerState.variant === 'outlined' && { '&.Mui-focusVisible, &:focus-visible': { outlineOffset: '-3px', }, }), ...(ownerState.size === 'md' && { '--Icon-fontSize': '20px', fontSize: '14px', fontWeight: 600, minHeight: '32px', borderRadius: '2px', paddingLeft: 20, paddingRight: 20, }), }), }, }, }, });`; const chakraTheme = extendTheme({ cssVarPrefix: 'chakra', colorSchemes: { light: { palette: { primary: { solidBg: '#319795', solidHoverBg: '#2C7A7B', solidActiveBg: '#285E61', outlinedColor: '#2C7A7B', outlinedBorder: '#2C7A7B', outlinedHoverBorder: undefined, outlinedHoverBg: '#E6FFFA', outlinedActiveBg: '#B2F5EA', }, focusVisible: 'rgba(66, 153, 225, 0.6)', }, }, }, focus: { default: { outlineWidth: '3px', }, }, fontFamily: { body: 'Inter, var(--chakra-fontFamily-fallback)', }, components: { JoyButton: { styleOverrides: { root: ({ theme, ownerState }) => ({ '&:focus': theme.focus.default, fontWeight: 600, ...(ownerState.size === 'md' && { borderRadius: '0.375rem', paddingInline: '1rem', }), }), }, }, }, }); const chakraCode = `const chakraTheme = extendTheme({ colorSchemes: { light: { palette: { primary: { solidBg: '#319795', solidHoverBg: '#2C7A7B', solidActiveBg: '#285E61', outlinedColor: '#2C7A7B', outlinedBorder: '#2C7A7B', outlinedHoverBorder: undefined, outlinedHoverBg: '#E6FFFA', outlinedActiveBg: '#B2F5EA', }, focusVisible: 'rgba(66, 153, 225, 0.6)', }, }, }, focus: { default: { outlineWidth: '3px', }, }, fontFamily: { body: 'Inter, var(--chakra-fontFamily-fallback)', }, components: { JoyButton: { styleOverrides: { root: ({ theme, ownerState }) => ({ '&:focus': theme.focus.default, fontWeight: 600, ...(ownerState.size === 'md' && { borderRadius: '0.375rem', paddingInline: '1rem', }), }), }, }, }, });`; const mantineTheme = extendTheme({ cssVarPrefix: 'mantine', colorSchemes: { light: { palette: { primary: { solidBg: '#228be6', solidHoverBg: '#1c7ed6', solidActiveBg: undefined, softColor: '#228be6', softBg: 'rgba(231, 245, 255, 1)', softHoverBg: 'rgba(208, 235, 255, 0.65)', softActiveBg: undefined, outlinedColor: '#228be6', outlinedBorder: '#228be6', outlinedHoverBg: 'rgba(231, 245, 255, 0.35)', outlinedHoverBorder: undefined, outlinedActiveBg: undefined, }, }, }, }, fontFamily: { body: '-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji', }, focus: { default: { outlineWidth: '2px', outlineOffset: '2px', outlineColor: '#339af0', }, }, components: { JoyButton: { styleOverrides: { root: ({ ownerState }) => ({ transition: 'initial', borderRadius: '4px', fontWeight: 600, ...(ownerState.size === 'md' && { minHeight: '36px', fontSize: '14px', paddingInline: '18px', }), '&:active': { transform: 'translateY(1px)', }, }), }, }, }, }); const mantineCode = `const mantineTheme = extendTheme({ colorSchemes: { light: { palette: { primary: { solidBg: '#228be6', solidHoverBg: '#1c7ed6', solidActiveBg: undefined, softColor: '#228be6', softBg: 'rgba(231, 245, 255, 1)', softHoverBg: 'rgba(208, 235, 255, 0.65)', softActiveBg: undefined, outlinedColor: '#228be6', outlinedBorder: '#228be6', outlinedHoverBg: 'rgba(231, 245, 255, 0.35)', outlinedHoverBorder: undefined, outlinedActiveBg: undefined, }, }, }, }, fontFamily: { body: '-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji', }, focus: { default: { outlineWidth: '2px', outlineOffset: '2px', outlineColor: '#339af0', }, }, components: { JoyButton: { styleOverrides: { root: ({ ownerState }) => ({ transition: 'initial', borderRadius: '4px', fontWeight: 600, ...(ownerState.size === 'md' && { minHeight: '36px', fontSize: '14px', paddingInline: '18px', }), '&:active': { transform: 'translateY(1px)', }, }), }, }, }, });`; const themes = { github: githubTheme, fluent: fluentTheme, chakra: chakraTheme, mantine: mantineTheme, }; const codes = { github: githubCode, fluent: fluentCode, chakra: chakraCode, mantine: mantineCode, }; const useEnhancedEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect; export default function ButtonThemes() { // 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('button-themes-demo')); }, []); const [design, setDesign] = React.useState('github'); return ( <Box sx={{ m: -1.5, mt: 0.5, flexGrow: 1, maxWidth: 'calc(100% + 24px)', borderRadius: '8px', '& .markdown-body pre': { margin: 0, borderRadius: 'xs', }, }} > <Box sx={{ display: 'flex', flexDirection: 'column', gap: 1, mb: 3 }}> <CssVarsProvider disableNestedContext theme={themes[design]} colorSchemeNode={node || null} colorSchemeSelector="#button-themes-demo" modeStorageKey="button-themes-demo" colorSchemeStorageKey="button-themes-demo" > <Box id="button-themes-demo" sx={{ flexGrow: 1, m: 'auto', display: 'flex', alignItems: 'center', p: 2, minHeight: 100, }} > {design === 'github' && ( <Box sx={{ display: 'flex', gap: 2 }}> <Button color="success">Primary</Button> <Button variant="outlined" color="neutral"> Default </Button> </Box> )} {design === 'fluent' && ( <Box sx={{ display: 'flex', gap: 2 }}> <Button>Primary</Button> <Button variant="outlined" color="neutral"> Secondary </Button> </Box> )} {design === 'chakra' && ( <Box sx={{ display: 'flex', gap: 2 }}> <Button>Solid</Button> <Button variant="outlined">Outlined</Button> </Box> )} {design === 'mantine' && ( <Box sx={{ display: 'flex', gap: 2 }}> <Button>Solid</Button> <Button variant="soft">Soft</Button> <Button variant="outlined">Outlined</Button> </Box> )} </Box> </CssVarsProvider> <Box sx={{ mx: 'auto', pt: 3, width: '100%', display: 'flex', gap: 1, alignItems: 'center', justifyContent: 'center', borderTop: '1px solid', borderColor: 'divider', }} > <FormLabel htmlFor="button-theme">Change the theme:</FormLabel> <Select slotProps={{ button: { id: 'button-theme', }, }} size="sm" value={design} onChange={(event, newValue) => setDesign(newValue)} sx={{ minWidth: 160 }} > <Option value="github">GitHub</Option> <Option value="fluent">Fluent</Option> <Option value="chakra">Chakra</Option> <Option value="mantine">Mantine</Option> </Select> </Box> </Box> <BrandingProvider mode="dark"> <HighlightedCode code={`import { CssVarsProvider, extendTheme } from '@mui/joy/styles'; import Button from '@mui/joy/Button'; ${codes[design]} function App() { return ( <CssVarsProvider theme={${design}Theme}> <Button>Solid</Button> ...other buttons </CssVarsProvider> ); }; `} copyButtonHidden language="jsx" sx={{ display: { xs: 'none', md: 'block' }, maxHeight: '40vh', overflow: 'auto', borderRadius: '7px', }} /> </BrandingProvider> </Box> ); }
1,795
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/approaches/StyledComponent.js
import * as React from 'react'; import { styled } from '@mui/joy/styles'; import VolumeUpRoundedIcon from '@mui/icons-material/VolumeUpRounded'; import VolumeOffRoundedIcon from '@mui/icons-material/VolumeOffRounded'; const ToggleButton = styled('button')( ({ theme, 'aria-pressed': pressed = 'false' }) => ({ padding: '0.5rem 1rem', borderRadius: theme.vars.radius.sm, display: 'inline-flex', justifyContent: 'center', gap: '8px', minHeight: 40, fontFamily: theme.vars.fontFamily.body, fontSize: theme.vars.fontSize.md, fontWeight: theme.vars.fontWeight.md, alignItems: 'center', border: '1px solid', borderColor: theme.vars.palette.neutral.outlinedBorder, backgroundColor: theme.vars.palette.background.body, boxShadow: theme.vars.shadow.md, [theme.focus.selector]: theme.focus.default, ...theme.variants.plain.neutral, ...(pressed === 'false' && { '&:hover': theme.variants.plainHover.neutral, '&:active': theme.variants.plainActive.neutral, }), ...(pressed === 'true' && { color: theme.vars.palette.danger.plainColor, backgroundColor: theme.vars.palette.background.body, boxShadow: theme.shadow.sm.replace(/,/g, ', inset'), }), }), ); export default function StyledComponent() { const [muted, setMuted] = React.useState(false); return ( <ToggleButton aria-pressed={muted ? 'true' : 'false'} onClick={() => setMuted((bool) => !bool)} sx={{ minWidth: 120 }} > Mute {muted ? <VolumeOffRoundedIcon /> : <VolumeUpRoundedIcon />} </ToggleButton> ); }
1,796
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/approaches/StyledComponent.tsx
import * as React from 'react'; import { styled } from '@mui/joy/styles'; import VolumeUpRoundedIcon from '@mui/icons-material/VolumeUpRounded'; import VolumeOffRoundedIcon from '@mui/icons-material/VolumeOffRounded'; const ToggleButton = styled('button')( ({ theme, 'aria-pressed': pressed = 'false' }) => ({ padding: '0.5rem 1rem', borderRadius: theme.vars.radius.sm, display: 'inline-flex', justifyContent: 'center', gap: '8px', minHeight: 40, fontFamily: theme.vars.fontFamily.body, fontSize: theme.vars.fontSize.md, fontWeight: theme.vars.fontWeight.md, alignItems: 'center', border: '1px solid', borderColor: theme.vars.palette.neutral.outlinedBorder, backgroundColor: theme.vars.palette.background.body, boxShadow: theme.vars.shadow.md, [theme.focus.selector]: theme.focus.default, ...theme.variants.plain.neutral, ...(pressed === 'false' && { '&:hover': theme.variants.plainHover.neutral, '&:active': theme.variants.plainActive.neutral, }), ...(pressed === 'true' && { color: theme.vars.palette.danger.plainColor, backgroundColor: theme.vars.palette.background.body, boxShadow: theme.shadow.sm.replace(/,/g, ', inset'), }), }), ); export default function StyledComponent() { const [muted, setMuted] = React.useState(false); return ( <ToggleButton aria-pressed={muted ? 'true' : 'false'} onClick={() => setMuted((bool) => !bool)} sx={{ minWidth: 120 }} > Mute {muted ? <VolumeOffRoundedIcon /> : <VolumeUpRoundedIcon />} </ToggleButton> ); }
1,797
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/approaches/StyledComponent.tsx.preview
<ToggleButton aria-pressed={muted ? 'true' : 'false'} onClick={() => setMuted((bool) => !bool)} sx={{ minWidth: 120 }} > Mute {muted ? <VolumeOffRoundedIcon /> : <VolumeUpRoundedIcon />} </ToggleButton>
1,798
0
petrpan-code/mui/material-ui/docs/data/joy/customization
petrpan-code/mui/material-ui/docs/data/joy/customization/approaches/SxProp.js
import * as React from 'react'; import Button from '@mui/joy/Button'; export default function SxProp() { return ( <Button size="md" sx={(theme) => ({ background: `linear-gradient(-45deg, ${theme.vars.palette.primary[700]}, ${theme.vars.palette.primary[600]})`, boxShadow: 'inset 0px 2px 2px rgba(255, 255, 255, 0.3)', borderRadius: 'md', fontWeight: 'lg', // short-hand syntax, same as `theme.fontWeight.lg` '&:hover': { background: `${theme.vars.palette.primary[700]}`, boxShadow: 'inset 0px 0px 4px rgba(0, 0, 0, 0.3)', }, })} > This is a call to action </Button> ); }
1,799