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/base/components/switch/UnstyledSwitchIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/switch/UnstyledSwitchIntroduction/system/index.js
import * as React from 'react'; import { styled } from '@mui/system'; import { Switch, switchClasses } from '@mui/base/Switch'; export default function UnstyledSwitchIntroduction() { const label = { slotProps: { input: { 'aria-label': 'Demo switch' } } }; return ( <div> <Switch slots={{ root: Root, }} {...label} defaultChecked /> <Switch slots={{ root: Root, }} {...label} /> <Switch slots={{ root: Root, }} {...label} defaultChecked disabled /> <Switch slots={{ root: Root, }} {...label} disabled /> </div> ); } const blue = { 200: '#99CCF3', 500: '#007FFF', 700: '#0059B2', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Root = styled('span')( ({ theme }) => ` font-size: 0; position: relative; display: inline-block; width: 38px; height: 24px; margin: 10px; cursor: pointer; &.${switchClasses.disabled} { opacity: 0.4; cursor: not-allowed; } & .${switchClasses.track} { background: ${theme.palette.mode === 'dark' ? grey[900] : grey[50]}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; border-radius: 24px; display: block; height: 100%; width: 100%; position: absolute; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 120ms; box-shadow: inset 0px 1px 1px ${ theme.palette.mode === 'dark' ? 'rgba(0, 0, 0, 0.5)' : 'rgba(0, 0, 0, 0.05)' }; } &:hover .${switchClasses.track} { background: ${theme.palette.mode === 'dark' ? grey[800] : grey[100]}; border-color: ${theme.palette.mode === 'dark' ? grey[600] : grey[300]}; } &.${switchClasses.focusVisible} .${switchClasses.track} { box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[700] : blue[200]}; } & .${switchClasses.thumb} { border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; display: block; width: 16px; height: 16px; top: 4px; left: 4px; border-radius: 16px; background-color: #FFF; position: relative; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 120ms; box-shadow: 0px 1px 2px ${ theme.palette.mode === 'dark' ? 'rgba(0, 0, 0, 0.25)' : 'rgba(0, 0, 0, 0.1)' }; } &.${switchClasses.checked} { .${switchClasses.thumb} { left: 18px; background-color: #fff; box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3); } .${switchClasses.track} { border: none; background: ${blue[500]}; } } &:hover .${switchClasses.checked} .${switchClasses.track} { background: ${blue[700]}; } & .${switchClasses.input} { cursor: inherit; position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; z-index: 1; margin: 0; } `, );
500
0
petrpan-code/mui/material-ui/docs/data/base/components/switch/UnstyledSwitchIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/switch/UnstyledSwitchIntroduction/system/index.tsx
import * as React from 'react'; import { styled } from '@mui/system'; import { Switch, switchClasses } from '@mui/base/Switch'; export default function UnstyledSwitchIntroduction() { const label = { slotProps: { input: { 'aria-label': 'Demo switch' } } }; return ( <div> <Switch slots={{ root: Root, }} {...label} defaultChecked /> <Switch slots={{ root: Root, }} {...label} /> <Switch slots={{ root: Root, }} {...label} defaultChecked disabled /> <Switch slots={{ root: Root, }} {...label} disabled /> </div> ); } const blue = { 200: '#99CCF3', 500: '#007FFF', 700: '#0059B2', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Root = styled('span')( ({ theme }) => ` font-size: 0; position: relative; display: inline-block; width: 38px; height: 24px; margin: 10px; cursor: pointer; &.${switchClasses.disabled} { opacity: 0.4; cursor: not-allowed; } & .${switchClasses.track} { background: ${theme.palette.mode === 'dark' ? grey[900] : grey[50]}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; border-radius: 24px; display: block; height: 100%; width: 100%; position: absolute; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 120ms; box-shadow: inset 0px 1px 1px ${ theme.palette.mode === 'dark' ? 'rgba(0, 0, 0, 0.5)' : 'rgba(0, 0, 0, 0.05)' }; } &:hover .${switchClasses.track} { background: ${theme.palette.mode === 'dark' ? grey[800] : grey[100]}; border-color: ${theme.palette.mode === 'dark' ? grey[600] : grey[300]}; } &.${switchClasses.focusVisible} .${switchClasses.track} { box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[700] : blue[200]}; } & .${switchClasses.thumb} { border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; display: block; width: 16px; height: 16px; top: 4px; left: 4px; border-radius: 16px; background-color: #FFF; position: relative; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 120ms; box-shadow: 0px 1px 2px ${ theme.palette.mode === 'dark' ? 'rgba(0, 0, 0, 0.25)' : 'rgba(0, 0, 0, 0.1)' }; } &.${switchClasses.checked} { .${switchClasses.thumb} { left: 18px; background-color: #fff; box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3); } .${switchClasses.track} { border: none; background: ${blue[500]}; } } &:hover .${switchClasses.checked} .${switchClasses.track} { background: ${blue[700]}; } & .${switchClasses.input} { cursor: inherit; position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; z-index: 1; margin: 0; } `, );
501
0
petrpan-code/mui/material-ui/docs/data/base/components/switch/UnstyledSwitchIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/switch/UnstyledSwitchIntroduction/tailwind/index.js
import * as React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; import { Switch as BaseSwitch } from '@mui/base/Switch'; import { useTheme } from '@mui/system'; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } export default function UnstyledSwitchIntroduction() { const label = { 'aria-label': 'Demo switch' }; // Replace this with your app logic for determining dark modes const isDarkMode = useIsDarkMode(); return ( <div className={isDarkMode ? 'dark' : ''}> <Switch slotProps={{ input: { ...label } }} defaultChecked /> <Switch slotProps={{ input: { ...label } }} /> <Switch slotProps={{ input: { ...label } }} defaultChecked disabled /> <Switch slotProps={{ input: { ...label } }} disabled /> </div> ); } const resolveSlotProps = (fn, args) => (typeof fn === 'function' ? fn(args) : fn); const Switch = React.forwardRef((props, ref) => { return ( <BaseSwitch ref={ref} {...props} slotProps={{ ...props.slotProps, root: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.root, ownerState, ); return { ...resolvedSlotProps, className: clsx( `group relative inline-block w-[38px] h-[24px] m-2.5 ${ ownerState.disabled ? 'cursor-not-allowed opacity-40' : 'cursor-pointer' }`, resolvedSlotProps?.className, ), }; }, input: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.input, ownerState, ); return { ...resolvedSlotProps, className: clsx( 'cursor-inherit absolute w-full h-full top-0 left-0 opacity-0 z-10 border-none', resolvedSlotProps?.className, ), }; }, track: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.track, ownerState, ); return { ...resolvedSlotProps, className: clsx( `absolute block w-full h-full transition rounded-full border border-solid outline-none border-slate-300 dark:border-gray-700 group-[.Mui-focusVisible]:shadow-outline-switch ${ ownerState.checked ? 'bg-purple-500' : 'bg-slate-100 dark:bg-slate-900 hover:bg-slate-200 dark:hover:bg-slate-800' } `, resolvedSlotProps?.className, ), }; }, thumb: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.thumb, ownerState, ); return { ...resolvedSlotProps, className: clsx( `block w-4 h-4 top-1 rounded-2xl border border-solid outline-none border-slate-300 dark:border-gray-700 transition shadow-[0_1px_2px_rgb(0_0_0_/_0.1)] dark:shadow-[0_1px_2px_rgb(0_0_0_/_0.25)] ${ ownerState.checked ? 'left-[18px] bg-white shadow-[0_0_0_rgb(0_0_0_/_0.3)]' : 'left-[4px] bg-white' } relative transition-all`, resolvedSlotProps?.className, ), }; }, }} /> ); }); Switch.propTypes = { /** * The props used for each slot inside the Switch. * @default {} */ slotProps: PropTypes.shape({ input: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), thumb: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), track: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), }), };
502
0
petrpan-code/mui/material-ui/docs/data/base/components/switch/UnstyledSwitchIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/switch/UnstyledSwitchIntroduction/tailwind/index.tsx
import * as React from 'react'; import clsx from 'clsx'; import { Switch as BaseSwitch, SwitchProps } from '@mui/base/Switch'; import { useTheme } from '@mui/system'; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } export default function UnstyledSwitchIntroduction() { const label = { 'aria-label': 'Demo switch' }; // Replace this with your app logic for determining dark modes const isDarkMode = useIsDarkMode(); return ( <div className={isDarkMode ? 'dark' : ''}> <Switch slotProps={{ input: { ...label } }} defaultChecked /> <Switch slotProps={{ input: { ...label } }} /> <Switch slotProps={{ input: { ...label } }} defaultChecked disabled /> <Switch slotProps={{ input: { ...label } }} disabled /> </div> ); } const resolveSlotProps = (fn: any, args: any) => typeof fn === 'function' ? fn(args) : fn; const Switch = React.forwardRef<HTMLSpanElement, SwitchProps>((props, ref) => { return ( <BaseSwitch ref={ref} {...props} slotProps={{ ...props.slotProps, root: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.root, ownerState, ); return { ...resolvedSlotProps, className: clsx( `group relative inline-block w-[38px] h-[24px] m-2.5 ${ ownerState.disabled ? 'cursor-not-allowed opacity-40' : 'cursor-pointer' }`, resolvedSlotProps?.className, ), }; }, input: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.input, ownerState, ); return { ...resolvedSlotProps, className: clsx( 'cursor-inherit absolute w-full h-full top-0 left-0 opacity-0 z-10 border-none', resolvedSlotProps?.className, ), }; }, track: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.track, ownerState, ); return { ...resolvedSlotProps, className: clsx( `absolute block w-full h-full transition rounded-full border border-solid outline-none border-slate-300 dark:border-gray-700 group-[.Mui-focusVisible]:shadow-outline-switch ${ ownerState.checked ? 'bg-purple-500' : 'bg-slate-100 dark:bg-slate-900 hover:bg-slate-200 dark:hover:bg-slate-800' } `, resolvedSlotProps?.className, ), }; }, thumb: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.thumb, ownerState, ); return { ...resolvedSlotProps, className: clsx( `block w-4 h-4 top-1 rounded-2xl border border-solid outline-none border-slate-300 dark:border-gray-700 transition shadow-[0_1px_2px_rgb(0_0_0_/_0.1)] dark:shadow-[0_1px_2px_rgb(0_0_0_/_0.25)] ${ ownerState.checked ? 'left-[18px] bg-white shadow-[0_0_0_rgb(0_0_0_/_0.3)]' : 'left-[4px] bg-white' } relative transition-all`, resolvedSlotProps?.className, ), }; }, }} /> ); });
503
0
petrpan-code/mui/material-ui/docs/data/base/components/switch/UnstyledSwitchIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/switch/UnstyledSwitchIntroduction/tailwind/index.tsx.preview
<Switch slotProps={{ input: { ...label } }} defaultChecked /> <Switch slotProps={{ input: { ...label } }} /> <Switch slotProps={{ input: { ...label } }} defaultChecked disabled /> <Switch slotProps={{ input: { ...label } }} disabled />
504
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/TableUnstyled.js
import * as React from 'react'; import { styled } from '@mui/system'; import { TablePagination, tablePaginationClasses as classes, } from '@mui/base/TablePagination'; export default function TableUnstyled() { const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); // Avoid a layout jump when reaching the last page with empty rows. const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0; const handleChangePage = (event, newPage) => { setPage(newPage); }; const handleChangeRowsPerPage = (event) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; return ( <Root sx={{ maxWidth: '100%', width: 500 }}> <table aria-label="custom pagination table"> <thead> <tr> <th>Dessert</th> <th>Calories</th> <th>Fat</th> </tr> </thead> <tbody> {(rowsPerPage > 0 ? rows.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) : rows ).map((row) => ( <tr key={row.name}> <td>{row.name}</td> <td style={{ width: 160 }} align="right"> {row.calories} </td> <td style={{ width: 160 }} align="right"> {row.fat} </td> </tr> ))} {emptyRows > 0 && ( <tr style={{ height: 41 * emptyRows }}> <td colSpan={3} aria-hidden /> </tr> )} </tbody> <tfoot> <tr> <CustomTablePagination rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]} colSpan={3} count={rows.length} rowsPerPage={rowsPerPage} page={page} slotProps={{ select: { 'aria-label': 'rows per page', }, actions: { showFirstButton: true, showLastButton: true, }, }} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> </tr> </tfoot> </table> </Root> ); } function createData(name, calories, fat) { return { name, calories, fat }; } const rows = [ createData('Cupcake', 305, 3.7), createData('Donut', 452, 25.0), createData('Eclair', 262, 16.0), createData('Frozen yoghurt', 159, 6.0), createData('Gingerbread', 356, 16.0), createData('Honeycomb', 408, 3.2), createData('Ice cream sandwich', 237, 9.0), createData('Jelly Bean', 375, 0.0), createData('KitKat', 518, 26.0), createData('Lollipop', 392, 0.2), createData('Marshmallow', 318, 0), createData('Nougat', 360, 19.0), createData('Oreo', 437, 18.0), ].sort((a, b) => (a.calories < b.calories ? -1 : 1)); const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Root = styled('div')( ({ theme }) => ` table { font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; border-collapse: collapse; width: 100%; } td, th { border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; text-align: left; padding: 8px; } th { background-color: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; } `, ); const CustomTablePagination = styled(TablePagination)` & .${classes.toolbar} { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; @media (min-width: 768px) { flex-direction: row; align-items: center; } } & .${classes.selectLabel} { margin: 0; } & .${classes.displayedRows} { margin: 0; @media (min-width: 768px) { margin-left: auto; } } & .${classes.spacer} { display: none; } & .${classes.actions} { display: flex; gap: 0.25rem; } `;
505
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/TableUnstyled.tsx
import * as React from 'react'; import { styled } from '@mui/system'; import { TablePagination, tablePaginationClasses as classes, } from '@mui/base/TablePagination'; export default function TableUnstyled() { const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); // Avoid a layout jump when reaching the last page with empty rows. const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0; const handleChangePage = ( event: React.MouseEvent<HTMLButtonElement> | null, newPage: number, ) => { setPage(newPage); }; const handleChangeRowsPerPage = ( event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, ) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; return ( <Root sx={{ maxWidth: '100%', width: 500 }}> <table aria-label="custom pagination table"> <thead> <tr> <th>Dessert</th> <th>Calories</th> <th>Fat</th> </tr> </thead> <tbody> {(rowsPerPage > 0 ? rows.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) : rows ).map((row) => ( <tr key={row.name}> <td>{row.name}</td> <td style={{ width: 160 }} align="right"> {row.calories} </td> <td style={{ width: 160 }} align="right"> {row.fat} </td> </tr> ))} {emptyRows > 0 && ( <tr style={{ height: 41 * emptyRows }}> <td colSpan={3} aria-hidden /> </tr> )} </tbody> <tfoot> <tr> <CustomTablePagination rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]} colSpan={3} count={rows.length} rowsPerPage={rowsPerPage} page={page} slotProps={{ select: { 'aria-label': 'rows per page', }, actions: { showFirstButton: true, showLastButton: true, }, }} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> </tr> </tfoot> </table> </Root> ); } function createData(name: string, calories: number, fat: number) { return { name, calories, fat }; } const rows = [ createData('Cupcake', 305, 3.7), createData('Donut', 452, 25.0), createData('Eclair', 262, 16.0), createData('Frozen yoghurt', 159, 6.0), createData('Gingerbread', 356, 16.0), createData('Honeycomb', 408, 3.2), createData('Ice cream sandwich', 237, 9.0), createData('Jelly Bean', 375, 0.0), createData('KitKat', 518, 26.0), createData('Lollipop', 392, 0.2), createData('Marshmallow', 318, 0), createData('Nougat', 360, 19.0), createData('Oreo', 437, 18.0), ].sort((a, b) => (a.calories < b.calories ? -1 : 1)); const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Root = styled('div')( ({ theme }) => ` table { font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; border-collapse: collapse; width: 100%; } td, th { border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; text-align: left; padding: 8px; } th { background-color: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; } `, ); const CustomTablePagination = styled(TablePagination)` & .${classes.toolbar} { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; @media (min-width: 768px) { flex-direction: row; align-items: center; } } & .${classes.selectLabel} { margin: 0; } & .${classes.displayedRows} { margin: 0; @media (min-width: 768px) { margin-left: auto; } } & .${classes.spacer} { display: none; } & .${classes.actions} { display: flex; gap: 0.25rem; } `;
506
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/table-pagination.md
--- productId: base-ui title: React Table Pagination component components: TablePagination githubLabel: 'component: TablePagination' --- # Table Pagination <p class="description">Table Pagination is an interface tool for splitting up large amounts of data to make it easier for users to navigate.</p> {{"component": "modules/components/ComponentLinkHeader.js", "design": false}} {{"component": "modules/components/ComponentPageTabs.js"}} ## Introduction The Table Pagination component lets you add pagination controls to a table. It controls two properties of its parent table: - displayed page index - number of rows per page {{"demo": "UnstyledPaginationIntroduction", "defaultCodeOpen": false, "bg": "gradient"}} ## Component ```jsx import { TablePagination } from '@mui/base/TablePagination'; ``` Table Pagination renders its internal elements in a `<td>` tag by default so it can be inserted into a table's `<tr>`. You can use the `slots.root` prop to render a different root element—for example, if you need to place the pagination controls outside of the table. See [Custom structure](#custom-structure) for details. The following demo shows an example of customized pagination controls in a table footer that spans the entire row: {{"demo": "TableUnstyled.js"}} ### Anatomy The Table Pagination component is composed of a root `<td>` that houses up to ten interior slots: - toolbar - spacer - selectLabel - selectRoot - select - selectIcon - input - menuItem - displayedRows - actions ```html <td class="MuiTablePagination-root"> <div class="MuiTablePagination-toolbar"> <div class="MuiTablePagination-spacer"></div> <p class="MuiTablePagination-selectLabel" id="mui-48">Rows per page:</p> <select class="MuiTablePagination-select"> <option class="MuiTablePagination-menuItem">All</option> </select> <p class="MuiTablePagination-displayedRows">1–5 of 13</p> <div class="MuiTablePagination-actions"> <button disabled="" aria-label="Go to first page" title="Go to first page"> <span>|⇽</span> </button> <button disabled="" aria-label="Go to previous page" title="Go to previous page" > <span>⇽</span> </button> <button aria-label="Go to next page" title="Go to next page"> <span>⇾</span> </button> <button aria-label="Go to last page" title="Go to last page"> <span>⇾|</span> </button> </div> </div> </td> ``` ### Custom structure Use the `slots` prop to override the root or any other interior slot: ```jsx <TablePagination slots={{ root: 'div', toolbar: 'nav' }} /> ``` :::info The `slots` prop is available on all non-utility Base components. See [Overriding component structure](/base-ui/guides/overriding-component-structure/) for full details. ::: Use the `slotProps` prop to pass custom props to internal slots. The following code snippet applies a CSS class called `my-spacer` to the spacer slot: ```jsx <TablePagination slotProps={{ spacer: { className: 'my-spacer' } }} /> ``` ## Customization ### Usage with TypeScript In TypeScript, you can specify the custom component type used in the `slots.root` as a generic parameter of the unstyled component. This way, you can safely provide the custom root's props directly on the component: ```tsx <TablePagination<typeof CustomComponent> slots={{ root: CustomComponent }} customProp /> ``` The same applies for props specific to custom primitive elements: ```tsx <TablePagination<'button'> slots={{ root: 'button' }} onClick={() => {}} /> ``` ### Custom pagination options You can customize the options shown in the **Rows per page** select using the `rowsPerPageOptions` prop. This prop requires an array of either numbers or objects: - **numbers**—each number is used for the option's label and value. ```jsx <TablePagination rowsPerPageOptions={[10, 50]} /> ``` - **objects**—the `value` and `label` keys are used, respectively, for the value and label of the option (useful for labels such as **All**). ```jsx <TablePagination rowsPerPageOptions={[10, 50, { value: -1, label: 'All' }]} /> ``` ### Customized look and feel The following demo shows another example of pagination controls but with additional style customization: {{"demo": "TableCustomized"}}
507
0
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/TableCustomized
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/TableCustomized/css/index.js
import * as React from 'react'; import { useTheme } from '@mui/system'; import { TablePagination, tablePaginationClasses as classes, } from '@mui/base/TablePagination'; export default function TableCustomized() { const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); // Avoid a layout jump when reaching the last page with empty rows. const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0; const handleChangePage = (event, newPage) => { setPage(newPage); }; const handleChangeRowsPerPage = (event) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; return ( <React.Fragment> <div className="TablePaginationDemo"> <table aria-label="custom pagination table"> <thead> <tr> <th>Dessert</th> <th>Calories</th> <th>Fat</th> </tr> </thead> <tbody> {(rowsPerPage > 0 ? rows.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) : rows ).map((row) => ( <tr key={row.name}> <td>{row.name}</td> <td style={{ width: 120 }} align="right"> {row.calories} </td> <td style={{ width: 120 }} align="right"> {row.fat} </td> </tr> ))} {emptyRows > 0 && ( <tr style={{ height: 34 * emptyRows }}> <td colSpan={3} aria-hidden /> </tr> )} </tbody> <tfoot> <tr> <TablePagination className="CustomTablePagination" rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]} colSpan={3} count={rows.length} rowsPerPage={rowsPerPage} page={page} slotProps={{ select: { 'aria-label': 'rows per page', }, actions: { showFirstButton: true, showLastButton: true, }, }} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> </tr> </tfoot> </table> </div> <Styles /> </React.Fragment> ); } function createData(name, calories, fat) { return { name, calories, fat }; } const rows = [ createData('Cupcake', 305, 3.7), createData('Donut', 452, 25.0), createData('Eclair', 262, 16.0), createData('Frozen yoghurt', 159, 6.0), createData('Gingerbread', 356, 16.0), createData('Honeycomb', 408, 3.2), createData('Ice cream sandwich', 237, 9.0), createData('Jelly Bean', 375, 0.0), createData('KitKat', 518, 26.0), createData('Lollipop', 392, 0.2), createData('Marshmallow', 318, 0), createData('Nougat', 360, 19.0), createData('Oreo', 437, 18.0), ].sort((a, b) => (a.calories < b.calories ? -1 : 1)); const cyan = { 50: '#E9F8FC', 100: '#BDEBF4', 200: '#99D8E5', 300: '#66BACC', 400: '#1F94AD', 500: '#0D5463', 600: '#094855', 700: '#063C47', 800: '#043039', 900: '#022127', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } function Styles() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); return ( <style> {` .TablePaginationDemo { width: 500px; max-width: 100%; } .TablePaginationDemo table { font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; border-collapse: collapse; width: 100%; } .TablePaginationDemo td, .TablePaginationDemo th { border: 1px solid ${isDarkMode ? grey[800] : grey[200]}; text-align: left; padding: 6px; } .TablePaginationDemo th { background-color: ${isDarkMode ? cyan[800] : cyan[50]}; } .CustomTablePagination .${classes.spacer} { display: none; } .CustomTablePagination .${classes.toolbar} { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; @media (min-width: 768px) { flex-direction: row; align-items: center; } } .CustomTablePagination .${classes.selectLabel} { margin: 0; } .CustomTablePagination .${classes.select} { padding: 2px; border: 1px solid ${isDarkMode ? grey[800] : grey[200]}; border-radius: 50px; background-color: transparent; } .CustomTablePagination .${classes.select}:hover { background-color: ${isDarkMode ? grey[800] : grey[50]}; } .CustomTablePagination .${classes.select}:focus { outline: 1px solid ${isDarkMode ? cyan[400] : cyan[200]}; } .CustomTablePagination .${classes.displayedRows} { margin: 0; @media (min-width: 768px) { margin-left: auto; } } .CustomTablePagination .${classes.actions} { padding: 2px; border: 1px solid ${isDarkMode ? grey[800] : grey[200]}; border-radius: 50px; text-align: center; } .CustomTablePagination .${classes.actions} > button { margin: 0 8px; border: transparent; border-radius: 2px; background-color: transparent; } .CustomTablePagination .${classes.actions} > button:hover { background-color: ${isDarkMode ? grey[800] : grey[50]}; } .CustomTablePagination .${classes.actions} > button:focus { outline: 1px solid ${isDarkMode ? cyan[400] : cyan[200]}; } `} </style> ); }
508
0
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/TableCustomized
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/TableCustomized/css/index.tsx
import * as React from 'react'; import { useTheme } from '@mui/system'; import { TablePagination, tablePaginationClasses as classes, } from '@mui/base/TablePagination'; export default function TableCustomized() { const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); // Avoid a layout jump when reaching the last page with empty rows. const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0; const handleChangePage = ( event: React.MouseEvent<HTMLButtonElement> | null, newPage: number, ) => { setPage(newPage); }; const handleChangeRowsPerPage = ( event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, ) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; return ( <React.Fragment> <div className="TablePaginationDemo"> <table aria-label="custom pagination table"> <thead> <tr> <th>Dessert</th> <th>Calories</th> <th>Fat</th> </tr> </thead> <tbody> {(rowsPerPage > 0 ? rows.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) : rows ).map((row) => ( <tr key={row.name}> <td>{row.name}</td> <td style={{ width: 120 }} align="right"> {row.calories} </td> <td style={{ width: 120 }} align="right"> {row.fat} </td> </tr> ))} {emptyRows > 0 && ( <tr style={{ height: 34 * emptyRows }}> <td colSpan={3} aria-hidden /> </tr> )} </tbody> <tfoot> <tr> <TablePagination className="CustomTablePagination" rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]} colSpan={3} count={rows.length} rowsPerPage={rowsPerPage} page={page} slotProps={{ select: { 'aria-label': 'rows per page', }, actions: { showFirstButton: true, showLastButton: true, }, }} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> </tr> </tfoot> </table> </div> <Styles /> </React.Fragment> ); } function createData(name: string, calories: number, fat: number) { return { name, calories, fat }; } const rows = [ createData('Cupcake', 305, 3.7), createData('Donut', 452, 25.0), createData('Eclair', 262, 16.0), createData('Frozen yoghurt', 159, 6.0), createData('Gingerbread', 356, 16.0), createData('Honeycomb', 408, 3.2), createData('Ice cream sandwich', 237, 9.0), createData('Jelly Bean', 375, 0.0), createData('KitKat', 518, 26.0), createData('Lollipop', 392, 0.2), createData('Marshmallow', 318, 0), createData('Nougat', 360, 19.0), createData('Oreo', 437, 18.0), ].sort((a, b) => (a.calories < b.calories ? -1 : 1)); const cyan = { 50: '#E9F8FC', 100: '#BDEBF4', 200: '#99D8E5', 300: '#66BACC', 400: '#1F94AD', 500: '#0D5463', 600: '#094855', 700: '#063C47', 800: '#043039', 900: '#022127', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } function Styles() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); return ( <style> {` .TablePaginationDemo { width: 500px; max-width: 100%; } .TablePaginationDemo table { font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; border-collapse: collapse; width: 100%; } .TablePaginationDemo td, .TablePaginationDemo th { border: 1px solid ${isDarkMode ? grey[800] : grey[200]}; text-align: left; padding: 6px; } .TablePaginationDemo th { background-color: ${isDarkMode ? cyan[800] : cyan[50]}; } .CustomTablePagination .${classes.spacer} { display: none; } .CustomTablePagination .${classes.toolbar} { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; @media (min-width: 768px) { flex-direction: row; align-items: center; } } .CustomTablePagination .${classes.selectLabel} { margin: 0; } .CustomTablePagination .${classes.select} { padding: 2px; border: 1px solid ${isDarkMode ? grey[800] : grey[200]}; border-radius: 50px; background-color: transparent; } .CustomTablePagination .${classes.select}:hover { background-color: ${isDarkMode ? grey[800] : grey[50]}; } .CustomTablePagination .${classes.select}:focus { outline: 1px solid ${isDarkMode ? cyan[400] : cyan[200]}; } .CustomTablePagination .${classes.displayedRows} { margin: 0; @media (min-width: 768px) { margin-left: auto; } } .CustomTablePagination .${classes.actions} { padding: 2px; border: 1px solid ${isDarkMode ? grey[800] : grey[200]}; border-radius: 50px; text-align: center; } .CustomTablePagination .${classes.actions} > button { margin: 0 8px; border: transparent; border-radius: 2px; background-color: transparent; } .CustomTablePagination .${classes.actions} > button:hover { background-color: ${isDarkMode ? grey[800] : grey[50]}; } .CustomTablePagination .${classes.actions} > button:focus { outline: 1px solid ${isDarkMode ? cyan[400] : cyan[200]}; } `} </style> ); }
509
0
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/TableCustomized
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/TableCustomized/system/index.js
import * as React from 'react'; import { styled } from '@mui/system'; import { TablePagination, tablePaginationClasses as classes, } from '@mui/base/TablePagination'; export default function TableCustomized() { const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); // Avoid a layout jump when reaching the last page with empty rows. const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0; const handleChangePage = (event, newPage) => { setPage(newPage); }; const handleChangeRowsPerPage = (event) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; return ( <Root sx={{ width: 500, maxWidth: '100%' }}> <table aria-label="custom pagination table"> <thead> <tr> <th>Dessert</th> <th>Calories</th> <th>Fat</th> </tr> </thead> <tbody> {(rowsPerPage > 0 ? rows.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) : rows ).map((row) => ( <tr key={row.name}> <td>{row.name}</td> <td style={{ width: 120 }} align="right"> {row.calories} </td> <td style={{ width: 120 }} align="right"> {row.fat} </td> </tr> ))} {emptyRows > 0 && ( <tr style={{ height: 34 * emptyRows }}> <td colSpan={3} aria-hidden /> </tr> )} </tbody> <tfoot> <tr> <CustomTablePagination rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]} colSpan={3} count={rows.length} rowsPerPage={rowsPerPage} page={page} slotProps={{ select: { 'aria-label': 'rows per page', }, actions: { showFirstButton: true, showLastButton: true, }, }} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> </tr> </tfoot> </table> </Root> ); } function createData(name, calories, fat) { return { name, calories, fat }; } const rows = [ createData('Cupcake', 305, 3.7), createData('Donut', 452, 25.0), createData('Eclair', 262, 16.0), createData('Frozen yoghurt', 159, 6.0), createData('Gingerbread', 356, 16.0), createData('Honeycomb', 408, 3.2), createData('Ice cream sandwich', 237, 9.0), createData('Jelly Bean', 375, 0.0), createData('KitKat', 518, 26.0), createData('Lollipop', 392, 0.2), createData('Marshmallow', 318, 0), createData('Nougat', 360, 19.0), createData('Oreo', 437, 18.0), ].sort((a, b) => (a.calories < b.calories ? -1 : 1)); const blue = { 50: '#F0F7FF', 200: '#A5D8FF', 400: '#3399FF', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Root = styled('div')( ({ theme }) => ` table { font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; border-collapse: collapse; width: 100%; } td, th { border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; text-align: left; padding: 6px; } th { background-color: ${theme.palette.mode === 'dark' ? blue[900] : blue[50]}; } `, ); const CustomTablePagination = styled(TablePagination)( ({ theme }) => ` & .${classes.spacer} { display: none; } & .${classes.toolbar} { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; @media (min-width: 768px) { flex-direction: row; align-items: center; } } & .${classes.selectLabel} { margin: 0; } & .${classes.select}{ padding: 2px; border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; border-radius: 50px; background-color: transparent; &:hover { background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[50]}; } &:focus { outline: 1px solid ${theme.palette.mode === 'dark' ? blue[400] : blue[200]}; } } & .${classes.displayedRows} { margin: 0; @media (min-width: 768px) { margin-left: auto; } } & .${classes.actions} { padding: 2px; border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; border-radius: 50px; text-align: center; } & .${classes.actions} > button { margin: 0 8px; border: transparent; border-radius: 2px; background-color: transparent; &:hover { background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[50]}; } &:focus { outline: 1px solid ${theme.palette.mode === 'dark' ? blue[400] : blue[200]}; } } `, );
510
0
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/TableCustomized
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/TableCustomized/system/index.tsx
import * as React from 'react'; import { styled } from '@mui/system'; import { TablePagination, tablePaginationClasses as classes, } from '@mui/base/TablePagination'; export default function TableCustomized() { const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); // Avoid a layout jump when reaching the last page with empty rows. const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0; const handleChangePage = ( event: React.MouseEvent<HTMLButtonElement> | null, newPage: number, ) => { setPage(newPage); }; const handleChangeRowsPerPage = ( event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, ) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; return ( <Root sx={{ width: 500, maxWidth: '100%' }}> <table aria-label="custom pagination table"> <thead> <tr> <th>Dessert</th> <th>Calories</th> <th>Fat</th> </tr> </thead> <tbody> {(rowsPerPage > 0 ? rows.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) : rows ).map((row) => ( <tr key={row.name}> <td>{row.name}</td> <td style={{ width: 120 }} align="right"> {row.calories} </td> <td style={{ width: 120 }} align="right"> {row.fat} </td> </tr> ))} {emptyRows > 0 && ( <tr style={{ height: 34 * emptyRows }}> <td colSpan={3} aria-hidden /> </tr> )} </tbody> <tfoot> <tr> <CustomTablePagination rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]} colSpan={3} count={rows.length} rowsPerPage={rowsPerPage} page={page} slotProps={{ select: { 'aria-label': 'rows per page', }, actions: { showFirstButton: true, showLastButton: true, }, }} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> </tr> </tfoot> </table> </Root> ); } function createData(name: string, calories: number, fat: number) { return { name, calories, fat }; } const rows = [ createData('Cupcake', 305, 3.7), createData('Donut', 452, 25.0), createData('Eclair', 262, 16.0), createData('Frozen yoghurt', 159, 6.0), createData('Gingerbread', 356, 16.0), createData('Honeycomb', 408, 3.2), createData('Ice cream sandwich', 237, 9.0), createData('Jelly Bean', 375, 0.0), createData('KitKat', 518, 26.0), createData('Lollipop', 392, 0.2), createData('Marshmallow', 318, 0), createData('Nougat', 360, 19.0), createData('Oreo', 437, 18.0), ].sort((a, b) => (a.calories < b.calories ? -1 : 1)); const blue = { 50: '#F0F7FF', 200: '#A5D8FF', 400: '#3399FF', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Root = styled('div')( ({ theme }) => ` table { font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; border-collapse: collapse; width: 100%; } td, th { border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; text-align: left; padding: 6px; } th { background-color: ${theme.palette.mode === 'dark' ? blue[900] : blue[50]}; } `, ); const CustomTablePagination = styled(TablePagination)( ({ theme }) => ` & .${classes.spacer} { display: none; } & .${classes.toolbar} { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; @media (min-width: 768px) { flex-direction: row; align-items: center; } } & .${classes.selectLabel} { margin: 0; } & .${classes.select}{ padding: 2px; border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; border-radius: 50px; background-color: transparent; &:hover { background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[50]}; } &:focus { outline: 1px solid ${theme.palette.mode === 'dark' ? blue[400] : blue[200]}; } } & .${classes.displayedRows} { margin: 0; @media (min-width: 768px) { margin-left: auto; } } & .${classes.actions} { padding: 2px; border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; border-radius: 50px; text-align: center; } & .${classes.actions} > button { margin: 0 8px; border: transparent; border-radius: 2px; background-color: transparent; &:hover { background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[50]}; } &:focus { outline: 1px solid ${theme.palette.mode === 'dark' ? blue[400] : blue[200]}; } } `, );
511
0
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/TableCustomized
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/TableCustomized/tailwind/index.js
import * as React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; import { useTheme } from '@mui/system'; import { TablePagination } from '@mui/base/TablePagination'; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } export default function TableCustomized() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); // Avoid a layout jump when reaching the last page with empty rows. const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0; const handleChangePage = (event, newPage) => { setPage(newPage); }; const handleChangeRowsPerPage = (event) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; return ( <div className={`${isDarkMode ? 'dark' : ''} max-w-full`} style={{ width: '500px' }} > <table className="text-sm font-sans w-full border-collapse" aria-label="custom pagination table" > <thead> <tr> <th className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5 bg-purple-50 dark:bg-purple-950"> Dessert </th> <th className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5 bg-purple-50 dark:bg-purple-950"> Calories </th> <th className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5 bg-purple-50 dark:bg-purple-950"> Fat </th> </tr> </thead> <tbody> {(rowsPerPage > 0 ? rows.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) : rows ).map((row) => ( <tr key={row.name}> <td className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5"> {row.name} </td> <td className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5" style={{ width: 120 }} align="right" > {row.calories} </td> <td className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5" style={{ width: 120 }} align="right" > {row.fat} </td> </tr> ))} {emptyRows > 0 && ( <tr style={{ height: 34 * emptyRows }}> <td className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5" colSpan={3} aria-hidden /> </tr> )} </tbody> <tfoot> <tr className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5"> <CustomTablePagination rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]} colSpan={3} count={rows.length} rowsPerPage={rowsPerPage} page={page} slotProps={{ select: { 'aria-label': 'rows per page', }, actions: { showFirstButton: true, showLastButton: true, }, }} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> </tr> </tfoot> </table> </div> ); } const resolveSlotProps = (fn, args) => (typeof fn === 'function' ? fn(args) : fn); const CustomTablePagination = React.forwardRef((props, ref) => { return ( <TablePagination ref={ref} {...props} className={clsx('CustomTablePagination p-1.5', props.className)} slotProps={{ ...props.slotProps, select: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.select, ownerState, ); return { ...resolvedSlotProps, className: clsx( 'p-0.5 border border-solid border-slate-200 dark:border-slate-800 rounded-3xl bg-transparent hover:bg-slate-20 hover:dark:bg-slate-800 focus:outline-0 focus:shadow-outline-purple-xs', resolvedSlotProps?.className, ), }; }, actions: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.actions, ownerState, ); return { ...resolvedSlotProps, className: clsx( 'p-0.5 border border-solid border-slate-200 dark:border-slate-800 rounded-3xl text-center [&>button]:my-0 [&>button]:mx-2 [&>button]:border-transparent [&>button]:rounded-sm [&>button]:bg-transparent [&>button:hover]:bg-slate-50 [&>button:hover]:dark:bg-slate-800 [&>button:focus]:outline-0 [&>button:focus]:shadow-outline-purple-xs', resolvedSlotProps?.className, ), }; }, spacer: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.spacer, ownerState, ); return { ...resolvedSlotProps, className: clsx('hidden', resolvedSlotProps?.className), }; }, toolbar: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.toolbar, ownerState, ); return { ...resolvedSlotProps, className: clsx( 'flex flex-col items-start gap-2.5 md:flex-row md:items-center', resolvedSlotProps?.className, ), }; }, selectLabel: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.selectLabel, ownerState, ); return { ...resolvedSlotProps, className: clsx('m-0', resolvedSlotProps?.className), }; }, displayedRows: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.displayedRows, ownerState, ); return { ...resolvedSlotProps, className: clsx('m-0 md:ml-auto', resolvedSlotProps?.className), }; }, }} /> ); }); CustomTablePagination.propTypes = { className: PropTypes.string, /** * The props used for each slot inside the TablePagination. * @default {} */ slotProps: PropTypes.shape({ actions: PropTypes.oneOfType([ PropTypes.func, PropTypes.shape({ count: PropTypes.number, direction: PropTypes.oneOf(['ltr', 'rtl']), getItemAriaLabel: PropTypes.func, onPageChange: PropTypes.func, page: PropTypes.number, rowsPerPage: PropTypes.number, showFirstButton: PropTypes.bool, showLastButton: PropTypes.bool, slotProps: PropTypes.shape({ backButton: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), firstButton: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), lastButton: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), nextButton: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), }), slots: PropTypes.shape({ backButton: PropTypes.elementType, backPageIcon: PropTypes.elementType, firstButton: PropTypes.elementType, firstPageIcon: PropTypes.elementType, lastButton: PropTypes.elementType, lastPageIcon: PropTypes.elementType, nextButton: PropTypes.elementType, nextPageIcon: PropTypes.elementType, root: PropTypes.elementType, }), }), ]), displayedRows: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), menuItem: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), select: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), selectLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), spacer: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), toolbar: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), }), }; function createData(name, calories, fat) { return { name, calories, fat }; } const rows = [ createData('Cupcake', 305, 3.7), createData('Donut', 452, 25.0), createData('Eclair', 262, 16.0), createData('Frozen yoghurt', 159, 6.0), createData('Gingerbread', 356, 16.0), createData('Honeycomb', 408, 3.2), createData('Ice cream sandwich', 237, 9.0), createData('Jelly Bean', 375, 0.0), createData('KitKat', 518, 26.0), createData('Lollipop', 392, 0.2), createData('Marshmallow', 318, 0), createData('Nougat', 360, 19.0), createData('Oreo', 437, 18.0), ].sort((a, b) => (a.calories < b.calories ? -1 : 1));
512
0
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/TableCustomized
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/TableCustomized/tailwind/index.tsx
import * as React from 'react'; import clsx from 'clsx'; import { useTheme } from '@mui/system'; import { TablePagination, TablePaginationProps } from '@mui/base/TablePagination'; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } export default function TableCustomized() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); // Avoid a layout jump when reaching the last page with empty rows. const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0; const handleChangePage = ( event: React.MouseEvent<HTMLButtonElement> | null, newPage: number, ) => { setPage(newPage); }; const handleChangeRowsPerPage = ( event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, ) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; return ( <div className={`${isDarkMode ? 'dark' : ''} max-w-full`} style={{ width: '500px' }} > <table className="text-sm font-sans w-full border-collapse" aria-label="custom pagination table" > <thead> <tr> <th className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5 bg-purple-50 dark:bg-purple-950"> Dessert </th> <th className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5 bg-purple-50 dark:bg-purple-950"> Calories </th> <th className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5 bg-purple-50 dark:bg-purple-950"> Fat </th> </tr> </thead> <tbody> {(rowsPerPage > 0 ? rows.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) : rows ).map((row) => ( <tr key={row.name}> <td className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5"> {row.name} </td> <td className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5" style={{ width: 120 }} align="right" > {row.calories} </td> <td className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5" style={{ width: 120 }} align="right" > {row.fat} </td> </tr> ))} {emptyRows > 0 && ( <tr style={{ height: 34 * emptyRows }}> <td className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5" colSpan={3} aria-hidden /> </tr> )} </tbody> <tfoot> <tr className="border border-solid border-slate-200 dark:border-slate-800 text-left p-1.5"> <CustomTablePagination rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]} colSpan={3} count={rows.length} rowsPerPage={rowsPerPage} page={page} slotProps={{ select: { 'aria-label': 'rows per page', }, actions: { showFirstButton: true, showLastButton: true, }, }} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> </tr> </tfoot> </table> </div> ); } const resolveSlotProps = (fn: any, args: any) => typeof fn === 'function' ? fn(args) : fn; const CustomTablePagination = React.forwardRef< HTMLTableCellElement, TablePaginationProps >((props, ref) => { return ( <TablePagination ref={ref} {...props} className={clsx('CustomTablePagination p-1.5', props.className)} slotProps={{ ...props.slotProps, select: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.select, ownerState, ); return { ...resolvedSlotProps, className: clsx( 'p-0.5 border border-solid border-slate-200 dark:border-slate-800 rounded-3xl bg-transparent hover:bg-slate-20 hover:dark:bg-slate-800 focus:outline-0 focus:shadow-outline-purple-xs', resolvedSlotProps?.className, ), }; }, actions: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.actions, ownerState, ); return { ...resolvedSlotProps, className: clsx( 'p-0.5 border border-solid border-slate-200 dark:border-slate-800 rounded-3xl text-center [&>button]:my-0 [&>button]:mx-2 [&>button]:border-transparent [&>button]:rounded-sm [&>button]:bg-transparent [&>button:hover]:bg-slate-50 [&>button:hover]:dark:bg-slate-800 [&>button:focus]:outline-0 [&>button:focus]:shadow-outline-purple-xs', resolvedSlotProps?.className, ), }; }, spacer: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.spacer, ownerState, ); return { ...resolvedSlotProps, className: clsx('hidden', resolvedSlotProps?.className), }; }, toolbar: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.toolbar, ownerState, ); return { ...resolvedSlotProps, className: clsx( 'flex flex-col items-start gap-2.5 md:flex-row md:items-center', resolvedSlotProps?.className, ), }; }, selectLabel: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.selectLabel, ownerState, ); return { ...resolvedSlotProps, className: clsx('m-0', resolvedSlotProps?.className), }; }, displayedRows: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.displayedRows, ownerState, ); return { ...resolvedSlotProps, className: clsx('m-0 md:ml-auto', resolvedSlotProps?.className), }; }, }} /> ); }); function createData(name: string, calories: number, fat: number) { return { name, calories, fat }; } const rows = [ createData('Cupcake', 305, 3.7), createData('Donut', 452, 25.0), createData('Eclair', 262, 16.0), createData('Frozen yoghurt', 159, 6.0), createData('Gingerbread', 356, 16.0), createData('Honeycomb', 408, 3.2), createData('Ice cream sandwich', 237, 9.0), createData('Jelly Bean', 375, 0.0), createData('KitKat', 518, 26.0), createData('Lollipop', 392, 0.2), createData('Marshmallow', 318, 0), createData('Nougat', 360, 19.0), createData('Oreo', 437, 18.0), ].sort((a, b) => (a.calories < b.calories ? -1 : 1));
513
0
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/UnstyledPaginationIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/UnstyledPaginationIntroduction/css/index.js
import * as React from 'react'; import { useTheme } from '@mui/system'; import { TablePagination, tablePaginationClasses as classes, } from '@mui/base/TablePagination'; export default function UnstyledPaginationIntroduction() { const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); const handleChangePage = (event, newPage) => { setPage(newPage); }; const handleChangeRowsPerPage = (event) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; return ( <React.Fragment> <div className="TablePaginationIntroductionDemo"> <table aria-label="custom pagination table"> <tfoot> <tr> <TablePagination className="CustomTablePagination" rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]} colSpan={3} count={13} rowsPerPage={rowsPerPage} page={page} slotProps={{ select: { 'aria-label': 'rows per page', }, actions: { showFirstButton: true, showLastButton: true, }, }} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> </tr> </tfoot> </table> </div> <Styles /> </React.Fragment> ); } const cyan = { 50: '#E9F8FC', 100: '#BDEBF4', 200: '#99D8E5', 300: '#66BACC', 400: '#1F94AD', 500: '#0D5463', 600: '#094855', 700: '#063C47', 800: '#043039', 900: '#022127', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } function Styles() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); return ( <style> {` .TablePaginationIntroductionDemo { width: 500px; max-width: 100%; } th { background-color: ${isDarkMode ? grey[900] : '#fff'}; } .TablePaginationIntroductionDemo table { font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; width: 100%; background-color: ${isDarkMode ? grey[900] : '#fff'}; box-shadow: 0px 2px 16px ${isDarkMode ? grey[900] : grey[200]}; border-radius: 12px; overflow: hidden; border: 1px solid ${isDarkMode ? grey[800] : grey[200]}; } .TablePaginationIntroductionDemo td, .TablePaginationIntroductionDemo th { padding: 16px; } .TablePaginationIntroductionDemo th { background-color: ${isDarkMode ? grey[900] : '#fff'}; } .CustomTablePagination .${classes.spacer} { display: none; } .CustomTablePagination .${classes.toolbar} { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; @media (min-width: 768px) { flex-direction: row; align-items: center; } } .CustomTablePagination .${classes.selectLabel} { margin: 0; } .CustomTablePagination .${classes.select} { padding: 2px 6px; border: 1px solid ${isDarkMode ? grey[800] : grey[200]}; border-radius: 50px; background-color: transparent; } .CustomTablePagination .${classes.select}:hover { background-color: ${isDarkMode ? grey[800] : grey[50]}; } .CustomTablePagination .${classes.select}:focus { outline: 1px solid ${isDarkMode ? cyan[400] : cyan[200]}; } .CustomTablePagination .${classes.displayedRows} { margin: 0; @media (min-width: 768px) { margin-left: auto; } } .CustomTablePagination .${classes.actions} { padding: 2px 6px; border: 1px solid ${isDarkMode ? grey[800] : grey[200]}; border-radius: 50px; text-align: center; } .CustomTablePagination .${classes.actions} > button { margin: 0 8px; border: transparent; border-radius: 2px; background-color: transparent; } .CustomTablePagination .${classes.actions} > button:hover { background-color: ${isDarkMode ? grey[800] : grey[50]}; } .CustomTablePagination .${classes.actions} > button:focus { outline: 1px solid ${isDarkMode ? cyan[400] : cyan[200]}; } .CustomTablePagination .${classes.actions} > button:disabled { opacity: 0.7; } `} </style> ); }
514
0
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/UnstyledPaginationIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/UnstyledPaginationIntroduction/css/index.tsx
import * as React from 'react'; import { useTheme } from '@mui/system'; import { TablePagination, tablePaginationClasses as classes, } from '@mui/base/TablePagination'; export default function UnstyledPaginationIntroduction() { const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); const handleChangePage = ( event: React.MouseEvent<HTMLButtonElement> | null, newPage: number, ) => { setPage(newPage); }; const handleChangeRowsPerPage = ( event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, ) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; return ( <React.Fragment> <div className="TablePaginationIntroductionDemo"> <table aria-label="custom pagination table"> <tfoot> <tr> <TablePagination className="CustomTablePagination" rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]} colSpan={3} count={13} rowsPerPage={rowsPerPage} page={page} slotProps={{ select: { 'aria-label': 'rows per page', }, actions: { showFirstButton: true, showLastButton: true, }, }} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> </tr> </tfoot> </table> </div> <Styles /> </React.Fragment> ); } const cyan = { 50: '#E9F8FC', 100: '#BDEBF4', 200: '#99D8E5', 300: '#66BACC', 400: '#1F94AD', 500: '#0D5463', 600: '#094855', 700: '#063C47', 800: '#043039', 900: '#022127', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } function Styles() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); return ( <style> {` .TablePaginationIntroductionDemo { width: 500px; max-width: 100%; } th { background-color: ${isDarkMode ? grey[900] : '#fff'}; } .TablePaginationIntroductionDemo table { font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; width: 100%; background-color: ${isDarkMode ? grey[900] : '#fff'}; box-shadow: 0px 2px 16px ${isDarkMode ? grey[900] : grey[200]}; border-radius: 12px; overflow: hidden; border: 1px solid ${isDarkMode ? grey[800] : grey[200]}; } .TablePaginationIntroductionDemo td, .TablePaginationIntroductionDemo th { padding: 16px; } .TablePaginationIntroductionDemo th { background-color: ${isDarkMode ? grey[900] : '#fff'}; } .CustomTablePagination .${classes.spacer} { display: none; } .CustomTablePagination .${classes.toolbar} { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; @media (min-width: 768px) { flex-direction: row; align-items: center; } } .CustomTablePagination .${classes.selectLabel} { margin: 0; } .CustomTablePagination .${classes.select} { padding: 2px 6px; border: 1px solid ${isDarkMode ? grey[800] : grey[200]}; border-radius: 50px; background-color: transparent; } .CustomTablePagination .${classes.select}:hover { background-color: ${isDarkMode ? grey[800] : grey[50]}; } .CustomTablePagination .${classes.select}:focus { outline: 1px solid ${isDarkMode ? cyan[400] : cyan[200]}; } .CustomTablePagination .${classes.displayedRows} { margin: 0; @media (min-width: 768px) { margin-left: auto; } } .CustomTablePagination .${classes.actions} { padding: 2px 6px; border: 1px solid ${isDarkMode ? grey[800] : grey[200]}; border-radius: 50px; text-align: center; } .CustomTablePagination .${classes.actions} > button { margin: 0 8px; border: transparent; border-radius: 2px; background-color: transparent; } .CustomTablePagination .${classes.actions} > button:hover { background-color: ${isDarkMode ? grey[800] : grey[50]}; } .CustomTablePagination .${classes.actions} > button:focus { outline: 1px solid ${isDarkMode ? cyan[400] : cyan[200]}; } .CustomTablePagination .${classes.actions} > button:disabled { opacity: 0.7; } `} </style> ); }
515
0
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/UnstyledPaginationIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/UnstyledPaginationIntroduction/system/index.js
import * as React from 'react'; import { styled } from '@mui/system'; import { TablePagination, tablePaginationClasses as classes, } from '@mui/base/TablePagination'; export default function UnstyledPaginationIntroduction() { const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); const handleChangePage = (event, newPage) => { setPage(newPage); }; const handleChangeRowsPerPage = (event) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; return ( <Root sx={{ width: 500, maxWidth: '100%' }}> <table aria-label="custom pagination table"> <tfoot> <tr> <CustomTablePagination rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]} colSpan={3} count={13} rowsPerPage={rowsPerPage} page={page} slotProps={{ select: { 'aria-label': 'rows per page', }, actions: { showFirstButton: true, showLastButton: true, }, }} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> </tr> </tfoot> </table> </Root> ); } const blue = { 200: '#A5D8FF', 400: '#3399FF', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Root = styled('div')( ({ theme }) => ` table { font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; width: 100%; background-color: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; box-shadow: 0px 2px 16px ${ theme.palette.mode === 'dark' ? grey[900] : grey[200] }; border-radius: 12px; overflow: hidden; border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; } td, th { padding: 16px; } th { background-color: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; } `, ); const CustomTablePagination = styled(TablePagination)( ({ theme }) => ` & .${classes.spacer} { display: none; } & .${classes.toolbar} { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; background-color: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; @media (min-width: 768px) { flex-direction: row; align-items: center; } } & .${classes.selectLabel} { margin: 0; } & .${classes.select}{ padding: 2px; border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; border-radius: 50px; background-color: transparent; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; &:hover { background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[50]}; } &:focus { outline: 1px solid ${theme.palette.mode === 'dark' ? blue[400] : blue[200]}; } } & .${classes.displayedRows} { margin: 0; @media (min-width: 768px) { margin-left: auto; } } & .${classes.actions} { padding: 2px; border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; border-radius: 50px; text-align: center; } & .${classes.actions} > button { margin: 0 8px; border: transparent; border-radius: 4px; background-color: transparent; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; &:hover { background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[50]}; } &:focus { outline: 1px solid ${theme.palette.mode === 'dark' ? blue[400] : blue[200]}; } &:disabled { opacity: 0.3; } } `, );
516
0
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/UnstyledPaginationIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/UnstyledPaginationIntroduction/system/index.tsx
import * as React from 'react'; import { styled } from '@mui/system'; import { TablePagination, tablePaginationClasses as classes, } from '@mui/base/TablePagination'; export default function UnstyledPaginationIntroduction() { const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); const handleChangePage = ( event: React.MouseEvent<HTMLButtonElement> | null, newPage: number, ) => { setPage(newPage); }; const handleChangeRowsPerPage = ( event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, ) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; return ( <Root sx={{ width: 500, maxWidth: '100%' }}> <table aria-label="custom pagination table"> <tfoot> <tr> <CustomTablePagination rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]} colSpan={3} count={13} rowsPerPage={rowsPerPage} page={page} slotProps={{ select: { 'aria-label': 'rows per page', }, actions: { showFirstButton: true, showLastButton: true, }, }} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> </tr> </tfoot> </table> </Root> ); } const blue = { 200: '#A5D8FF', 400: '#3399FF', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Root = styled('div')( ({ theme }) => ` table { font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; width: 100%; background-color: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; box-shadow: 0px 2px 16px ${ theme.palette.mode === 'dark' ? grey[900] : grey[200] }; border-radius: 12px; overflow: hidden; border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; } td, th { padding: 16px; } th { background-color: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; } `, ); const CustomTablePagination = styled(TablePagination)( ({ theme }) => ` & .${classes.spacer} { display: none; } & .${classes.toolbar} { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; background-color: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; @media (min-width: 768px) { flex-direction: row; align-items: center; } } & .${classes.selectLabel} { margin: 0; } & .${classes.select}{ padding: 2px; border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; border-radius: 50px; background-color: transparent; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; &:hover { background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[50]}; } &:focus { outline: 1px solid ${theme.palette.mode === 'dark' ? blue[400] : blue[200]}; } } & .${classes.displayedRows} { margin: 0; @media (min-width: 768px) { margin-left: auto; } } & .${classes.actions} { padding: 2px; border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; border-radius: 50px; text-align: center; } & .${classes.actions} > button { margin: 0 8px; border: transparent; border-radius: 4px; background-color: transparent; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; &:hover { background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[50]}; } &:focus { outline: 1px solid ${theme.palette.mode === 'dark' ? blue[400] : blue[200]}; } &:disabled { opacity: 0.3; } } `, );
517
0
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/UnstyledPaginationIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/UnstyledPaginationIntroduction/tailwind/index.js
import * as React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; import { useTheme } from '@mui/system'; import { TablePagination } from '@mui/base/TablePagination'; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } export default function UnstyledPaginationIntroduction() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); const handleChangePage = (event, newPage) => { setPage(newPage); }; const handleChangeRowsPerPage = (event) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; return ( <div className={isDarkMode ? 'dark' : ''} style={{ width: 500, maxWidth: '100%' }} > <table aria-label="custom pagination table" className="text-sm font-sans [&>th]:p-4 [&>td]:p-4 border border-solid border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 rounded-xl shadow-md w-full" > <tfoot> <tr> <CustomTablePagination rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]} colSpan={3} count={13} rowsPerPage={rowsPerPage} page={page} slotProps={{ select: { 'aria-label': 'rows per page', }, actions: { showFirstButton: true, showLastButton: true, }, }} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> </tr> </tfoot> </table> </div> ); } const resolveSlotProps = (fn, args) => (typeof fn === 'function' ? fn(args) : fn); const CustomTablePagination = React.forwardRef((props, ref) => { return ( <TablePagination ref={ref} {...props} className={clsx('CustomTablePagination p-4', props.className)} slotProps={{ ...props.slotProps, select: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.select, ownerState, ); return { ...resolvedSlotProps, className: clsx( 'py-0.5 px-1.5 border border-solid border-slate-200 dark:border-slate-800 rounded-3xl bg-transparent hover:bg-slate-20 hover:dark:bg-slate-800 focus:outline-0 focus:shadow-outline-purple-xs', resolvedSlotProps?.className, ), }; }, actions: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.actions, ownerState, ); return { ...resolvedSlotProps, className: clsx( 'p-0.5 border border-solid border-slate-200 dark:border-slate-800 rounded-3xl text-center [&>button]:my-0 [&>button]:mx-2 [&>button]:border-none [&>button]:rounded-sm [&>button]:bg-transparent [&>button:hover]:bg-slate-50 [&>button:hover]:dark:bg-slate-800 [&>button:focus]:outline-0 [&>button:focus]:shadow-outline-purple-xs', resolvedSlotProps?.className, ), }; }, spacer: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.spacer, ownerState, ); return { ...resolvedSlotProps, className: clsx('hidden', resolvedSlotProps?.className), }; }, toolbar: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.toolbar, ownerState, ); return { ...resolvedSlotProps, className: clsx( 'flex flex-col items-start gap-2.5 md:flex-row md:items-center', resolvedSlotProps?.className, ), }; }, selectLabel: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.selectLabel, ownerState, ); return { ...resolvedSlotProps, className: clsx('m-0', resolvedSlotProps?.className), }; }, displayedRows: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.displayedRows, ownerState, ); return { ...resolvedSlotProps, className: clsx('m-0 md:ml-auto', resolvedSlotProps?.className), }; }, }} /> ); }); CustomTablePagination.propTypes = { className: PropTypes.string, /** * The props used for each slot inside the TablePagination. * @default {} */ slotProps: PropTypes.shape({ actions: PropTypes.oneOfType([ PropTypes.func, PropTypes.shape({ count: PropTypes.number, direction: PropTypes.oneOf(['ltr', 'rtl']), getItemAriaLabel: PropTypes.func, onPageChange: PropTypes.func, page: PropTypes.number, rowsPerPage: PropTypes.number, showFirstButton: PropTypes.bool, showLastButton: PropTypes.bool, slotProps: PropTypes.shape({ backButton: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), firstButton: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), lastButton: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), nextButton: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), }), slots: PropTypes.shape({ backButton: PropTypes.elementType, backPageIcon: PropTypes.elementType, firstButton: PropTypes.elementType, firstPageIcon: PropTypes.elementType, lastButton: PropTypes.elementType, lastPageIcon: PropTypes.elementType, nextButton: PropTypes.elementType, nextPageIcon: PropTypes.elementType, root: PropTypes.elementType, }), }), ]), displayedRows: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), menuItem: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), select: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), selectLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), spacer: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), toolbar: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), }), };
518
0
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/UnstyledPaginationIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/table-pagination/UnstyledPaginationIntroduction/tailwind/index.tsx
import * as React from 'react'; import clsx from 'clsx'; import { useTheme } from '@mui/system'; import { TablePagination, TablePaginationProps } from '@mui/base/TablePagination'; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } export default function UnstyledPaginationIntroduction() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); const handleChangePage = ( event: React.MouseEvent<HTMLButtonElement> | null, newPage: number, ) => { setPage(newPage); }; const handleChangeRowsPerPage = ( event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, ) => { setRowsPerPage(parseInt(event.target.value, 10)); setPage(0); }; return ( <div className={isDarkMode ? 'dark' : ''} style={{ width: 500, maxWidth: '100%' }} > <table aria-label="custom pagination table" className="text-sm font-sans [&>th]:p-4 [&>td]:p-4 border border-solid border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 rounded-xl shadow-md w-full" > <tfoot> <tr> <CustomTablePagination rowsPerPageOptions={[5, 10, 25, { label: 'All', value: -1 }]} colSpan={3} count={13} rowsPerPage={rowsPerPage} page={page} slotProps={{ select: { 'aria-label': 'rows per page', }, actions: { showFirstButton: true, showLastButton: true, }, }} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> </tr> </tfoot> </table> </div> ); } const resolveSlotProps = (fn: any, args: any) => typeof fn === 'function' ? fn(args) : fn; const CustomTablePagination = React.forwardRef< HTMLTableCellElement, TablePaginationProps >((props, ref) => { return ( <TablePagination ref={ref} {...props} className={clsx('CustomTablePagination p-4', props.className)} slotProps={{ ...props.slotProps, select: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.select, ownerState, ); return { ...resolvedSlotProps, className: clsx( 'py-0.5 px-1.5 border border-solid border-slate-200 dark:border-slate-800 rounded-3xl bg-transparent hover:bg-slate-20 hover:dark:bg-slate-800 focus:outline-0 focus:shadow-outline-purple-xs', resolvedSlotProps?.className, ), }; }, actions: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.actions, ownerState, ); return { ...resolvedSlotProps, className: clsx( 'p-0.5 border border-solid border-slate-200 dark:border-slate-800 rounded-3xl text-center [&>button]:my-0 [&>button]:mx-2 [&>button]:border-none [&>button]:rounded-sm [&>button]:bg-transparent [&>button:hover]:bg-slate-50 [&>button:hover]:dark:bg-slate-800 [&>button:focus]:outline-0 [&>button:focus]:shadow-outline-purple-xs', resolvedSlotProps?.className, ), }; }, spacer: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.spacer, ownerState, ); return { ...resolvedSlotProps, className: clsx('hidden', resolvedSlotProps?.className), }; }, toolbar: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.toolbar, ownerState, ); return { ...resolvedSlotProps, className: clsx( 'flex flex-col items-start gap-2.5 md:flex-row md:items-center', resolvedSlotProps?.className, ), }; }, selectLabel: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.selectLabel, ownerState, ); return { ...resolvedSlotProps, className: clsx('m-0', resolvedSlotProps?.className), }; }, displayedRows: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.displayedRows, ownerState, ); return { ...resolvedSlotProps, className: clsx('m-0 md:ml-auto', resolvedSlotProps?.className), }; }, }} /> ); });
519
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/tabs/KeyboardNavigation.js
import * as React from 'react'; import { styled } from '@mui/system'; import { buttonClasses } from '@mui/base/Button'; import { Tabs } from '@mui/base/Tabs'; import { Tab as BaseTab, tabClasses } from '@mui/base/Tab'; import { TabsList as BaseTabsList } from '@mui/base/TabsList'; export default function KeyboardNavigation() { return ( <div> <p>Selection following focus:</p> <Tabs defaultValue={1} aria-label="Tabs where selection follows focus" selectionFollowsFocus > <TabsList> <Tab value={1}>One</Tab> <Tab value={2}>Two</Tab> <Tab value={3}>Three</Tab> </TabsList> </Tabs> <p>Selection independent of focus (default behavior):</p> <Tabs defaultValue={1} aria-label="Tabs where selection does not follow focus"> <TabsList> <Tab value={1}>One</Tab> <Tab value={2}>Two</Tab> <Tab value={3}>Three</Tab> </TabsList> </Tabs> </div> ); } const blue = { 50: '#F0F7FF', 100: '#C2E0FF', 200: '#80BFFF', 300: '#66B2FF', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 700: '#0059B2', 800: '#004C99', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Tab = styled(BaseTab)` font-family: 'IBM Plex Sans', sans-serif; color: white; cursor: pointer; font-size: 0.875rem; font-weight: bold; background-color: transparent; width: 100%; padding: 12px; margin: 6px; border: none; border-radius: 7px; display: flex; justify-content: center; &:hover { background-color: ${blue[400]}; } &:focus { color: #fff; outline: 3px solid ${blue[200]}; } &.${tabClasses.selected} { background-color: #fff; color: ${blue[600]}; } &.${buttonClasses.disabled} { opacity: 0.5; cursor: not-allowed; } `; const TabsList = styled(BaseTabsList)( ({ theme }) => ` min-width: 400px; background-color: ${blue[500]}; border-radius: 12px; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; align-content: space-between; box-shadow: 0px 4px 8px ${theme.palette.mode === 'dark' ? grey[900] : grey[200]}; `, );
520
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/tabs/KeyboardNavigation.tsx
import * as React from 'react'; import { styled } from '@mui/system'; import { buttonClasses } from '@mui/base/Button'; import { Tabs } from '@mui/base/Tabs'; import { Tab as BaseTab, tabClasses } from '@mui/base/Tab'; import { TabsList as BaseTabsList } from '@mui/base/TabsList'; export default function KeyboardNavigation() { return ( <div> <p>Selection following focus:</p> <Tabs defaultValue={1} aria-label="Tabs where selection follows focus" selectionFollowsFocus > <TabsList> <Tab value={1}>One</Tab> <Tab value={2}>Two</Tab> <Tab value={3}>Three</Tab> </TabsList> </Tabs> <p>Selection independent of focus (default behavior):</p> <Tabs defaultValue={1} aria-label="Tabs where selection does not follow focus"> <TabsList> <Tab value={1}>One</Tab> <Tab value={2}>Two</Tab> <Tab value={3}>Three</Tab> </TabsList> </Tabs> </div> ); } const blue = { 50: '#F0F7FF', 100: '#C2E0FF', 200: '#80BFFF', 300: '#66B2FF', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 700: '#0059B2', 800: '#004C99', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Tab = styled(BaseTab)` font-family: 'IBM Plex Sans', sans-serif; color: white; cursor: pointer; font-size: 0.875rem; font-weight: bold; background-color: transparent; width: 100%; padding: 12px; margin: 6px; border: none; border-radius: 7px; display: flex; justify-content: center; &:hover { background-color: ${blue[400]}; } &:focus { color: #fff; outline: 3px solid ${blue[200]}; } &.${tabClasses.selected} { background-color: #fff; color: ${blue[600]}; } &.${buttonClasses.disabled} { opacity: 0.5; cursor: not-allowed; } `; const TabsList = styled(BaseTabsList)( ({ theme }) => ` min-width: 400px; background-color: ${blue[500]}; border-radius: 12px; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; align-content: space-between; box-shadow: 0px 4px 8px ${theme.palette.mode === 'dark' ? grey[900] : grey[200]}; `, );
521
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsBasic.js
import * as React from 'react'; import { Tabs } from '@mui/base/Tabs'; import { TabsList } from '@mui/base/TabsList'; import { TabPanel } from '@mui/base/TabPanel'; import { Tab } from '@mui/base/Tab'; export default function UnstyledTabsBasic() { return ( <Tabs defaultValue={1}> <TabsList> <Tab value={1}>One</Tab> <Tab value={2}>Two</Tab> <Tab value={3}>Three</Tab> </TabsList> <TabPanel value={1}>First page</TabPanel> <TabPanel value={2}>Second page</TabPanel> <TabPanel value={3}>Third page</TabPanel> </Tabs> ); }
522
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsBasic.tsx
import * as React from 'react'; import { Tabs } from '@mui/base/Tabs'; import { TabsList } from '@mui/base/TabsList'; import { TabPanel } from '@mui/base/TabPanel'; import { Tab } from '@mui/base/Tab'; export default function UnstyledTabsBasic() { return ( <Tabs defaultValue={1}> <TabsList> <Tab value={1}>One</Tab> <Tab value={2}>Two</Tab> <Tab value={3}>Three</Tab> </TabsList> <TabPanel value={1}>First page</TabPanel> <TabPanel value={2}>Second page</TabPanel> <TabPanel value={3}>Third page</TabPanel> </Tabs> ); }
523
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsBasic.tsx.preview
<Tabs defaultValue={1}> <TabsList> <Tab value={1}>One</Tab> <Tab value={2}>Two</Tab> <Tab value={3}>Three</Tab> </TabsList> <TabPanel value={1}>First page</TabPanel> <TabPanel value={2}>Second page</TabPanel> <TabPanel value={3}>Third page</TabPanel> </Tabs>
524
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsRouting.js
import * as React from 'react'; import PropTypes from 'prop-types'; import { Tabs } from '@mui/base/Tabs'; import { Tab as BaseTab, tabClasses } from '@mui/base/Tab'; import { TabsList as BaseTabsList } from '@mui/base/TabsList'; import { MemoryRouter, Route, Routes, Link, matchPath, useLocation, } from 'react-router-dom'; import { StaticRouter } from 'react-router-dom/server'; import { styled } from '@mui/system'; function Router(props) { const { children } = props; if (typeof window === 'undefined') { return <StaticRouter location="/drafts">{children}</StaticRouter>; } return ( <MemoryRouter initialEntries={['/drafts']} initialIndex={0}> {children} </MemoryRouter> ); } Router.propTypes = { children: PropTypes.node, }; function useRouteMatch(patterns) { const { pathname } = useLocation(); for (let i = 0; i < patterns.length; i += 1) { const pattern = patterns[i]; const possibleMatch = matchPath(pattern, pathname); if (possibleMatch !== null) { return possibleMatch; } } return null; } function MyTabs() { // You need to provide the routes in descendant order. // This means that if you have nested routes like: // users, users/new, users/edit. // Then the order should be ['users/add', 'users/edit', 'users']. const routeMatch = useRouteMatch(['/inbox/:id', '/drafts', '/trash']); const currentTab = routeMatch?.pattern?.path; return ( <Tabs value={currentTab}> <TabsList> <Tab value="/inbox/:id" to="/inbox/1" slots={{ root: RouterLink }}> Inbox </Tab> <Tab value="/drafts" to="/drafts" slots={{ root: RouterLink }}> Drafts </Tab> <Tab value="/trash" to="/trash" slots={{ root: RouterLink }}> Trash </Tab> </TabsList> </Tabs> ); } function CurrentRoute() { const location = useLocation(); return <RouteDisplay>Current route: {location.pathname}</RouteDisplay>; } export default function UnstyledTabsRouting() { return ( <Router> <div> <Routes> <Route path="*" element={<CurrentRoute />} /> </Routes> <MyTabs /> </div> </Router> ); } const blue = { 50: '#F0F7FF', 100: '#C2E0FF', 200: '#80BFFF', 300: '#66B2FF', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 700: '#0059B2', 800: '#004C99', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const RouteDisplay = styled('p')` font-size: 0.75rem; color: ${grey[500]}; `; const RouterLink = React.forwardRef(function RouterLink(props, ref) { const { ownerState, ...other } = props; return <Link {...other} ref={ref} />; }); RouterLink.propTypes = { ownerState: PropTypes.object.isRequired, }; const Tab = styled(BaseTab)` font-family: 'IBM Plex Sans', sans-serif; color: #fff; cursor: pointer; font-size: 0.875rem; font-weight: 600; text-decoration: none; background-color: transparent; width: 100%; padding: 10px 12px; margin: 6px; border: none; border-radius: 7px; display: flex; justify-content: center; &:hover { background-color: ${blue[400]}; } &:focus { color: #fff; outline: 3px solid ${blue[200]}; } &.${tabClasses.selected} { background-color: #fff; color: ${blue[600]}; } `; const TabsList = styled(BaseTabsList)( ({ theme }) => ` min-width: 400px; background-color: ${blue[500]}; border-radius: 12px; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; align-content: space-between; box-shadow: 0px 4px 30px ${theme.palette.mode === 'dark' ? grey[900] : grey[200]}; `, );
525
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsRouting.tsx
import * as React from 'react'; import { Tabs } from '@mui/base/Tabs'; import { Tab as BaseTab, TabRootSlotProps, tabClasses } from '@mui/base/Tab'; import { TabsList as BaseTabsList } from '@mui/base/TabsList'; import { MemoryRouter, Route, Routes, Link, matchPath, useLocation, } from 'react-router-dom'; import { StaticRouter } from 'react-router-dom/server'; import { styled } from '@mui/system'; function Router(props: { children?: React.ReactNode }) { const { children } = props; if (typeof window === 'undefined') { return <StaticRouter location="/drafts">{children}</StaticRouter>; } return ( <MemoryRouter initialEntries={['/drafts']} initialIndex={0}> {children} </MemoryRouter> ); } function useRouteMatch(patterns: readonly string[]) { const { pathname } = useLocation(); for (let i = 0; i < patterns.length; i += 1) { const pattern = patterns[i]; const possibleMatch = matchPath(pattern, pathname); if (possibleMatch !== null) { return possibleMatch; } } return null; } function MyTabs() { // You need to provide the routes in descendant order. // This means that if you have nested routes like: // users, users/new, users/edit. // Then the order should be ['users/add', 'users/edit', 'users']. const routeMatch = useRouteMatch(['/inbox/:id', '/drafts', '/trash']); const currentTab = routeMatch?.pattern?.path; return ( <Tabs value={currentTab}> <TabsList> <Tab value="/inbox/:id" to="/inbox/1" slots={{ root: RouterLink }}> Inbox </Tab> <Tab value="/drafts" to="/drafts" slots={{ root: RouterLink }}> Drafts </Tab> <Tab value="/trash" to="/trash" slots={{ root: RouterLink }}> Trash </Tab> </TabsList> </Tabs> ); } function CurrentRoute() { const location = useLocation(); return <RouteDisplay>Current route: {location.pathname}</RouteDisplay>; } export default function UnstyledTabsRouting() { return ( <Router> <div> <Routes> <Route path="*" element={<CurrentRoute />} /> </Routes> <MyTabs /> </div> </Router> ); } const blue = { 50: '#F0F7FF', 100: '#C2E0FF', 200: '#80BFFF', 300: '#66B2FF', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 700: '#0059B2', 800: '#004C99', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const RouteDisplay = styled('p')` font-size: 0.75rem; color: ${grey[500]}; `; const RouterLink = React.forwardRef(function RouterLink( props: TabRootSlotProps & { to: string }, ref: React.Ref<HTMLAnchorElement>, ) { const { ownerState, ...other } = props; return <Link {...other} ref={ref} />; }); const Tab = styled(BaseTab)` font-family: 'IBM Plex Sans', sans-serif; color: #fff; cursor: pointer; font-size: 0.875rem; font-weight: 600; text-decoration: none; background-color: transparent; width: 100%; padding: 10px 12px; margin: 6px; border: none; border-radius: 7px; display: flex; justify-content: center; &:hover { background-color: ${blue[400]}; } &:focus { color: #fff; outline: 3px solid ${blue[200]}; } &.${tabClasses.selected} { background-color: #fff; color: ${blue[600]}; } `; const TabsList = styled(BaseTabsList)( ({ theme }) => ` min-width: 400px; background-color: ${blue[500]}; border-radius: 12px; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; align-content: space-between; box-shadow: 0px 4px 30px ${theme.palette.mode === 'dark' ? grey[900] : grey[200]}; `, );
526
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsRouting.tsx.preview
<Router> <div> <Routes> <Route path="*" element={<CurrentRoute />} /> </Routes> <MyTabs /> </div> </Router>
527
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsVertical.js
import * as React from 'react'; import { styled } from '@mui/system'; import { Tabs as BaseTabs } from '@mui/base/Tabs'; import { TabsList as BaseTabsList } from '@mui/base/TabsList'; import { TabPanel as BaseTabPanel } from '@mui/base/TabPanel'; import { buttonClasses } from '@mui/base/Button'; import { Tab as BaseTab, tabClasses } from '@mui/base/Tab'; export default function UnstyledTabsVertical() { return ( <Tabs defaultValue={0} orientation="vertical"> <TabsList> <Tab>One</Tab> <Tab>Two</Tab> <Tab>Three</Tab> </TabsList> <TabPanel value={0}>First page</TabPanel> <TabPanel value={1}>Second page</TabPanel> <TabPanel value={2}>Third page</TabPanel> </Tabs> ); } const blue = { 50: '#F0F7FF', 100: '#C2E0FF', 200: '#80BFFF', 300: '#66B2FF', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 700: '#0059B2', 800: '#004C99', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Tab = styled(BaseTab)` font-family: 'IBM Plex Sans', sans-serif; color: white; cursor: pointer; font-size: 0.875rem; font-weight: bold; background-color: transparent; width: 100%; padding: 12px; border: none; border-radius: 7px; display: flex; justify-content: center; &:hover { background-color: ${blue[400]}; } &:focus { color: #fff; outline: 3px solid ${blue[200]}; } &.${buttonClasses.focusVisible} { background-color: #fff; color: ${blue[600]}; } &.${tabClasses.disabled} { opacity: 0.5; cursor: not-allowed; } &.${tabClasses.selected} { background-color: #fff; color: ${blue[600]}; } `; const TabPanel = styled(BaseTabPanel)` width: 100%; font-family: 'IBM Plex Sans', sans-serif; font-size: 0.875rem; `; const Tabs = styled(BaseTabs)` display: flex; gap: 16px; width: 200px; `; const TabsList = styled(BaseTabsList)( ({ theme }) => ` min-width: 80px; background-color: ${blue[500]}; border-radius: 12px; margin-bottom: 16px; display: flex; padding: 6px; gap: 12px; flex-direction: column; align-items: center; justify-content: center; align-content: space-between; box-shadow: 0px 4px 8px ${theme.palette.mode === 'dark' ? grey[900] : grey[200]}; `, );
528
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsVertical.tsx
import * as React from 'react'; import { styled } from '@mui/system'; import { Tabs as BaseTabs } from '@mui/base/Tabs'; import { TabsList as BaseTabsList } from '@mui/base/TabsList'; import { TabPanel as BaseTabPanel } from '@mui/base/TabPanel'; import { buttonClasses } from '@mui/base/Button'; import { Tab as BaseTab, tabClasses } from '@mui/base/Tab'; export default function UnstyledTabsVertical() { return ( <Tabs defaultValue={0} orientation="vertical"> <TabsList> <Tab>One</Tab> <Tab>Two</Tab> <Tab>Three</Tab> </TabsList> <TabPanel value={0}>First page</TabPanel> <TabPanel value={1}>Second page</TabPanel> <TabPanel value={2}>Third page</TabPanel> </Tabs> ); } const blue = { 50: '#F0F7FF', 100: '#C2E0FF', 200: '#80BFFF', 300: '#66B2FF', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 700: '#0059B2', 800: '#004C99', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Tab = styled(BaseTab)` font-family: 'IBM Plex Sans', sans-serif; color: white; cursor: pointer; font-size: 0.875rem; font-weight: bold; background-color: transparent; width: 100%; padding: 12px; border: none; border-radius: 7px; display: flex; justify-content: center; &:hover { background-color: ${blue[400]}; } &:focus { color: #fff; outline: 3px solid ${blue[200]}; } &.${buttonClasses.focusVisible} { background-color: #fff; color: ${blue[600]}; } &.${tabClasses.disabled} { opacity: 0.5; cursor: not-allowed; } &.${tabClasses.selected} { background-color: #fff; color: ${blue[600]}; } `; const TabPanel = styled(BaseTabPanel)` width: 100%; font-family: 'IBM Plex Sans', sans-serif; font-size: 0.875rem; `; const Tabs = styled(BaseTabs)` display: flex; gap: 16px; width: 200px; `; const TabsList = styled(BaseTabsList)( ({ theme }) => ` min-width: 80px; background-color: ${blue[500]}; border-radius: 12px; margin-bottom: 16px; display: flex; padding: 6px; gap: 12px; flex-direction: column; align-items: center; justify-content: center; align-content: space-between; box-shadow: 0px 4px 8px ${theme.palette.mode === 'dark' ? grey[900] : grey[200]}; `, );
529
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsVertical.tsx.preview
<Tabs defaultValue={0} orientation="vertical"> <TabsList> <Tab>One</Tab> <Tab>Two</Tab> <Tab>Three</Tab> </TabsList> <TabPanel value={0}>First page</TabPanel> <TabPanel value={1}>Second page</TabPanel> <TabPanel value={2}>Third page</TabPanel> </Tabs>
530
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/tabs/tabs.md
--- productId: base-ui title: React Tabs components components: Tabs, Tab, TabPanel, TabsList hooks: useTab, useTabPanel, useTabs, useTabsList githubLabel: 'component: tabs' waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/tabs/ --- # Tabs <p class="description">Tabs are UI elements for organizing and navigating between groups of related content.</p> {{"component": "modules/components/ComponentLinkHeader.js", "design": false}} {{"component": "modules/components/ComponentPageTabs.js"}} ## Introduction Tabs are implemented using a collection of related components: - `<Tab />` - the tab element itself. Clicking on a tab displays its corresponding panel. - `<TabsList />` - the container that houses the tabs. Responsible for handling focus and keyboard navigation between tabs. - `<TabPanel />` - the card that hosts the content associated with a tab. - `<Tabs />` - the top-level component that wraps the Tabs List and Tab Panel components so that tabs and their panels can communicate with one another. {{"demo": "UnstyledTabsIntroduction", "defaultCodeOpen": false, "bg": "gradient"}} ## Components ```jsx import { Tab } from '@mui/base/Tab'; import { TabsList } from '@mui/base/TabsList'; import { TabPanel } from '@mui/base/TabPanel'; import { Tabs } from '@mui/base/Tabs'; ``` By default, Tab components and their corresponding panels are **zero-indexed** (i.e. the first tab has a `value` of `0`, then `1`, `2`, etc.). Clicking on a given Tab opens the panel with the same `value`, which corresponds to the order in which each component is nested within its container. Though not required, you can add the `value` prop to the Tab and Tab Panel to take control over how these components are associated with one another. The following demo omits the `value` prop from the Tab components, and also defines `0` as the `defaultValue` for the Tabs component, which sets the first Tab and Panel as the defaults: {{"demo": "UnstyledTabsBasic.js"}} The next demo shows how to apply custom styles to a set of tabs: {{"demo": "UnstyledTabsCustomized"}} ### Anatomy The Tab components are each composed of a root slot with no interior slots: ```html <div class="Tabs-root"> <div class="TabsList-root"> <button class="Tab-root">First tab</button> <button class="Tab-root">Second tab</button> <button class="Tab-root">Third tab</button> </div> <div class="TabPanel-root">First panel</div> <div class="TabPanel-root">Second panel</div> <div class="TabPanel-root">Third panel</div> </div> ``` ### Custom structure Use the `slots` prop to override the root or any other interior slot: ```jsx <Tab slots={{ root: 'span' }} /> ``` If you provide a non-interactive element such as a `<span>`, the Tab components will automatically add the necessary accessibility attributes. :::info The `slots` prop is available on all non-utility Base components. See [Overriding component structure](/base-ui/guides/overriding-component-structure/) for full details. ::: ## Customization ### Vertical Tab components can be arranged vertically as well as horizontally. When vertical, you must set `orientation="vertical"` on the `<Tabs />` component so the user can navigate with the up and down arrow keys (rather than the default left-to-right behavior for horizontal tabs). {{"demo": "UnstyledTabsVertical.js"}} ### Usage with TypeScript In TypeScript, you can specify the custom component type used in the `slots.root` as a generic parameter of the unstyled component. This way, you can safely provide the custom root's props directly on the component: ```tsx <Tab<typeof CustomComponent> slots={{ root: CustomComponent }} customProp /> ``` The same applies for props specific to custom primitive elements: ```tsx <Tab<'button'> slots={{ root: 'button' }} onClick={() => {}} /> ``` ### Third-party routing library A common use case for tabs is to implement client-side navigation that doesn't require an HTTP round-trip to the server. The Tab component provides the `slots` prop to handle this, as shown below: {{"demo": "UnstyledTabsRouting.js"}} ## Accessibility (WAI-ARIA: https://www.w3.org/WAI/ARIA/apg/patterns/tabs/) The following steps are necessary to make the Tab component suite accessible to assistive technology: 1. Label `<Tabs />` with `aria-label` or `aria-labelledby`. 2. Connect each `<Tab />` to its corresponding `<TabPanel />` by setting the correct `id`, `aria-controls` and `aria-labelledby`. The demos below illustrate the proper use of ARIA labels. ### Keyboard navigation By default, when using keyboard navigation, the Tab components open via **manual activation**—that is, the next panel is displayed only after the user activates the tab with either <kbd class="key">Space</kbd>, <kbd class="key">Enter</kbd>, or a mouse click. This is the preferable behavior for tabs in most cases, according to [the WAI-ARIA authoring practices](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/). Alternatively, you can set the panels to be displayed automatically when their corresponding tabs are in focus—this behavior of the selection following the focus is known as **automatic activation**. To enable automatic activation, pass the `selectionFollowsFocus` prop to the `<Tabs />` component: ```jsx /* Tabs where selection follows focus */ <Tabs selectionFollowsFocus /> ``` The following demo pair illustrates the difference between manual and automatic activation. Move the focus to a tab in either demo and navigate with the arrow keys to observe the difference: {{"demo": "KeyboardNavigation.js"}}
531
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsCustomized
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsCustomized/css/index.js
import * as React from 'react'; import { useTheme } from '@mui/system'; import { Tabs } from '@mui/base/Tabs'; import { TabsList } from '@mui/base/TabsList'; import { TabPanel } from '@mui/base/TabPanel'; import { buttonClasses } from '@mui/base/Button'; import { Tab, tabClasses } from '@mui/base/Tab'; export default function UnstyledTabsCustomized() { return ( <React.Fragment> <Tabs defaultValue={1}> <TabsList className="CustomTabsList"> <Tab className="CustomTab" value={1}> One </Tab> <Tab className="CustomTab" value={2}> Two </Tab> <Tab className="CustomTab" value={3}> Three </Tab> </TabsList> <TabPanel className="CustomTabPanel" value={1}> First page </TabPanel> <TabPanel className="CustomTabPanel" value={2}> Second page </TabPanel> <TabPanel className="CustomTabPanel" value={3}> Third page </TabPanel> </Tabs> <Styles /> </React.Fragment> ); } const cyan = { 50: '#E9F8FC', 100: '#BDEBF4', 200: '#99D8E5', 300: '#66BACC', 400: '#1F94AD', 500: '#0D5463', 600: '#094855', 700: '#063C47', 800: '#043039', 900: '#022127', }; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } function Styles() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); return ( <style> {` .CustomTabsList { min-width: 400px; background-color: ${cyan[500]}; border-radius: 12px; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; align-content: space-between; box-shadow: 0px 4px 6px ${ isDarkMode ? 'rgba(0,0,0, 0.4)' : 'rgba(0,0,0, 0.2)' }; } .CustomTab { font-family: 'IBM Plex Sans', sans-serif; color: white; cursor: pointer; font-size: 0.875rem; font-weight: bold; background-color: transparent; width: 100%; line-height: 1.5; padding: 8px 12px; margin: 6px; border: none; border-radius: 8px; display: flex; justify-content: center; } .CustomTab:hover { background-color: ${cyan[400]}; } .CustomTab:focus { color: #fff; outline: 3px solid ${cyan[200]}; } .CustomTab.${tabClasses.selected} { background-color: #fff; color: ${cyan[600]}; } .CustomTab.${buttonClasses.disabled} { opacity: 0.5; cursor: not-allowed; } .CustomTabPanel { width: 100%; font-family: 'IBM Plex Sans', sans-serif; font-size: 0.875rem; } `} </style> ); }
532
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsCustomized
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsCustomized/css/index.tsx
import * as React from 'react'; import { useTheme } from '@mui/system'; import { Tabs } from '@mui/base/Tabs'; import { TabsList } from '@mui/base/TabsList'; import { TabPanel } from '@mui/base/TabPanel'; import { buttonClasses } from '@mui/base/Button'; import { Tab, tabClasses } from '@mui/base/Tab'; export default function UnstyledTabsCustomized() { return ( <React.Fragment> <Tabs defaultValue={1}> <TabsList className="CustomTabsList"> <Tab className="CustomTab" value={1}> One </Tab> <Tab className="CustomTab" value={2}> Two </Tab> <Tab className="CustomTab" value={3}> Three </Tab> </TabsList> <TabPanel className="CustomTabPanel" value={1}> First page </TabPanel> <TabPanel className="CustomTabPanel" value={2}> Second page </TabPanel> <TabPanel className="CustomTabPanel" value={3}> Third page </TabPanel> </Tabs> <Styles /> </React.Fragment> ); } const cyan = { 50: '#E9F8FC', 100: '#BDEBF4', 200: '#99D8E5', 300: '#66BACC', 400: '#1F94AD', 500: '#0D5463', 600: '#094855', 700: '#063C47', 800: '#043039', 900: '#022127', }; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } function Styles() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); return ( <style> {` .CustomTabsList { min-width: 400px; background-color: ${cyan[500]}; border-radius: 12px; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; align-content: space-between; box-shadow: 0px 4px 6px ${ isDarkMode ? 'rgba(0,0,0, 0.4)' : 'rgba(0,0,0, 0.2)' }; } .CustomTab { font-family: 'IBM Plex Sans', sans-serif; color: white; cursor: pointer; font-size: 0.875rem; font-weight: bold; background-color: transparent; width: 100%; line-height: 1.5; padding: 8px 12px; margin: 6px; border: none; border-radius: 8px; display: flex; justify-content: center; } .CustomTab:hover { background-color: ${cyan[400]}; } .CustomTab:focus { color: #fff; outline: 3px solid ${cyan[200]}; } .CustomTab.${tabClasses.selected} { background-color: #fff; color: ${cyan[600]}; } .CustomTab.${buttonClasses.disabled} { opacity: 0.5; cursor: not-allowed; } .CustomTabPanel { width: 100%; font-family: 'IBM Plex Sans', sans-serif; font-size: 0.875rem; } `} </style> ); }
533
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsCustomized
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsCustomized/system/index.js
import * as React from 'react'; import { styled } from '@mui/system'; import { Tabs } from '@mui/base/Tabs'; import { TabsList as BaseTabsList } from '@mui/base/TabsList'; import { TabPanel as BaseTabPanel } from '@mui/base/TabPanel'; import { buttonClasses } from '@mui/base/Button'; import { Tab as BaseTab, tabClasses } from '@mui/base/Tab'; export default function UnstyledTabsCustomized() { return ( <Tabs defaultValue={1}> <TabsList> <Tab value={1}>One</Tab> <Tab value={2}>Two</Tab> <Tab value={3}>Three</Tab> </TabsList> <TabPanel value={1}>First page</TabPanel> <TabPanel value={2}>Second page</TabPanel> <TabPanel value={3}>Third page</TabPanel> </Tabs> ); } const blue = { 50: '#F0F7FF', 100: '#C2E0FF', 200: '#80BFFF', 300: '#66B2FF', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 700: '#0059B2', 800: '#004C99', 900: '#003A75', }; const Tab = styled(BaseTab)` font-family: 'IBM Plex Sans', sans-serif; color: white; cursor: pointer; font-size: 0.875rem; font-weight: bold; background-color: transparent; width: 100%; line-height: 1.5; padding: 8px 12px; margin: 6px; border: none; border-radius: 8px; display: flex; justify-content: center; &:hover { background-color: ${blue[400]}; } &:focus { color: #fff; outline: 3px solid ${blue[200]}; } &.${tabClasses.selected} { background-color: #fff; color: ${blue[600]}; } &.${buttonClasses.disabled} { opacity: 0.5; cursor: not-allowed; } `; const TabPanel = styled(BaseTabPanel)` width: 100%; font-family: 'IBM Plex Sans', sans-serif; font-size: 0.875rem; `; const TabsList = styled(BaseTabsList)( ({ theme }) => ` min-width: 400px; background-color: ${blue[500]}; border-radius: 12px; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; align-content: space-between; box-shadow: 0px 4px 6px ${ theme.palette.mode === 'dark' ? 'rgba(0,0,0, 0.4)' : 'rgba(0,0,0, 0.2)' }; `, );
534
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsCustomized
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsCustomized/system/index.tsx
import * as React from 'react'; import { styled } from '@mui/system'; import { Tabs } from '@mui/base/Tabs'; import { TabsList as BaseTabsList } from '@mui/base/TabsList'; import { TabPanel as BaseTabPanel } from '@mui/base/TabPanel'; import { buttonClasses } from '@mui/base/Button'; import { Tab as BaseTab, tabClasses } from '@mui/base/Tab'; export default function UnstyledTabsCustomized() { return ( <Tabs defaultValue={1}> <TabsList> <Tab value={1}>One</Tab> <Tab value={2}>Two</Tab> <Tab value={3}>Three</Tab> </TabsList> <TabPanel value={1}>First page</TabPanel> <TabPanel value={2}>Second page</TabPanel> <TabPanel value={3}>Third page</TabPanel> </Tabs> ); } const blue = { 50: '#F0F7FF', 100: '#C2E0FF', 200: '#80BFFF', 300: '#66B2FF', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 700: '#0059B2', 800: '#004C99', 900: '#003A75', }; const Tab = styled(BaseTab)` font-family: 'IBM Plex Sans', sans-serif; color: white; cursor: pointer; font-size: 0.875rem; font-weight: bold; background-color: transparent; width: 100%; line-height: 1.5; padding: 8px 12px; margin: 6px; border: none; border-radius: 8px; display: flex; justify-content: center; &:hover { background-color: ${blue[400]}; } &:focus { color: #fff; outline: 3px solid ${blue[200]}; } &.${tabClasses.selected} { background-color: #fff; color: ${blue[600]}; } &.${buttonClasses.disabled} { opacity: 0.5; cursor: not-allowed; } `; const TabPanel = styled(BaseTabPanel)` width: 100%; font-family: 'IBM Plex Sans', sans-serif; font-size: 0.875rem; `; const TabsList = styled(BaseTabsList)( ({ theme }) => ` min-width: 400px; background-color: ${blue[500]}; border-radius: 12px; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; align-content: space-between; box-shadow: 0px 4px 6px ${ theme.palette.mode === 'dark' ? 'rgba(0,0,0, 0.4)' : 'rgba(0,0,0, 0.2)' }; `, );
535
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsCustomized
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsCustomized/system/index.tsx.preview
<Tabs defaultValue={1}> <TabsList> <Tab value={1}>One</Tab> <Tab value={2}>Two</Tab> <Tab value={3}>Three</Tab> </TabsList> <TabPanel value={1}>First page</TabPanel> <TabPanel value={2}>Second page</TabPanel> <TabPanel value={3}>Third page</TabPanel> </Tabs>
536
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsCustomized
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsCustomized/tailwind/index.js
import * as React from 'react'; import { Tabs } from '@mui/base/Tabs'; import { TabsList } from '@mui/base/TabsList'; import { TabPanel } from '@mui/base/TabPanel'; import { Tab } from '@mui/base/Tab'; export default function UnstyledTabsCustomized() { return ( <Tabs defaultValue={1}> <TabsList className="mb-4 rounded-xl bg-purple-500 flex font-sans items-center justify-center content-between min-w-tabs-list shadow-lg"> <Tab slotProps={{ root: ({ selected, disabled }) => ({ className: `font-sans ${ selected ? 'text-purple-500 bg-white' : 'text-white bg-transparent focus:text-white hover:bg-purple-400' } ${ disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer' } text-sm font-bold w-full p-2 m-1.5 border-0 rounded-lg flex justify-center focus:outline-0 focus:shadow-outline-purple-light`, }), }} value={1} > One </Tab> <Tab slotProps={{ root: ({ selected, disabled }) => ({ className: `font-sans ${ selected ? 'text-purple-500 bg-white' : 'text-white bg-transparent focus:text-white hover:bg-purple-400' } ${ disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer' } text-sm font-bold w-full p-2 m-1.5 border-0 rounded-md flex justify-center focus:outline-0 focus:shadow-outline-purple-light`, }), }} value={2} > Two </Tab> <Tab slotProps={{ root: ({ selected, disabled }) => ({ className: `font-sans ${ selected ? 'text-purple-500 bg-white' : 'text-white bg-transparent focus:text-white hover:bg-purple-400' } ${ disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer' } text-sm font-bold w-full p-2 m-1.5 border-0 rounded-md flex justify-center focus:outline-0 focus:shadow-outline-purple-light`, }), }} value={3} > Three </Tab> </TabsList> <TabPanel className="w-full font-sans text-sm" value={1}> First page </TabPanel> <TabPanel className="w-full font-sans text-sm" value={2}> Second page </TabPanel> <TabPanel className="w-full font-sans text-sm" value={3}> Third page </TabPanel> </Tabs> ); }
537
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsCustomized
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsCustomized/tailwind/index.tsx
import * as React from 'react'; import { Tabs } from '@mui/base/Tabs'; import { TabsList } from '@mui/base/TabsList'; import { TabPanel } from '@mui/base/TabPanel'; import { Tab } from '@mui/base/Tab'; export default function UnstyledTabsCustomized() { return ( <Tabs defaultValue={1}> <TabsList className="mb-4 rounded-xl bg-purple-500 flex font-sans items-center justify-center content-between min-w-tabs-list shadow-lg"> <Tab slotProps={{ root: ({ selected, disabled }) => ({ className: `font-sans ${ selected ? 'text-purple-500 bg-white' : 'text-white bg-transparent focus:text-white hover:bg-purple-400' } ${ disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer' } text-sm font-bold w-full p-2 m-1.5 border-0 rounded-lg flex justify-center focus:outline-0 focus:shadow-outline-purple-light`, }), }} value={1} > One </Tab> <Tab slotProps={{ root: ({ selected, disabled }) => ({ className: `font-sans ${ selected ? 'text-purple-500 bg-white' : 'text-white bg-transparent focus:text-white hover:bg-purple-400' } ${ disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer' } text-sm font-bold w-full p-2 m-1.5 border-0 rounded-md flex justify-center focus:outline-0 focus:shadow-outline-purple-light`, }), }} value={2} > Two </Tab> <Tab slotProps={{ root: ({ selected, disabled }) => ({ className: `font-sans ${ selected ? 'text-purple-500 bg-white' : 'text-white bg-transparent focus:text-white hover:bg-purple-400' } ${ disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer' } text-sm font-bold w-full p-2 m-1.5 border-0 rounded-md flex justify-center focus:outline-0 focus:shadow-outline-purple-light`, }), }} value={3} > Three </Tab> </TabsList> <TabPanel className="w-full font-sans text-sm" value={1}> First page </TabPanel> <TabPanel className="w-full font-sans text-sm" value={2}> Second page </TabPanel> <TabPanel className="w-full font-sans text-sm" value={3}> Third page </TabPanel> </Tabs> ); }
538
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction/css/index.js
import * as React from 'react'; import { useTheme } from '@mui/system'; import { Tabs } from '@mui/base/Tabs'; import { TabsList } from '@mui/base/TabsList'; import { TabPanel } from '@mui/base/TabPanel'; import { buttonClasses } from '@mui/base/Button'; import { Tab, tabClasses } from '@mui/base/Tab'; export default function UnstyledTabsIntroduction() { return ( <React.Fragment> <Tabs defaultValue={0}> <TabsList className="CustomTabsListIntroduction"> <Tab className="CustomTabIntroduction" value={0}> My account </Tab> <Tab className="CustomTabIntroduction" value={1}> Profile </Tab> <Tab className="CustomTabIntroduction" value={2}> Language </Tab> </TabsList> <TabPanel className="CustomTabPanelIntroduction" value={0}> My account page </TabPanel> <TabPanel className="CustomTabPanelIntroduction" value={1}> Profile page </TabPanel> <TabPanel className="CustomTabPanelIntroduction" value={2}> Language page </TabPanel> </Tabs> <Styles /> </React.Fragment> ); } const cyan = { 50: '#E9F8FC', 100: '#BDEBF4', 200: '#99D8E5', 300: '#66BACC', 400: '#1F94AD', 500: '#0D5463', 600: '#094855', 700: '#063C47', 800: '#043039', 900: '#022127', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } function Styles() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); return ( <style> {` .CustomTabsListIntroduction { min-width: 400px; background-color: ${cyan[500]}; border-radius: 12px; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; align-content: space-between; box-shadow: 0px 4px 6px ${isDarkMode ? grey[900] : grey[200]}; } .CustomTabIntroduction { font-family: 'IBM Plex Sans', sans-serif; color: #fff; cursor: pointer; font-size: 0.875rem; font-weight: 600; background-color: transparent; width: 100%; padding: 10px 12px; margin: 6px; border: none; border-radius: 7px; display: flex; justify-content: center; } .CustomTabIntroduction:hover { background-color: ${cyan[400]}; } .CustomTabIntroduction:focus { color: #fff; outline: 3px solid ${cyan[200]}; } .CustomTabIntroduction.${tabClasses.selected} { background-color: #fff; color: ${cyan[600]}; } .CustomTabIntroduction.${buttonClasses.disabled} { opacity: 0.5; cursor: not-allowed; } .CustomTabPanelIntroduction { width: 100%; font-family: 'IBM Plex Sans', sans-serif; font-size: 0.875rem; padding: 20px 12px; background: ${isDarkMode ? grey[900] : '#fff'}; border: 1px solid ${isDarkMode ? grey[700] : grey[200]}; border-radius: 12px; opacity: 0.6; } `} </style> ); }
539
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction/css/index.tsx
import * as React from 'react'; import { useTheme } from '@mui/system'; import { Tabs } from '@mui/base/Tabs'; import { TabsList } from '@mui/base/TabsList'; import { TabPanel } from '@mui/base/TabPanel'; import { buttonClasses } from '@mui/base/Button'; import { Tab, tabClasses } from '@mui/base/Tab'; export default function UnstyledTabsIntroduction() { return ( <React.Fragment> <Tabs defaultValue={0}> <TabsList className="CustomTabsListIntroduction"> <Tab className="CustomTabIntroduction" value={0}> My account </Tab> <Tab className="CustomTabIntroduction" value={1}> Profile </Tab> <Tab className="CustomTabIntroduction" value={2}> Language </Tab> </TabsList> <TabPanel className="CustomTabPanelIntroduction" value={0}> My account page </TabPanel> <TabPanel className="CustomTabPanelIntroduction" value={1}> Profile page </TabPanel> <TabPanel className="CustomTabPanelIntroduction" value={2}> Language page </TabPanel> </Tabs> <Styles /> </React.Fragment> ); } const cyan = { 50: '#E9F8FC', 100: '#BDEBF4', 200: '#99D8E5', 300: '#66BACC', 400: '#1F94AD', 500: '#0D5463', 600: '#094855', 700: '#063C47', 800: '#043039', 900: '#022127', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } function Styles() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); return ( <style> {` .CustomTabsListIntroduction { min-width: 400px; background-color: ${cyan[500]}; border-radius: 12px; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; align-content: space-between; box-shadow: 0px 4px 6px ${isDarkMode ? grey[900] : grey[200]}; } .CustomTabIntroduction { font-family: 'IBM Plex Sans', sans-serif; color: #fff; cursor: pointer; font-size: 0.875rem; font-weight: 600; background-color: transparent; width: 100%; padding: 10px 12px; margin: 6px; border: none; border-radius: 7px; display: flex; justify-content: center; } .CustomTabIntroduction:hover { background-color: ${cyan[400]}; } .CustomTabIntroduction:focus { color: #fff; outline: 3px solid ${cyan[200]}; } .CustomTabIntroduction.${tabClasses.selected} { background-color: #fff; color: ${cyan[600]}; } .CustomTabIntroduction.${buttonClasses.disabled} { opacity: 0.5; cursor: not-allowed; } .CustomTabPanelIntroduction { width: 100%; font-family: 'IBM Plex Sans', sans-serif; font-size: 0.875rem; padding: 20px 12px; background: ${isDarkMode ? grey[900] : '#fff'}; border: 1px solid ${isDarkMode ? grey[700] : grey[200]}; border-radius: 12px; opacity: 0.6; } `} </style> ); }
540
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction/system/UnstyledTabsIntroduction.tsx.preview
<Tabs defaultValue={0}> <StyledTabsList> <StyledTab value={0}>My account</StyledTab> <StyledTab value={1}>Profile</StyledTab> <StyledTab value={2}>Language</StyledTab> </StyledTabsList> <StyledTabPanel value={0}>My account page</StyledTabPanel> <StyledTabPanel value={1}>Profile page</StyledTabPanel> <StyledTabPanel value={2}>Language page</StyledTabPanel> </Tabs>
541
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction/system/index.js
import * as React from 'react'; import { styled } from '@mui/system'; import { Tabs } from '@mui/base/Tabs'; import { TabsList as BaseTabsList } from '@mui/base/TabsList'; import { TabPanel as BaseTabPanel } from '@mui/base/TabPanel'; import { buttonClasses } from '@mui/base/Button'; import { Tab as BaseTab, tabClasses } from '@mui/base/Tab'; export default function UnstyledTabsIntroduction() { return ( <Tabs defaultValue={0}> <TabsList> <Tab value={0}>My account</Tab> <Tab value={1}>Profile</Tab> <Tab value={2}>Language</Tab> </TabsList> <TabPanel value={0}>My account page</TabPanel> <TabPanel value={1}>Profile page</TabPanel> <TabPanel value={2}>Language page</TabPanel> </Tabs> ); } const blue = { 50: '#F0F7FF', 100: '#C2E0FF', 200: '#80BFFF', 300: '#66B2FF', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 700: '#0059B2', 800: '#004C99', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Tab = styled(BaseTab)` font-family: 'IBM Plex Sans', sans-serif; color: #fff; cursor: pointer; font-size: 0.875rem; font-weight: 600; background-color: transparent; width: 100%; padding: 10px 12px; margin: 6px; border: none; border-radius: 7px; display: flex; justify-content: center; &:hover { background-color: ${blue[400]}; } &:focus { color: #fff; outline: 3px solid ${blue[200]}; } &.${tabClasses.selected} { background-color: #fff; color: ${blue[600]}; } &.${buttonClasses.disabled} { opacity: 0.5; cursor: not-allowed; } `; const TabPanel = styled(BaseTabPanel)( ({ theme }) => ` width: 100%; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; padding: 20px 12px; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; border-radius: 12px; opacity: 0.6; `, ); const TabsList = styled(BaseTabsList)( ({ theme }) => ` min-width: 400px; background-color: ${blue[500]}; border-radius: 12px; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; align-content: space-between; box-shadow: 0px 4px 30px ${theme.palette.mode === 'dark' ? grey[900] : grey[200]}; `, );
542
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction/system/index.tsx
import * as React from 'react'; import { styled } from '@mui/system'; import { Tabs } from '@mui/base/Tabs'; import { TabsList as BaseTabsList } from '@mui/base/TabsList'; import { TabPanel as BaseTabPanel } from '@mui/base/TabPanel'; import { buttonClasses } from '@mui/base/Button'; import { Tab as BaseTab, tabClasses } from '@mui/base/Tab'; export default function UnstyledTabsIntroduction() { return ( <Tabs defaultValue={0}> <TabsList> <Tab value={0}>My account</Tab> <Tab value={1}>Profile</Tab> <Tab value={2}>Language</Tab> </TabsList> <TabPanel value={0}>My account page</TabPanel> <TabPanel value={1}>Profile page</TabPanel> <TabPanel value={2}>Language page</TabPanel> </Tabs> ); } const blue = { 50: '#F0F7FF', 100: '#C2E0FF', 200: '#80BFFF', 300: '#66B2FF', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 700: '#0059B2', 800: '#004C99', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Tab = styled(BaseTab)` font-family: 'IBM Plex Sans', sans-serif; color: #fff; cursor: pointer; font-size: 0.875rem; font-weight: 600; background-color: transparent; width: 100%; padding: 10px 12px; margin: 6px; border: none; border-radius: 7px; display: flex; justify-content: center; &:hover { background-color: ${blue[400]}; } &:focus { color: #fff; outline: 3px solid ${blue[200]}; } &.${tabClasses.selected} { background-color: #fff; color: ${blue[600]}; } &.${buttonClasses.disabled} { opacity: 0.5; cursor: not-allowed; } `; const TabPanel = styled(BaseTabPanel)( ({ theme }) => ` width: 100%; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; padding: 20px 12px; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; border-radius: 12px; opacity: 0.6; `, ); const TabsList = styled(BaseTabsList)( ({ theme }) => ` min-width: 400px; background-color: ${blue[500]}; border-radius: 12px; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; align-content: space-between; box-shadow: 0px 4px 30px ${theme.palette.mode === 'dark' ? grey[900] : grey[200]}; `, );
543
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction/system/index.tsx.preview
<Tabs defaultValue={0}> <TabsList> <Tab value={0}>My account</Tab> <Tab value={1}>Profile</Tab> <Tab value={2}>Language</Tab> </TabsList> <TabPanel value={0}>My account page</TabPanel> <TabPanel value={1}>Profile page</TabPanel> <TabPanel value={2}>Language page</TabPanel> </Tabs>
544
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.js
import * as React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; import { Tabs } from '@mui/base/Tabs'; import { TabsList as BaseTabsList } from '@mui/base/TabsList'; import { TabPanel as BaseTabPanel } from '@mui/base/TabPanel'; import { Tab as BaseTab } from '@mui/base/Tab'; import { useTheme } from '@mui/system'; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } export default function UnstyledTabsIntroduction() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); return ( <div className={isDarkMode ? 'dark' : ''}> <Tabs defaultValue={0}> <TabsList> <Tab value={0}>My account</Tab> <Tab value={1}>Profile</Tab> <Tab value={2}>Language</Tab> </TabsList> <TabPanel value={0}>My account page</TabPanel> <TabPanel value={1}>Profile page</TabPanel> <TabPanel value={2}>Language page</TabPanel> </Tabs> </div> ); } const resolveSlotProps = (fn, args) => (typeof fn === 'function' ? fn(args) : fn); const TabsList = React.forwardRef((props, ref) => { const { className, ...other } = props; return ( <BaseTabsList ref={ref} className={clsx( 'mb-4 rounded-xl bg-purple-500 flex font-sans items-center justify-center content-between min-w-tabs-list shadow-lg', className, )} {...other} /> ); }); TabsList.propTypes = { className: PropTypes.string, }; const Tab = React.forwardRef((props, ref) => { return ( <BaseTab ref={ref} {...props} slotProps={{ ...props.slotProps, root: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.root, ownerState, ); return { ...resolvedSlotProps, className: clsx( `font-sans ${ ownerState.selected ? 'text-purple-500 bg-white' : 'text-white bg-transparent focus:text-white hover:bg-purple-400' } ${ ownerState.disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer' } text-sm leading-[1.3] font-semibold w-full py-2.5 px-3 m-1.5 border-0 rounded-md flex justify-center focus:outline-0 focus:shadow-outline-purple-light`, resolvedSlotProps?.className, ), }; }, }} /> ); }); Tab.propTypes = { /** * The props used for each slot inside the Tab. * @default {} */ slotProps: PropTypes.shape({ root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), }), }; const TabPanel = React.forwardRef((props, ref) => { const { className, ...other } = props; return ( <BaseTabPanel ref={ref} className={clsx( 'py-5 px-3 bg-white dark:bg-slate-900 border border-solid border-slate-200 dark:border-slate-700 rounded-xl opacity-60 w-full font-sans text-sm', className, )} {...other} /> ); }); TabPanel.propTypes = { className: PropTypes.string, };
545
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.tsx
import * as React from 'react'; import clsx from 'clsx'; import { Tabs } from '@mui/base/Tabs'; import { TabsList as BaseTabsList, TabsListProps } from '@mui/base/TabsList'; import { TabPanel as BaseTabPanel, TabPanelProps } from '@mui/base/TabPanel'; import { Tab as BaseTab, TabProps } from '@mui/base/Tab'; import { useTheme } from '@mui/system'; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } export default function UnstyledTabsIntroduction() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); return ( <div className={isDarkMode ? 'dark' : ''}> <Tabs defaultValue={0}> <TabsList> <Tab value={0}>My account</Tab> <Tab value={1}>Profile</Tab> <Tab value={2}>Language</Tab> </TabsList> <TabPanel value={0}>My account page</TabPanel> <TabPanel value={1}>Profile page</TabPanel> <TabPanel value={2}>Language page</TabPanel> </Tabs> </div> ); } const resolveSlotProps = (fn: any, args: any) => typeof fn === 'function' ? fn(args) : fn; const TabsList = React.forwardRef<HTMLDivElement, TabsListProps>((props, ref) => { const { className, ...other } = props; return ( <BaseTabsList ref={ref} className={clsx( 'mb-4 rounded-xl bg-purple-500 flex font-sans items-center justify-center content-between min-w-tabs-list shadow-lg', className, )} {...other} /> ); }); const Tab = React.forwardRef<HTMLButtonElement, TabProps>((props, ref) => { return ( <BaseTab ref={ref} {...props} slotProps={{ ...props.slotProps, root: (ownerState) => { const resolvedSlotProps = resolveSlotProps( props.slotProps?.root, ownerState, ); return { ...resolvedSlotProps, className: clsx( `font-sans ${ ownerState.selected ? 'text-purple-500 bg-white' : 'text-white bg-transparent focus:text-white hover:bg-purple-400' } ${ ownerState.disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer' } text-sm leading-[1.3] font-semibold w-full py-2.5 px-3 m-1.5 border-0 rounded-md flex justify-center focus:outline-0 focus:shadow-outline-purple-light`, resolvedSlotProps?.className, ), }; }, }} /> ); }); const TabPanel = React.forwardRef<HTMLDivElement, TabPanelProps>((props, ref) => { const { className, ...other } = props; return ( <BaseTabPanel ref={ref} className={clsx( 'py-5 px-3 bg-white dark:bg-slate-900 border border-solid border-slate-200 dark:border-slate-700 rounded-xl opacity-60 w-full font-sans text-sm', className, )} {...other} /> ); });
546
0
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.tsx.preview
<Tabs defaultValue={0}> <TabsList> <Tab value={0}>My account</Tab> <Tab value={1}>Profile</Tab> <Tab value={2}>Language</Tab> </TabsList> <TabPanel value={0}>My account page</TabPanel> <TabPanel value={1}>Profile page</TabPanel> <TabPanel value={2}>Language page</TabPanel> </Tabs>
547
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/EmptyTextarea.js
import * as React from 'react'; import { TextareaAutosize as BaseTextareaAutosize } from '@mui/base/TextareaAutosize'; import { styled } from '@mui/system'; export default function EmptyTextarea() { const blue = { 100: '#DAECFF', 200: '#b6daff', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Textarea = styled(BaseTextareaAutosize)( ({ theme }) => ` width: 320px; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.5; padding: 8px 12px; border-radius: 8px; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; box-shadow: 0px 2px 2px ${theme.palette.mode === 'dark' ? grey[900] : grey[50]}; &:hover { border-color: ${blue[400]}; } &:focus { outline: 0; border-color: ${blue[400]}; box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[600] : blue[200]}; } // firefox &:focus-visible { outline: 0; } `, ); return <Textarea aria-label="empty textarea" placeholder="Empty" />; }
548
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/EmptyTextarea.tsx
import * as React from 'react'; import { TextareaAutosize as BaseTextareaAutosize } from '@mui/base/TextareaAutosize'; import { styled } from '@mui/system'; export default function EmptyTextarea() { const blue = { 100: '#DAECFF', 200: '#b6daff', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Textarea = styled(BaseTextareaAutosize)( ({ theme }) => ` width: 320px; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.5; padding: 8px 12px; border-radius: 8px; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; box-shadow: 0px 2px 2px ${theme.palette.mode === 'dark' ? grey[900] : grey[50]}; &:hover { border-color: ${blue[400]}; } &:focus { outline: 0; border-color: ${blue[400]}; box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[600] : blue[200]}; } // firefox &:focus-visible { outline: 0; } `, ); return <Textarea aria-label="empty textarea" placeholder="Empty" />; }
549
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/EmptyTextarea.tsx.preview
<Textarea aria-label="empty textarea" placeholder="Empty" />
550
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/MaxHeightTextarea.js
import * as React from 'react'; import { TextareaAutosize as BaseTextareaAutosize } from '@mui/base/TextareaAutosize'; import { styled } from '@mui/system'; export default function MaxHeightTextarea() { const blue = { 100: '#DAECFF', 200: '#b6daff', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Textarea = styled(BaseTextareaAutosize)( ({ theme }) => ` width: 320px; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.5; padding: 8px 12px; border-radius: 8px; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; box-shadow: 0px 2px 2px ${theme.palette.mode === 'dark' ? grey[900] : grey[50]}; &:hover { border-color: ${blue[400]}; } &:focus { border-color: ${blue[400]}; box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[600] : blue[200]}; } // firefox &:focus-visible { outline: 0; } `, ); return ( <Textarea maxRows={4} aria-label="maximum height" placeholder="Maximum 4 rows" defaultValue="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." /> ); }
551
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/MaxHeightTextarea.tsx
import * as React from 'react'; import { TextareaAutosize as BaseTextareaAutosize } from '@mui/base/TextareaAutosize'; import { styled } from '@mui/system'; export default function MaxHeightTextarea() { const blue = { 100: '#DAECFF', 200: '#b6daff', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Textarea = styled(BaseTextareaAutosize)( ({ theme }) => ` width: 320px; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.5; padding: 8px 12px; border-radius: 8px; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; box-shadow: 0px 2px 2px ${theme.palette.mode === 'dark' ? grey[900] : grey[50]}; &:hover { border-color: ${blue[400]}; } &:focus { border-color: ${blue[400]}; box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[600] : blue[200]}; } // firefox &:focus-visible { outline: 0; } `, ); return ( <Textarea maxRows={4} aria-label="maximum height" placeholder="Maximum 4 rows" defaultValue="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." /> ); }
552
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/MaxHeightTextarea.tsx.preview
<Textarea maxRows={4} aria-label="maximum height" placeholder="Maximum 4 rows" defaultValue="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." />
553
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/MinHeightTextarea.js
import * as React from 'react'; import { TextareaAutosize as BaseTextareaAutosize } from '@mui/base/TextareaAutosize'; import { styled } from '@mui/system'; export default function MinHeightTextarea() { const blue = { 100: '#DAECFF', 200: '#b6daff', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Textarea = styled(BaseTextareaAutosize)( ({ theme }) => ` width: 320px; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.5; padding: 8px 12px; border-radius: 8px; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; box-shadow: 0px 2px 2px ${theme.palette.mode === 'dark' ? grey[900] : grey[50]}; &:hover { border-color: ${blue[400]}; } &:focus { border-color: ${blue[400]}; box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[600] : blue[200]}; } // firefox &:focus-visible { outline: 0; } `, ); return ( <Textarea aria-label="minimum height" minRows={3} placeholder="Minimum 3 rows" /> ); }
554
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/MinHeightTextarea.tsx
import * as React from 'react'; import { TextareaAutosize as BaseTextareaAutosize } from '@mui/base/TextareaAutosize'; import { styled } from '@mui/system'; export default function MinHeightTextarea() { const blue = { 100: '#DAECFF', 200: '#b6daff', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Textarea = styled(BaseTextareaAutosize)( ({ theme }) => ` width: 320px; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.5; padding: 8px 12px; border-radius: 8px; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; box-shadow: 0px 2px 2px ${theme.palette.mode === 'dark' ? grey[900] : grey[50]}; &:hover { border-color: ${blue[400]}; } &:focus { border-color: ${blue[400]}; box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[600] : blue[200]}; } // firefox &:focus-visible { outline: 0; } `, ); return ( <Textarea aria-label="minimum height" minRows={3} placeholder="Minimum 3 rows" /> ); }
555
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/MinHeightTextarea.tsx.preview
<Textarea aria-label="minimum height" minRows={3} placeholder="Minimum 3 rows" />
556
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/textarea-autosize.md
--- productId: base-ui title: Textarea Autosize React component components: TextareaAutosize githubLabel: 'component: TextareaAutosize' --- # Textarea Autosize <p class="description">The Textarea Autosize 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}} {{"component": "modules/components/ComponentPageTabs.js"}} ## Introduction Textarea Autosize is a utility component that replaces the native `<textarea>` HTML. The height of the Textarea Autosize component automatically adjusts as a response to keyboard inputs and window resizing events. {{"demo": "UnstyledTextareaIntroduction", "defaultCodeOpen": false, "bg": "gradient"}} ## Component ```jsx import { TextareaAutosize } from '@mui/base/TextareaAutosize'; ``` Textarea Autosize behaves similarly to the native HTML`<textarea>`. By default, an empty Textarea Autosize component renders as a single row, as shown in the following demo: {{"demo": "UnstyledTextarea", "defaultCodeOpen": false}} ## Customization ### Minimum height Use the `minRows` prop to define the minimum height of the component: {{"demo": "MinHeightTextarea.js"}} ### Maximum height Use the `maxRows` prop to define the maximum height of the component: {{"demo": "MaxHeightTextarea.js"}}
557
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea/css/index.js
import * as React from 'react'; import { TextareaAutosize } from '@mui/base/TextareaAutosize'; import { useTheme } from '@mui/system'; export default function UnstyledTextareaAutosize() { return ( <React.Fragment> <TextareaAutosize className="CustomTextarea" aria-label="empty textarea" placeholder="Empty" /> <Styles /> </React.Fragment> ); } const cyan = { 50: '#E9F8FC', 100: '#BDEBF4', 200: '#99D8E5', 300: '#66BACC', 400: '#1F94AD', 500: '#0D5463', 600: '#094855', 700: '#063C47', 800: '#043039', 900: '#022127', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } function Styles() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); return ( <style> {` .CustomTextarea { width: 320px; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.5; padding: 8px 12px; border-radius: 8px; color: ${isDarkMode ? grey[300] : grey[900]}; background: ${isDarkMode ? grey[900] : '#fff'}; border: 1px solid ${isDarkMode ? grey[700] : grey[200]}; box-shadow: 0px 2px 2px ${isDarkMode ? grey[900] : grey[50]}; } .CustomTextarea:hover { border-color: ${cyan[400]}; } .CustomTextarea:focus { outline: 0; border-color: ${cyan[400]}; box-shadow: 0 0 0 3px ${isDarkMode ? cyan[500] : cyan[200]}; } // firefox .CustomTextarea:focus-visible { outline: 0; } `} </style> ); }
558
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea/css/index.tsx
import * as React from 'react'; import { TextareaAutosize } from '@mui/base/TextareaAutosize'; import { useTheme } from '@mui/system'; export default function UnstyledTextareaAutosize() { return ( <React.Fragment> <TextareaAutosize className="CustomTextarea" aria-label="empty textarea" placeholder="Empty" /> <Styles /> </React.Fragment> ); } const cyan = { 50: '#E9F8FC', 100: '#BDEBF4', 200: '#99D8E5', 300: '#66BACC', 400: '#1F94AD', 500: '#0D5463', 600: '#094855', 700: '#063C47', 800: '#043039', 900: '#022127', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } function Styles() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); return ( <style> {` .CustomTextarea { width: 320px; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.5; padding: 8px 12px; border-radius: 8px; color: ${isDarkMode ? grey[300] : grey[900]}; background: ${isDarkMode ? grey[900] : '#fff'}; border: 1px solid ${isDarkMode ? grey[700] : grey[200]}; box-shadow: 0px 2px 2px ${isDarkMode ? grey[900] : grey[50]}; } .CustomTextarea:hover { border-color: ${cyan[400]}; } .CustomTextarea:focus { outline: 0; border-color: ${cyan[400]}; box-shadow: 0 0 0 3px ${isDarkMode ? cyan[500] : cyan[200]}; } // firefox .CustomTextarea:focus-visible { outline: 0; } `} </style> ); }
559
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea/css/index.tsx.preview
<React.Fragment> <TextareaAutosize className="CustomTextarea" aria-label="empty textarea" placeholder="Empty" /> <Styles /> </React.Fragment>
560
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea/system/index.js
import * as React from 'react'; import { TextareaAutosize as BaseTextareaAutosize } from '@mui/base/TextareaAutosize'; import { styled } from '@mui/system'; export default function EmptyTextarea() { const blue = { 100: '#DAECFF', 200: '#b6daff', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Textarea = styled(BaseTextareaAutosize)( ({ theme }) => ` width: 320px; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.5; padding: 12px; border-radius: 12px 12px 0 12px; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; box-shadow: 0px 2px 2px ${theme.palette.mode === 'dark' ? grey[900] : grey[50]}; &:hover { border-color: ${blue[400]}; } &:focus { outline: 0; border-color: ${blue[400]}; box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[600] : blue[200]}; } // firefox &:focus-visible { outline: 0; } `, ); return <Textarea aria-label="empty textarea" placeholder="Empty" />; }
561
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea/system/index.tsx
import * as React from 'react'; import { TextareaAutosize as BaseTextareaAutosize } from '@mui/base/TextareaAutosize'; import { styled } from '@mui/system'; export default function EmptyTextarea() { const blue = { 100: '#DAECFF', 200: '#b6daff', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const Textarea = styled(BaseTextareaAutosize)( ({ theme }) => ` width: 320px; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.5; padding: 12px; border-radius: 12px 12px 0 12px; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; box-shadow: 0px 2px 2px ${theme.palette.mode === 'dark' ? grey[900] : grey[50]}; &:hover { border-color: ${blue[400]}; } &:focus { outline: 0; border-color: ${blue[400]}; box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[600] : blue[200]}; } // firefox &:focus-visible { outline: 0; } `, ); return <Textarea aria-label="empty textarea" placeholder="Empty" />; }
562
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea/system/index.tsx.preview
<Textarea aria-label="empty textarea" placeholder="Empty" />
563
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea/tailwind/index.js
import * as React from 'react'; import { TextareaAutosize } from '@mui/base/TextareaAutosize'; import { useTheme } from '@mui/system'; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } export default function UnstyledTextareaAutosize() { // Replace this with your app logic for determining dark modes const isDarkMode = useIsDarkMode(); return ( <div className={isDarkMode ? 'dark' : ''}> <TextareaAutosize className="'w-80 text-sm font-sans font-normal leading-5 px-3 py-2 rounded-lg shadow-md shadow-slate-100 dark:shadow-slate-900 focus:shadow-outline-purple dark:focus:shadow-outline-purple focus:shadow-lg border border-solid border-slate-300 hover:border-purple-500 dark:hover:border-purple-500 focus:border-purple-500 dark:focus:border-purple-500 dark:border-slate-600 bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-300 focus-visible:outline-0" aria-label="Demo input" placeholder="Empty" /> </div> ); }
564
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea/tailwind/index.tsx
import * as React from 'react'; import { TextareaAutosize } from '@mui/base/TextareaAutosize'; import { useTheme } from '@mui/system'; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } export default function UnstyledTextareaAutosize() { // Replace this with your app logic for determining dark modes const isDarkMode = useIsDarkMode(); return ( <div className={isDarkMode ? 'dark' : ''}> <TextareaAutosize className="'w-80 text-sm font-sans font-normal leading-5 px-3 py-2 rounded-lg shadow-md shadow-slate-100 dark:shadow-slate-900 focus:shadow-outline-purple dark:focus:shadow-outline-purple focus:shadow-lg border border-solid border-slate-300 hover:border-purple-500 dark:hover:border-purple-500 focus:border-purple-500 dark:focus:border-purple-500 dark:border-slate-600 bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-300 focus-visible:outline-0" aria-label="Demo input" placeholder="Empty" /> </div> ); }
565
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextarea/tailwind/index.tsx.preview
<TextareaAutosize className="'w-80 text-sm font-sans font-normal leading-5 px-3 py-2 rounded-lg shadow-md shadow-slate-100 dark:shadow-slate-900 focus:shadow-outline-purple dark:focus:shadow-outline-purple focus:shadow-lg border border-solid border-slate-300 hover:border-purple-500 dark:hover:border-purple-500 focus:border-purple-500 dark:focus:border-purple-500 dark:border-slate-600 bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-300 focus-visible:outline-0" aria-label="Demo input" placeholder="Empty" />
566
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction/css/index.js
import * as React from 'react'; import { TextareaAutosize } from '@mui/base/TextareaAutosize'; import { useTheme } from '@mui/system'; export default function UnstyledTextareaIntroduction() { return ( <React.Fragment> <TextareaAutosize className="CustomTextareaIntrocudtion" aria-label="empty textarea" placeholder="Empty" /> <Styles /> </React.Fragment> ); } const cyan = { 50: '#E9F8FC', 100: '#BDEBF4', 200: '#99D8E5', 300: '#66BACC', 400: '#1F94AD', 500: '#0D5463', 600: '#094855', 700: '#063C47', 800: '#043039', 900: '#022127', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } function Styles() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); return ( <style> {` .CustomTextareaIntrocudtion { width: 320px; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.5; padding: 12px; border-radius: 12px 12px 0 12px; color: ${isDarkMode ? grey[300] : grey[900]}; background: ${isDarkMode ? grey[900] : '#fff'}; border: 1px solid ${isDarkMode ? grey[700] : grey[200]}; box-shadow: 0px 2px 24px ${isDarkMode ? cyan[900] : cyan[100]}; } .CustomTextareaIntrocudtion:hover { border-color: ${cyan[400]}; } .CustomTextareaIntrocudtion:focus { border-color: ${cyan[400]}; box-shadow: 0 0 0 3px ${isDarkMode ? cyan[600] : cyan[200]}; outline: none; } // firefox .CustomTextareaIntrocudtion:focus-visible { outline: 0; } `} </style> ); }
567
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction/css/index.tsx
import * as React from 'react'; import { TextareaAutosize } from '@mui/base/TextareaAutosize'; import { useTheme } from '@mui/system'; export default function UnstyledTextareaIntroduction() { return ( <React.Fragment> <TextareaAutosize className="CustomTextareaIntrocudtion" aria-label="empty textarea" placeholder="Empty" /> <Styles /> </React.Fragment> ); } const cyan = { 50: '#E9F8FC', 100: '#BDEBF4', 200: '#99D8E5', 300: '#66BACC', 400: '#1F94AD', 500: '#0D5463', 600: '#094855', 700: '#063C47', 800: '#043039', 900: '#022127', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } function Styles() { // Replace this with your app logic for determining dark mode const isDarkMode = useIsDarkMode(); return ( <style> {` .CustomTextareaIntrocudtion { width: 320px; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.5; padding: 12px; border-radius: 12px 12px 0 12px; color: ${isDarkMode ? grey[300] : grey[900]}; background: ${isDarkMode ? grey[900] : '#fff'}; border: 1px solid ${isDarkMode ? grey[700] : grey[200]}; box-shadow: 0px 2px 24px ${isDarkMode ? cyan[900] : cyan[100]}; } .CustomTextareaIntrocudtion:hover { border-color: ${cyan[400]}; } .CustomTextareaIntrocudtion:focus { border-color: ${cyan[400]}; box-shadow: 0 0 0 3px ${isDarkMode ? cyan[600] : cyan[200]}; outline: none; } // firefox .CustomTextareaIntrocudtion:focus-visible { outline: 0; } `} </style> ); }
568
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction/css/index.tsx.preview
<React.Fragment> <TextareaAutosize className="CustomTextareaIntrocudtion" aria-label="empty textarea" placeholder="Empty" /> <Styles /> </React.Fragment>
569
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction/system/index.js
import * as React from 'react'; import { TextareaAutosize as BaseTextareaAutosize } from '@mui/base/TextareaAutosize'; import { styled } from '@mui/system'; export default function UnstyledTextareaIntroduction() { return <TextareaAutosize aria-label="empty textarea" placeholder="Empty" />; } const blue = { 100: '#DAECFF', 200: '#b6daff', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const TextareaAutosize = styled(BaseTextareaAutosize)( ({ theme }) => ` width: 320px; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.5; padding: 8px 12px; border-radius: 8px; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; box-shadow: 0px 2px 2px ${theme.palette.mode === 'dark' ? grey[900] : grey[50]}; &:hover { border-color: ${blue[400]}; } &:focus { border-color: ${blue[400]}; box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[600] : blue[200]}; } // firefox &:focus-visible { outline: 0; } `, );
570
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction/system/index.tsx
import * as React from 'react'; import { TextareaAutosize as BaseTextareaAutosize } from '@mui/base/TextareaAutosize'; import { styled } from '@mui/system'; export default function UnstyledTextareaIntroduction() { return <TextareaAutosize aria-label="empty textarea" placeholder="Empty" />; } const blue = { 100: '#DAECFF', 200: '#b6daff', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 900: '#003A75', }; const grey = { 50: '#F3F6F9', 100: '#E5EAF2', 200: '#DAE2ED', 300: '#C7D0DD', 400: '#B0B8C4', 500: '#9DA8B7', 600: '#6B7A90', 700: '#434D5B', 800: '#303740', 900: '#1C2025', }; const TextareaAutosize = styled(BaseTextareaAutosize)( ({ theme }) => ` width: 320px; font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; font-weight: 400; line-height: 1.5; padding: 8px 12px; border-radius: 8px; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; box-shadow: 0px 2px 2px ${theme.palette.mode === 'dark' ? grey[900] : grey[50]}; &:hover { border-color: ${blue[400]}; } &:focus { border-color: ${blue[400]}; box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[600] : blue[200]}; } // firefox &:focus-visible { outline: 0; } `, );
571
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction/system/index.tsx.preview
<TextareaAutosize aria-label="empty textarea" placeholder="Empty" />
572
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction/tailwind/index.js
import * as React from 'react'; import { TextareaAutosize } from '@mui/base/TextareaAutosize'; import { useTheme } from '@mui/system'; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } export default function UnstyledTextareaIntroduction() { // Replace this with your app logic for determining dark modes const isDarkMode = useIsDarkMode(); return ( <div className={isDarkMode ? 'dark' : ''} style={{ display: 'flex' }}> <TextareaAutosize className="w-80 text-sm font-normal font-sans leading-normal p-3 rounded-xl rounded-br-none shadow-lg shadow-slate-100 dark:shadow-slate-900 focus:shadow-outline-purple dark:focus:shadow-outline-purple focus:shadow-lg border border-solid border-slate-300 hover:border-purple-500 dark:hover:border-purple-500 focus:border-purple-500 dark:focus:border-purple-500 dark:border-slate-600 bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-300 focus-visible:outline-0" aria-label="empty textarea" placeholder="Empty" /> </div> ); }
573
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction/tailwind/index.tsx
import * as React from 'react'; import { TextareaAutosize } from '@mui/base/TextareaAutosize'; import { useTheme } from '@mui/system'; function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } export default function UnstyledTextareaIntroduction() { // Replace this with your app logic for determining dark modes const isDarkMode = useIsDarkMode(); return ( <div className={isDarkMode ? 'dark' : ''} style={{ display: 'flex' }}> <TextareaAutosize className="w-80 text-sm font-normal font-sans leading-normal p-3 rounded-xl rounded-br-none shadow-lg shadow-slate-100 dark:shadow-slate-900 focus:shadow-outline-purple dark:focus:shadow-outline-purple focus:shadow-lg border border-solid border-slate-300 hover:border-purple-500 dark:hover:border-purple-500 focus:border-purple-500 dark:focus:border-purple-500 dark:border-slate-600 bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-300 focus-visible:outline-0" aria-label="empty textarea" placeholder="Empty" /> </div> ); }
574
0
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction
petrpan-code/mui/material-ui/docs/data/base/components/textarea-autosize/UnstyledTextareaIntroduction/tailwind/index.tsx.preview
<TextareaAutosize className="w-80 text-sm font-normal font-sans leading-normal p-3 rounded-xl rounded-br-none shadow-lg shadow-slate-100 dark:shadow-slate-900 focus:shadow-outline-purple dark:focus:shadow-outline-purple focus:shadow-lg border border-solid border-slate-300 hover:border-purple-500 dark:hover:border-purple-500 focus:border-purple-500 dark:focus:border-purple-500 dark:border-slate-600 bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-300 focus-visible:outline-0" aria-label="empty textarea" placeholder="Empty" />
575
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/toggle-button-group/toggle-button-group.md
--- productId: base-ui title: React Toggle Button Group component githubLabel: 'component: toggle button' --- # Toggle Button Group 🚧 <p class="description">Toggle Button Groups house sets of buttons with mutually exclusive actions.</p> :::warning The Base UI Toggle Button Group component isn't available yet, but you can upvote [this GitHub issue](https://github.com/mui/material-ui/issues/38044) to see it arrive sooner. :::
576
0
petrpan-code/mui/material-ui/docs/data/base/components
petrpan-code/mui/material-ui/docs/data/base/components/tooltip/tooltip.md
--- productId: base-ui title: React Tooltip component 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> :::warning The Base UI Tooltip component isn't available yet, but you can upvote [this GitHub issue](https://github.com/mui/material-ui/issues/38045) to see it arrive sooner. :::
577
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/accessibility/ColorContrast.js
import * as React from 'react'; import { Button as BaseButton, buttonClasses } from '@mui/base/Button'; import { styled } from '@mui/system'; import Stack from '@mui/material/Stack'; export default function ColorContrast() { return ( <Stack spacing={2} direction="row"> <Button>Good contrast</Button> <PoorContrastButton>Poor contrast</PoorContrastButton> </Stack> ); } const blue = { 500: '#007FFF', 600: '#0072E5', 700: '#0059B2', }; const Button = styled(BaseButton)` font-family: 'IBM Plex Sans', sans-serif; font-size: 0.875rem; line-height: 1.5; background-color: ${blue[500]}; color: white; border-radius: 8px; font-weight: 600; padding: 8px 16px; cursor: pointer; transition: all 150ms ease; border: none; &:hover:not(:disabled) { background-color: ${blue[600]}; } &:active:not(:disabled) { background-color: ${blue[700]}; } &.${buttonClasses.focusVisible} { box-shadow: 0 4px 20px 0 rgb(61 71 82 / 0.1), 0 0 0 5px rgb(0 127 255 / 0.5); outline: none; } &.${buttonClasses.disabled} { opacity: 0.5; cursor: not-allowed; } `; const PoorContrastButton = styled(BaseButton)` font-family: 'IBM Plex Sans', sans-serif; font-size: 0.875rem; line-height: 1.5; background-color: ${blue[500]}; color: black; border-radius: 8px; font-weight: 600; padding: 8px 16px; cursor: pointer; transition: all 150ms ease; border: none; &:hover:not(:disabled) { background-color: ${blue[600]}; } &:active:not(:disabled) { background-color: ${blue[700]}; } &.${buttonClasses.focusVisible} { box-shadow: 0 4px 20px 0 rgb(61 71 82 / 0.1), 0 0 0 5px rgb(0 127 255 / 0.5); outline: none; } &.${buttonClasses.disabled} { opacity: 0.5; cursor: not-allowed; } `;
578
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/accessibility/ColorContrast.tsx
import * as React from 'react'; import { Button as BaseButton, buttonClasses } from '@mui/base/Button'; import { styled } from '@mui/system'; import Stack from '@mui/material/Stack'; export default function ColorContrast() { return ( <Stack spacing={2} direction="row"> <Button>Good contrast</Button> <PoorContrastButton>Poor contrast</PoorContrastButton> </Stack> ); } const blue = { 500: '#007FFF', 600: '#0072E5', 700: '#0059B2', }; const Button = styled(BaseButton)` font-family: 'IBM Plex Sans', sans-serif; font-size: 0.875rem; line-height: 1.5; background-color: ${blue[500]}; color: white; border-radius: 8px; font-weight: 600; padding: 8px 16px; cursor: pointer; transition: all 150ms ease; border: none; &:hover:not(:disabled) { background-color: ${blue[600]}; } &:active:not(:disabled) { background-color: ${blue[700]}; } &.${buttonClasses.focusVisible} { box-shadow: 0 4px 20px 0 rgb(61 71 82 / 0.1), 0 0 0 5px rgb(0 127 255 / 0.5); outline: none; } &.${buttonClasses.disabled} { opacity: 0.5; cursor: not-allowed; } `; const PoorContrastButton = styled(BaseButton)` font-family: 'IBM Plex Sans', sans-serif; font-size: 0.875rem; line-height: 1.5; background-color: ${blue[500]}; color: black; border-radius: 8px; font-weight: 600; padding: 8px 16px; cursor: pointer; transition: all 150ms ease; border: none; &:hover:not(:disabled) { background-color: ${blue[600]}; } &:active:not(:disabled) { background-color: ${blue[700]}; } &.${buttonClasses.focusVisible} { box-shadow: 0 4px 20px 0 rgb(61 71 82 / 0.1), 0 0 0 5px rgb(0 127 255 / 0.5); outline: none; } &.${buttonClasses.disabled} { opacity: 0.5; cursor: not-allowed; } `;
579
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/accessibility/ColorContrast.tsx.preview
<Button>Good contrast</Button> <PoorContrastButton>Poor contrast</PoorContrastButton>
580
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/accessibility/FocusRing.js
import * as React from 'react'; import { styled, alpha, Box } from '@mui/system'; import { Slider as BaseSlider, sliderClasses } from '@mui/base/Slider'; export default function FocusRing() { return ( <Box sx={{ width: 300 }}> <Slider defaultValue={[10, 20]} /> </Box> ); } const blue = { 100: '#DAECFF', 200: '#99CCF3', 400: '#3399FF', 300: '#66B2FF', 500: '#007FFF', 600: '#0072E5', 900: '#003A75', }; const Slider = styled(BaseSlider)( ({ theme }) => ` color: ${theme.palette.mode === 'light' ? blue[500] : blue[400]}; height: 6px; width: 100%; padding: 16px 0; display: inline-block; position: relative; cursor: pointer; touch-action: none; -webkit-tap-highlight-color: transparent; &:hover { opacity: 1; } & .${sliderClasses.rail} { display: block; position: absolute; width: 100%; height: 4px; border-radius: 2px; background-color: currentColor; opacity: 0.4; } & .${sliderClasses.track} { display: block; position: absolute; height: 4px; border-radius: 2px; background-color: currentColor; } & .${sliderClasses.thumb} { position: absolute; width: 16px; height: 16px; margin-left: -6px; margin-top: -6px; box-sizing: border-box; border-radius: 50%; outline: 0; border: 3px solid currentColor; background-color: #fff; :hover, &.${sliderClasses.focusVisible} { box-shadow: 0 0 0 0.25rem ${alpha( theme.palette.mode === 'light' ? blue[400] : blue[300], 0.15, )}; } &.${sliderClasses.active} { box-shadow: 0 0 0 0.25rem ${alpha( theme.palette.mode === 'light' ? blue[200] : blue[300], 0.3, )}; } } `, );
581
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/accessibility/FocusRing.tsx
import * as React from 'react'; import { styled, alpha, Box } from '@mui/system'; import { Slider as BaseSlider, sliderClasses } from '@mui/base/Slider'; export default function FocusRing() { return ( <Box sx={{ width: 300 }}> <Slider defaultValue={[10, 20]} /> </Box> ); } const blue = { 100: '#DAECFF', 200: '#99CCF3', 400: '#3399FF', 300: '#66B2FF', 500: '#007FFF', 600: '#0072E5', 900: '#003A75', }; const Slider = styled(BaseSlider)( ({ theme }) => ` color: ${theme.palette.mode === 'light' ? blue[500] : blue[400]}; height: 6px; width: 100%; padding: 16px 0; display: inline-block; position: relative; cursor: pointer; touch-action: none; -webkit-tap-highlight-color: transparent; &:hover { opacity: 1; } & .${sliderClasses.rail} { display: block; position: absolute; width: 100%; height: 4px; border-radius: 2px; background-color: currentColor; opacity: 0.4; } & .${sliderClasses.track} { display: block; position: absolute; height: 4px; border-radius: 2px; background-color: currentColor; } & .${sliderClasses.thumb} { position: absolute; width: 16px; height: 16px; margin-left: -6px; margin-top: -6px; box-sizing: border-box; border-radius: 50%; outline: 0; border: 3px solid currentColor; background-color: #fff; :hover, &.${sliderClasses.focusVisible} { box-shadow: 0 0 0 0.25rem ${alpha( theme.palette.mode === 'light' ? blue[400] : blue[300], 0.15, )}; } &.${sliderClasses.active} { box-shadow: 0 0 0 0.25rem ${alpha( theme.palette.mode === 'light' ? blue[200] : blue[300], 0.3, )}; } } `, );
582
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/accessibility/FocusRing.tsx.preview
<Slider defaultValue={[10, 20]} />
583
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/accessibility/KeyboardNavigation.js
import * as React from 'react'; import { Select as BaseSelect, selectClasses } from '@mui/base/Select'; import { Option as BaseOption, optionClasses } from '@mui/base/Option'; import { Popper as BasePopper } from '@mui/base/Popper'; import { Dropdown } from '@mui/base/Dropdown'; import { Menu } from '@mui/base/Menu'; import { MenuButton as BaseMenuButton } from '@mui/base/MenuButton'; import { MenuItem as BaseMenuItem, menuItemClasses } from '@mui/base/MenuItem'; import { styled } from '@mui/system'; export default function KeyboardNavigation() { return ( <Container> <Select defaultValue="cascadia-code"> <Option value="cascadia-code">Cascadia Code</Option> <Option value="consolas">Consolas</Option> <Option value="dejavu-sans-mono">DejaVu Sans Mono</Option> <Option value="fira-code">Fira Code</Option> <Option value="jetbrains-mono">JetBrains Mono</Option> <Option value="menlo">Menlo</Option> <Option value="monaco">Monaco</Option> <Option value="monolisa">Monolisa</Option> <Option value="source-code-pro">Source Code Pro</Option> </Select> <Dropdown> <MenuButton>Edit</MenuButton> <Menu slots={{ listbox: Listbox }}> <MenuItem>Cut</MenuItem> <MenuItem>Copy</MenuItem> <MenuItem>Paste</MenuItem> </Menu> </Dropdown> </Container> ); } const Select = React.forwardRef(function Select(props, ref) { const slots = { root: Button, listbox: Listbox, popper: Popper, ...props.slots, }; return <BaseSelect {...props} ref={ref} slots={slots} />; }); const blue = { 50: '#F0F7FF', 100: '#DAECFF', 200: '#99CCF3', 300: '#66B2FF', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 900: '#003A75', }; const grey = { 50: '#f6f8fa', 100: '#eaeef2', 200: '#d0d7de', 300: '#afb8c1', 400: '#8c959f', 500: '#6e7781', 600: '#57606a', 700: '#424a53', 800: '#32383f', 900: '#24292f', }; const Button = styled('button')( ({ theme }) => ` font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; box-sizing: border-box; min-width: 200px; padding: 8px 12px; border-radius: 8px; text-align: left; line-height: 1.5; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; box-shadow: 0px 4px 6px ${ theme.palette.mode === 'dark' ? 'rgba(0,0,0, 0.50)' : 'rgba(0,0,0, 0.05)' }; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 120ms; &:hover { background: ${theme.palette.mode === 'dark' ? grey[800] : grey[50]}; border-color: ${theme.palette.mode === 'dark' ? grey[600] : grey[300]}; } &.${selectClasses.focusVisible} { border-color: ${blue[400]}; outline: 3px solid ${theme.palette.mode === 'dark' ? blue[500] : blue[200]}; } &.${selectClasses.expanded} { &::after { content: '▴'; } } &::after { content: '▾'; float: right; } `, ); const Listbox = styled('ul')( ({ theme }) => ` font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; box-sizing: border-box; padding: 6px; margin: 12px 0; min-width: 150px; border-radius: 12px; overflow: auto; outline: 0px; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; box-shadow: 0px 4px 6px ${ theme.palette.mode === 'dark' ? 'rgba(0,0,0, 0.50)' : 'rgba(0,0,0, 0.05)' }; `, ); const Option = styled(BaseOption)( ({ theme }) => ` list-style: none; padding: 8px; border-radius: 8px; cursor: default; &:last-of-type { border-bottom: none; } &.${optionClasses.selected} { background-color: ${theme.palette.mode === 'dark' ? blue[900] : blue[100]}; color: ${theme.palette.mode === 'dark' ? blue[100] : blue[900]}; } &.${optionClasses.highlighted} { background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[100]}; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; } &.${optionClasses.highlighted}.${optionClasses.selected} { background-color: ${theme.palette.mode === 'dark' ? blue[900] : blue[100]}; color: ${theme.palette.mode === 'dark' ? blue[100] : blue[900]}; } &.${optionClasses.disabled} { color: ${theme.palette.mode === 'dark' ? grey[700] : grey[400]}; } &:hover:not(.${optionClasses.disabled}) { background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[100]}; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; } `, ); const MenuItem = styled(BaseMenuItem)( ({ theme }) => ` list-style: none; padding: 8px; border-radius: 8px; cursor: default; user-select: none; &:last-of-type { border-bottom: none; } &.${menuItemClasses.focusVisible} { outline: 3px solid ${theme.palette.mode === 'dark' ? blue[600] : blue[200]}; background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[100]}; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; } &.${menuItemClasses.disabled} { color: ${theme.palette.mode === 'dark' ? grey[700] : grey[400]}; } &:hover:not(.${menuItemClasses.disabled}) { background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[100]}; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; } `, ); const MenuButton = styled(BaseMenuButton)( ({ theme }) => ` font-family: IBM Plex Sans, sans-serif; font-weight: 600; font-size: 0.875rem; box-sizing: border-box; border-radius: 8px; padding: 8px 16px; line-height: 1.5; background: transparent; border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; color: ${theme.palette.mode === 'dark' ? blue[300] : blue[500]}; cursor: pointer; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 120ms; &:hover { background: ${theme.palette.mode === 'dark' ? grey[800] : grey[50]}; border-color: ${theme.palette.mode === 'dark' ? grey[600] : grey[300]}; } &:focus-visible { border-color: ${blue[400]}; outline: 3px solid ${theme.palette.mode === 'dark' ? blue[500] : blue[200]}; } `, ); const Container = styled('div')` display: flex; gap: 10px; `; const Popper = styled(BasePopper)` z-index: 1; `;
584
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/accessibility/KeyboardNavigation.tsx
import * as React from 'react'; import { Select as BaseSelect, SelectProps, selectClasses } from '@mui/base/Select'; import { Option as BaseOption, optionClasses } from '@mui/base/Option'; import { Popper as BasePopper } from '@mui/base/Popper'; import { Dropdown } from '@mui/base/Dropdown'; import { Menu } from '@mui/base/Menu'; import { MenuButton as BaseMenuButton } from '@mui/base/MenuButton'; import { MenuItem as BaseMenuItem, menuItemClasses } from '@mui/base/MenuItem'; import { styled } from '@mui/system'; export default function KeyboardNavigation() { return ( <Container> <Select defaultValue="cascadia-code"> <Option value="cascadia-code">Cascadia Code</Option> <Option value="consolas">Consolas</Option> <Option value="dejavu-sans-mono">DejaVu Sans Mono</Option> <Option value="fira-code">Fira Code</Option> <Option value="jetbrains-mono">JetBrains Mono</Option> <Option value="menlo">Menlo</Option> <Option value="monaco">Monaco</Option> <Option value="monolisa">Monolisa</Option> <Option value="source-code-pro">Source Code Pro</Option> </Select> <Dropdown> <MenuButton>Edit</MenuButton> <Menu slots={{ listbox: Listbox }}> <MenuItem>Cut</MenuItem> <MenuItem>Copy</MenuItem> <MenuItem>Paste</MenuItem> </Menu> </Dropdown> </Container> ); } const Select = React.forwardRef(function Select< TValue extends {}, Multiple extends boolean, >(props: SelectProps<TValue, Multiple>, ref: React.ForwardedRef<HTMLButtonElement>) { const slots: SelectProps<TValue, Multiple>['slots'] = { root: Button, listbox: Listbox, popper: Popper, ...props.slots, }; return <BaseSelect {...props} ref={ref} slots={slots} />; }) as <TValue extends {}, Multiple extends boolean>( props: SelectProps<TValue, Multiple> & React.RefAttributes<HTMLButtonElement>, ) => JSX.Element; const blue = { 50: '#F0F7FF', 100: '#DAECFF', 200: '#99CCF3', 300: '#66B2FF', 400: '#3399FF', 500: '#007FFF', 600: '#0072E5', 900: '#003A75', }; const grey = { 50: '#f6f8fa', 100: '#eaeef2', 200: '#d0d7de', 300: '#afb8c1', 400: '#8c959f', 500: '#6e7781', 600: '#57606a', 700: '#424a53', 800: '#32383f', 900: '#24292f', }; const Button = styled('button')( ({ theme }) => ` font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; box-sizing: border-box; min-width: 200px; padding: 8px 12px; border-radius: 8px; text-align: left; line-height: 1.5; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; box-shadow: 0px 4px 6px ${ theme.palette.mode === 'dark' ? 'rgba(0,0,0, 0.50)' : 'rgba(0,0,0, 0.05)' }; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 120ms; &:hover { background: ${theme.palette.mode === 'dark' ? grey[800] : grey[50]}; border-color: ${theme.palette.mode === 'dark' ? grey[600] : grey[300]}; } &.${selectClasses.focusVisible} { border-color: ${blue[400]}; outline: 3px solid ${theme.palette.mode === 'dark' ? blue[500] : blue[200]}; } &.${selectClasses.expanded} { &::after { content: '▴'; } } &::after { content: '▾'; float: right; } `, ); const Listbox = styled('ul')( ({ theme }) => ` font-family: IBM Plex Sans, sans-serif; font-size: 0.875rem; box-sizing: border-box; padding: 6px; margin: 12px 0; min-width: 150px; border-radius: 12px; overflow: auto; outline: 0px; background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; box-shadow: 0px 4px 6px ${ theme.palette.mode === 'dark' ? 'rgba(0,0,0, 0.50)' : 'rgba(0,0,0, 0.05)' }; `, ); const Option = styled(BaseOption)( ({ theme }) => ` list-style: none; padding: 8px; border-radius: 8px; cursor: default; &:last-of-type { border-bottom: none; } &.${optionClasses.selected} { background-color: ${theme.palette.mode === 'dark' ? blue[900] : blue[100]}; color: ${theme.palette.mode === 'dark' ? blue[100] : blue[900]}; } &.${optionClasses.highlighted} { background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[100]}; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; } &.${optionClasses.highlighted}.${optionClasses.selected} { background-color: ${theme.palette.mode === 'dark' ? blue[900] : blue[100]}; color: ${theme.palette.mode === 'dark' ? blue[100] : blue[900]}; } &.${optionClasses.disabled} { color: ${theme.palette.mode === 'dark' ? grey[700] : grey[400]}; } &:hover:not(.${optionClasses.disabled}) { background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[100]}; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; } `, ); const MenuItem = styled(BaseMenuItem)( ({ theme }) => ` list-style: none; padding: 8px; border-radius: 8px; cursor: default; user-select: none; &:last-of-type { border-bottom: none; } &.${menuItemClasses.focusVisible} { outline: 3px solid ${theme.palette.mode === 'dark' ? blue[600] : blue[200]}; background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[100]}; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; } &.${menuItemClasses.disabled} { color: ${theme.palette.mode === 'dark' ? grey[700] : grey[400]}; } &:hover:not(.${menuItemClasses.disabled}) { background-color: ${theme.palette.mode === 'dark' ? grey[800] : grey[100]}; color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; } `, ); const MenuButton = styled(BaseMenuButton)( ({ theme }) => ` font-family: IBM Plex Sans, sans-serif; font-weight: 600; font-size: 0.875rem; box-sizing: border-box; border-radius: 8px; padding: 8px 16px; line-height: 1.5; background: transparent; border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[200]}; color: ${theme.palette.mode === 'dark' ? blue[300] : blue[500]}; cursor: pointer; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 120ms; &:hover { background: ${theme.palette.mode === 'dark' ? grey[800] : grey[50]}; border-color: ${theme.palette.mode === 'dark' ? grey[600] : grey[300]}; } &:focus-visible { border-color: ${blue[400]}; outline: 3px solid ${theme.palette.mode === 'dark' ? blue[500] : blue[200]}; } `, ); const Container = styled('div')` display: flex; gap: 10px; `; const Popper = styled(BasePopper)` z-index: 1; `;
585
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/accessibility/accessibility.md
# Accessibility <p class="description"> Learn how to make the most of Base UI's accessibility features and guidelines. </p> Accessibility is our top priority for Base UI components. However, the library cannot make your application fully accessible on its own. This page highlights the most common actions that you as a developer must take to ensure that your app is accessible to users who require assistive technologies. ## Keyboard navigation Base UI components follow the [WAI-ARIA 1.2 standard](https://www.w3.org/TR/wai-aria-1.2/), so they are accessible with a keyboard out of the box. This is important for users who have trouble using a pointing device, but also comes in handy for users who find navigating with a keyboard faster, and who expect web components to behave the same way as native operating system controls. Specifically, interactive components can be focused using the <kbd class="key">Tab</kbd> key. List-like components (such as Select and Menu) can be browsed and activated using arrow keys, <kbd class="key">Home</kbd>, <kbd class="key">End</kbd>, <kbd class="key">Enter</kbd>/<kbd class="key">Return</kbd>, and <kbd class="key">Escape</kbd>. The Select and Menu also let users navigate to options that begin with a provided string by pressing alphanumeric keys. {{"demo": "KeyboardNavigation.js", "defaultCodeOpen": false}} ## Focus ring While Base UI components handle keyboard navigation, it's the developer's responsibility to indicate when a component is focused and can receive keyboard input. This is usually done by styling the [`:focus`](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus) or [`:focus-visible`](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible) pseudoclasses. Read the [WCAG guidelines on focus appearance](https://www.w3.org/WAI/WCAG22/Understanding/focus-appearance-minimum) to learn more about requirements for focus indicators. {{"demo": "FocusRing.js", "defaultCodeOpen": false}} ## Color contrast Since Base UI components are unstyled, it's up to you to implement the appropriate amount of color contrast between text and background. You can use [C. Liam Brown's Color Contrast Tool](https://cliambrown.com/contrast/) to measure contrast between colors in your design and ensure that they meet the minimum requirements (note that this tool uses the [APCA algorithm](https://ruitina.com/apca-accessible-colour-contrast/), which is slated to become the new standard in WCAG 3). {{"demo": "ColorContrast.js", "defaultCodeOpen": false}} ## Accessible labels It's your responsibility to ensure that components have accessible names. For form controls (such as the [Input](/base-ui/react-input/), [Number Input](/base-ui/react-number-input/), and [Select](/base-ui/react-select/)), this requires adding an associated `<label>` element, or placing an `aria-label` attribute on the component itself: ```jsx <label> First name <Input /> </label> ``` or ```jsx <label for="first-name">First name</label> <Input id="first-name" /> ``` or ```jsx <Input aria-label="First name" /> ``` For buttons, their inner text becomes the accessible label. You only need to place an `aria-label` attribute if the button contains no text (like an icon button).
586
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/customization/CreateSlot.tsx.preview
<Button href="/" slots={{ root: LinkSlot }}> Home </Button>
587
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/customization/DisabledDefaultClasses.js
import * as React from 'react'; import { styled } from '@mui/system'; import { Switch } from '@mui/base/Switch'; import { ClassNameConfigurator } from '@mui/base'; const Root = styled('span')( ({ ownerState }) => ` font-size: 0; position: relative; display: inline-block; width: 32px; height: 20px; background: #b3c3d3; border-radius: 10px; margin: 10px; cursor: pointer; ${ ownerState.disabled ? `opacity: 0.4; cursor: not-allowed;` : '' } ${ownerState.checked ? 'background: #007fff;' : ''} `, ); const Thumb = styled('span')( ({ ownerState }) => ` display: block; width: 14px; height: 14px; top: 3px; left: 3px; border-radius: 16px; background-color: #fff; position: relative; transition: all 200ms ease; ${ ownerState.focusVisible ? `background-color: rgba(255, 255, 255, 1); box-shadow: 0 0 1px 8px rgba(0, 0, 0, 0.25);` : '' } ${ ownerState.checked ? `left: 14px; top: 3px; background-color: #fff;` : '' } `, ); const Input = styled('input')` cursor: inherit; position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; z-index: 1; margin: 0; `; const slots = { root: Root, thumb: Thumb, input: Input }; export default function DisabledDefaultClasses() { return ( <div> {/* The built-in classes (MuiSwitch-root, Mui-checked, etc.) are enabled by default, even though they are not used */} <Switch slots={slots} slotProps={{ input: { 'aria-label': 'Switch with built-in classes' } }} /> <ClassNameConfigurator disableDefaultClasses> {/* ClassNameConfigurator removes the built-in classes, leaving only the one generated by Emotion */} <Switch slots={slots} slotProps={{ input: { 'aria-label': 'Switch without built-in classes' } }} /> </ClassNameConfigurator> </div> ); }
588
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/customization/DisabledDefaultClasses.tsx
import * as React from 'react'; import { styled } from '@mui/system'; import { Switch, SwitchRootSlotProps, SwitchThumbSlotProps } from '@mui/base/Switch'; import { ClassNameConfigurator } from '@mui/base'; const Root = styled('span')( ({ ownerState }: SwitchRootSlotProps) => ` font-size: 0; position: relative; display: inline-block; width: 32px; height: 20px; background: #b3c3d3; border-radius: 10px; margin: 10px; cursor: pointer; ${ ownerState.disabled ? `opacity: 0.4; cursor: not-allowed;` : '' } ${ownerState.checked ? 'background: #007fff;' : ''} `, ); const Thumb = styled('span')( ({ ownerState }: SwitchThumbSlotProps) => ` display: block; width: 14px; height: 14px; top: 3px; left: 3px; border-radius: 16px; background-color: #fff; position: relative; transition: all 200ms ease; ${ ownerState.focusVisible ? `background-color: rgba(255, 255, 255, 1); box-shadow: 0 0 1px 8px rgba(0, 0, 0, 0.25);` : '' } ${ ownerState.checked ? `left: 14px; top: 3px; background-color: #fff;` : '' } `, ); const Input = styled('input')` cursor: inherit; position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; z-index: 1; margin: 0; `; const slots = { root: Root, thumb: Thumb, input: Input }; export default function DisabledDefaultClasses() { return ( <div> {/* The built-in classes (MuiSwitch-root, Mui-checked, etc.) are enabled by default, even though they are not used */} <Switch slots={slots} slotProps={{ input: { 'aria-label': 'Switch with built-in classes' } }} /> <ClassNameConfigurator disableDefaultClasses> {/* ClassNameConfigurator removes the built-in classes, leaving only the one generated by Emotion */} <Switch slots={slots} slotProps={{ input: { 'aria-label': 'Switch without built-in classes' } }} /> </ClassNameConfigurator> </div> ); }
589
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/customization/DisabledDefaultClasses.tsx.preview
{/* The built-in classes (MuiSwitch-root, Mui-checked, etc.) are enabled by default, even though they are not used */} <Switch slots={slots} slotProps={{ input: { 'aria-label': 'Switch with built-in classes' } }} /> <ClassNameConfigurator disableDefaultClasses> {/* ClassNameConfigurator removes the built-in classes, leaving only the one generated by Emotion */} <Switch slots={slots} slotProps={{ input: { 'aria-label': 'Switch without built-in classes' } }} /> </ClassNameConfigurator>
590
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/customization/PrepareForSlot.js
import * as React from 'react'; import { prepareForSlot } from '@mui/base/utils'; import { Button } from '@mui/base/Button'; import Link from 'next/link'; const LinkSlot = prepareForSlot(Link); export default function PrepareForSlot() { return ( <Button href="/" slots={{ root: LinkSlot }} prefetch={false}> Home </Button> ); }
591
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/customization/PrepareForSlot.tsx
import * as React from 'react'; import { prepareForSlot } from '@mui/base/utils'; import { Button } from '@mui/base/Button'; import Link from 'next/link'; const LinkSlot = prepareForSlot(Link); export default function PrepareForSlot() { return ( <Button<typeof LinkSlot> href="/" slots={{ root: LinkSlot }} prefetch={false}> Home </Button> ); }
592
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/customization/PrepareForSlot.tsx.preview
<Button<typeof LinkSlot> href="/" slots={{ root: LinkSlot }} prefetch={false}> Home </Button>
593
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/customization/SlotPropsCallback.js
import * as React from 'react'; import { Switch } from '@mui/base/Switch'; const css = ` .my-switch { font-size: 0; position: relative; display: inline-block; width: 32px; height: 20px; background: #B3C3D3; border-radius: 10px; margin: 10px; cursor: pointer; } .my-switch.on { background: #007FFF; } .my-switch.focused .MuiSwitch-thumb { background-color: rgba(255, 255, 255, 1); box-shadow: 0 0 1px 8px rgba(0, 0, 0, 0.25); } .my-switch .MuiSwitch-thumb { display: block; width: 14px; height: 14px; top: 3px; left: 3px; border-radius: 16px; background-color: #FFF; position: relative; transition: all 200ms ease; } .my-switch.on .MuiSwitch-thumb { left: 14px; top: 3px; background-color: #FFF; } .my-switch .MuiSwitch-input { cursor: inherit; position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; z-index: 1; margin: 0; }`; export default function SlotPropsCallback() { const slotProps = { root: (ownerState) => ({ className: `my-switch ${ownerState.checked ? 'on' : 'off'} ${ ownerState.focusVisible ? 'focused' : '' }`, }), }; return ( <div> <style type="text/css">{css}</style> <Switch slotProps={slotProps} /> </div> ); }
594
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/customization/SlotPropsCallback.tsx
import * as React from 'react'; import { Switch, SwitchOwnerState } from '@mui/base/Switch'; const css = ` .my-switch { font-size: 0; position: relative; display: inline-block; width: 32px; height: 20px; background: #B3C3D3; border-radius: 10px; margin: 10px; cursor: pointer; } .my-switch.on { background: #007FFF; } .my-switch.focused .MuiSwitch-thumb { background-color: rgba(255, 255, 255, 1); box-shadow: 0 0 1px 8px rgba(0, 0, 0, 0.25); } .my-switch .MuiSwitch-thumb { display: block; width: 14px; height: 14px; top: 3px; left: 3px; border-radius: 16px; background-color: #FFF; position: relative; transition: all 200ms ease; } .my-switch.on .MuiSwitch-thumb { left: 14px; top: 3px; background-color: #FFF; } .my-switch .MuiSwitch-input { cursor: inherit; position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; z-index: 1; margin: 0; }`; export default function SlotPropsCallback() { const slotProps = { root: (ownerState: SwitchOwnerState) => ({ className: `my-switch ${ownerState.checked ? 'on' : 'off'} ${ ownerState.focusVisible ? 'focused' : '' }`, }), }; return ( <div> <style type="text/css">{css}</style> <Switch slotProps={slotProps} /> </div> ); }
595
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/customization/SlotPropsCallback.tsx.preview
<style type="text/css">{css}</style> <Switch slotProps={slotProps} />
596
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/customization/StylingCustomCss.js
import * as React from 'react'; import { Switch as SwitchUnstyled, switchClasses } from '@mui/base/Switch'; const css = ` .my-switch { font-size: 0; position: relative; display: inline-block; width: 32px; height: 20px; background: #B3C3D3; border-radius: 10px; margin: 10px; cursor: pointer; } .my-switch.${switchClasses.checked} { background: #007FFF; } .my-switch .${switchClasses.thumb} { display: block; width: 14px; height: 14px; top: 3px; left: 3px; border-radius: 16px; background-color: #FFF; position: relative; transition: all 200ms ease; } .my-switch.${switchClasses.checked} .${switchClasses.thumb} { left: 14px; top: 3px; background-color: #FFF; } .my-switch .${switchClasses.input} { cursor: inherit; position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; z-index: 1; margin: 0; }`; export default function StylingCustomCss() { return ( <div> <style type="text/css">{css}</style> <SwitchUnstyled className="my-switch" /> </div> ); }
597
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/customization/StylingCustomCss.tsx
import * as React from 'react'; import { Switch as SwitchUnstyled, switchClasses } from '@mui/base/Switch'; const css = ` .my-switch { font-size: 0; position: relative; display: inline-block; width: 32px; height: 20px; background: #B3C3D3; border-radius: 10px; margin: 10px; cursor: pointer; } .my-switch.${switchClasses.checked} { background: #007FFF; } .my-switch .${switchClasses.thumb} { display: block; width: 14px; height: 14px; top: 3px; left: 3px; border-radius: 16px; background-color: #FFF; position: relative; transition: all 200ms ease; } .my-switch.${switchClasses.checked} .${switchClasses.thumb} { left: 14px; top: 3px; background-color: #FFF; } .my-switch .${switchClasses.input} { cursor: inherit; position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; z-index: 1; margin: 0; }`; export default function StylingCustomCss() { return ( <div> <style type="text/css">{css}</style> <SwitchUnstyled className="my-switch" /> </div> ); }
598
0
petrpan-code/mui/material-ui/docs/data/base/getting-started
petrpan-code/mui/material-ui/docs/data/base/getting-started/customization/StylingCustomCss.tsx.preview
<style type="text/css">{css}</style> <SwitchUnstyled className="my-switch" />
599