true
when the container is a flex row and you want the AspectRatio to fill the height of its container."
+ },
"maxHeight": {
"description": "The maximum calculated height of the element (not the CSS height)."
},
diff --git a/examples/joy-ui-cra-ts/public/index.html b/examples/joy-ui-cra-ts/public/index.html
index a14995814b20f7..84a86e0fe30bf6 100644
--- a/examples/joy-ui-cra-ts/public/index.html
+++ b/examples/joy-ui-cra-ts/public/index.html
@@ -10,7 +10,7 @@
diff --git a/examples/joy-ui-nextjs/src/components/ThemeRegistry/theme.js b/examples/joy-ui-nextjs/src/components/ThemeRegistry/theme.js
index 8dd36fef01d811..18f316a884095e 100644
--- a/examples/joy-ui-nextjs/src/components/ThemeRegistry/theme.js
+++ b/examples/joy-ui-nextjs/src/components/ThemeRegistry/theme.js
@@ -1,15 +1,12 @@
-import { Public_Sans } from 'next/font/google';
+import { Inter } from 'next/font/google';
import { extendTheme } from '@mui/joy/styles';
-const publicSans = Public_Sans({
+Inter({
subsets: ['latin'],
display: 'swap',
});
const theme = extendTheme({
- fontFamily: {
- body: publicSans.style.fontFamily,
- },
components: {
JoyButton: {
styleOverrides: {
diff --git a/examples/joy-ui-vite-ts/index.html b/examples/joy-ui-vite-ts/index.html
index 4c897a34c14538..0396aa17470c55 100644
--- a/examples/joy-ui-vite-ts/index.html
+++ b/examples/joy-ui-vite-ts/index.html
@@ -10,7 +10,7 @@
diff --git a/packages/mui-joy/src/AspectRatio/AspectRatio.tsx b/packages/mui-joy/src/AspectRatio/AspectRatio.tsx
index c5aadf95b810f8..7d0323b1529abc 100644
--- a/packages/mui-joy/src/AspectRatio/AspectRatio.tsx
+++ b/packages/mui-joy/src/AspectRatio/AspectRatio.tsx
@@ -45,6 +45,8 @@ const AspectRatioRoot = styled('div', {
? 'currentColor'
: theme.vars.palette.text.icon,
borderRadius: 'var(--AspectRatio-radius)',
+ display: ownerState.flex ? 'flex' : 'block',
+ flex: ownerState.flex ? 1 : 'initial',
flexDirection: 'column',
margin: 'var(--AspectRatio-margin)',
};
@@ -112,6 +114,7 @@ const AspectRatio = React.forwardRef(function AspectRatio(inProps, ref) {
color: colorProp = 'neutral',
variant = 'soft',
component,
+ flex = false,
slots = {},
slotProps = {},
...other
@@ -121,6 +124,7 @@ const AspectRatio = React.forwardRef(function AspectRatio(inProps, ref) {
const ownerState = {
...props,
+ flex,
minHeight,
maxHeight,
objectFit,
@@ -180,6 +184,12 @@ AspectRatio.propTypes /* remove-proptypes */ = {
* Either a string to use a HTML element or a component.
*/
component: PropTypes.elementType,
+ /**
+ * By default, the AspectRatio will maintain the aspect ratio of its content.
+ * Set this prop to `true` when the container is a flex row and you want the AspectRatio to fill the height of its container.
+ * @default false
+ */
+ flex: PropTypes.bool,
/**
* The maximum calculated height of the element (not the CSS height).
*/
diff --git a/packages/mui-joy/src/AspectRatio/AspectRatioProps.ts b/packages/mui-joy/src/AspectRatio/AspectRatioProps.ts
index 90be05d28e0f2d..121e6de62c4299 100644
--- a/packages/mui-joy/src/AspectRatio/AspectRatioProps.ts
+++ b/packages/mui-joy/src/AspectRatio/AspectRatioProps.ts
@@ -42,6 +42,12 @@ export interface AspectRatioTypeMap* This can be an element, or just a string. */ children?: React.ReactNode; + /** + * By default, the AspectRatio will maintain the aspect ratio of its content. + * Set this prop to `true` when the container is a flex row and you want the AspectRatio to fill the height of its container. + * @default false + */ + flex?: boolean; /** * The minimum calculated height of the element (not the CSS height). */ diff --git a/packages/mui-joy/src/Breadcrumbs/Breadcrumbs.tsx b/packages/mui-joy/src/Breadcrumbs/Breadcrumbs.tsx index e228d46a9bf6ad..597feaa781c1db 100644 --- a/packages/mui-joy/src/Breadcrumbs/Breadcrumbs.tsx +++ b/packages/mui-joy/src/Breadcrumbs/Breadcrumbs.tsx @@ -35,14 +35,17 @@ const BreadcrumbsRoot = styled('nav', { })<{ ownerState: BreadcrumbsOwnerState }>(({ theme, ownerState }) => ({ ...(ownerState.size === 'sm' && { '--Breadcrumbs-gap': '0.25rem', + '--Icon-fontSize': theme.vars.fontSize.lg, padding: '0.5rem', }), ...(ownerState.size === 'md' && { '--Breadcrumbs-gap': '0.375rem', + '--Icon-fontSize': theme.vars.fontSize.xl, padding: '0.75rem', }), ...(ownerState.size === 'lg' && { '--Breadcrumbs-gap': '0.5rem', + '--Icon-fontSize': theme.vars.fontSize.xl2, padding: '1rem', }), ...theme.typography[`body-${ownerState.size!}`], diff --git a/packages/mui-joy/src/Card/Card.tsx b/packages/mui-joy/src/Card/Card.tsx index ec05cc6cacbb93..c4caf13ebad36a 100644 --- a/packages/mui-joy/src/Card/Card.tsx +++ b/packages/mui-joy/src/Card/Card.tsx @@ -66,8 +66,8 @@ const CardRoot = styled('div', { '--Divider-inset': 'calc(-1 * var(--Card-padding))', ...(ownerState.size === 'sm' && { '--Card-radius': theme.vars.radius.sm, - '--Card-padding': '0.5rem', - gap: '0.375rem 0.5rem', + '--Card-padding': '0.625rem', + gap: '0.5rem', }), ...(ownerState.size === 'md' && { '--Card-radius': theme.vars.radius.md, diff --git a/packages/mui-joy/src/CardContent/CardContent.tsx b/packages/mui-joy/src/CardContent/CardContent.tsx index 251ce36b32c143..d047e8b8200ed7 100644 --- a/packages/mui-joy/src/CardContent/CardContent.tsx +++ b/packages/mui-joy/src/CardContent/CardContent.tsx @@ -26,9 +26,10 @@ const CardContentRoot = styled('div', { })<{ ownerState: CardContentProps }>(({ ownerState }) => ({ display: 'flex', flexDirection: ownerState.orientation === 'horizontal' ? 'row' : 'column', - flex: 1, // fill the available space in the Card and also shrink if needed + flex: 9999, // fill the available space in the Card and also shrink if needed zIndex: 1, columnGap: 'var(--Card-padding)', + rowGap: 'max(2px, calc(0.1875 * var(--Card-padding)))', padding: 'var(--unstable_padding)', [`.${cardOverflowClasses.root} > &`]: { '--unstable_padding': 'calc(var(--Card-padding) * 0.75) 0px', diff --git a/packages/mui-joy/src/CardOverflow/CardOverflow.tsx b/packages/mui-joy/src/CardOverflow/CardOverflow.tsx index dd994e27c57118..17ed565de6d0dd 100644 --- a/packages/mui-joy/src/CardOverflow/CardOverflow.tsx +++ b/packages/mui-joy/src/CardOverflow/CardOverflow.tsx @@ -46,6 +46,7 @@ const CardOverflowRoot = styled('div', { alignSelf: 'stretch', // prevent shrinking if parent's align-items is not initial borderRadius: 'var(--CardOverflow-radius)', position: 'relative', + display: 'flex', ...(ownerState['data-parent'] === 'Card-horizontal' && { '--AspectRatio-margin': 'calc(-1 * var(--Card-padding)) 0px', marginTop: 'var(--CardOverflow-offset)', @@ -76,6 +77,7 @@ const CardOverflowRoot = styled('div', { }), ...(ownerState['data-parent'] === 'Card-vertical' && { '--AspectRatio-margin': '0px calc(-1 * var(--Card-padding))', + flexDirection: 'column', // required to make AspectRatio works marginLeft: 'var(--CardOverflow-offset)', marginRight: 'var(--CardOverflow-offset)', padding: '0px var(--Card-padding)', diff --git a/packages/mui-joy/src/IconButton/IconButton.tsx b/packages/mui-joy/src/IconButton/IconButton.tsx index 172cc4e886d7db..02964cb2752023 100644 --- a/packages/mui-joy/src/IconButton/IconButton.tsx +++ b/packages/mui-joy/src/IconButton/IconButton.tsx @@ -100,10 +100,7 @@ export const StyledIconButton = styled('button')<{ ownerState: IconButtonOwnerSt '--Icon-color': 'currentColor', ...theme.variants[`${ownerState.variant!}Active`]?.[ownerState.color!], }, - '&:disabled': { - '--Icon-color': 'currentColor', - ...theme.variants[`${ownerState.variant!}Disabled`]?.[ownerState.color!], - }, + '&:disabled': theme.variants[`${ownerState.variant!}Disabled`]?.[ownerState.color!], }, ], ); diff --git a/packages/mui-joy/src/ListItemButton/ListItemButton.tsx b/packages/mui-joy/src/ListItemButton/ListItemButton.tsx index 386494e577a9ab..c4e390afeaf8f0 100644 --- a/packages/mui-joy/src/ListItemButton/ListItemButton.tsx +++ b/packages/mui-joy/src/ListItemButton/ListItemButton.tsx @@ -12,6 +12,7 @@ import { ExtendListItemButton, ListItemButtonTypeMap, } from './ListItemButtonProps'; +import listItemClasses from '../ListItem/listItemClasses'; import listItemButtonClasses, { getListItemButtonUtilityClass } from './listItemButtonClasses'; import ListItemButtonOrientationContext from './ListItemButtonOrientationContext'; import RowListContext from '../List/RowListContext'; @@ -50,6 +51,7 @@ export const StyledListItemButton = styled('div')<{ ownerState: ListItemButtonOw WebkitTapHighlightColor: 'transparent', boxSizing: 'border-box', position: 'relative', + font: 'inherit', display: 'flex', flexDirection: 'row', alignItems: 'center', @@ -79,9 +81,7 @@ export const StyledListItemButton = styled('div')<{ ownerState: ListItemButtonOw minBlockSize: 'var(--ListItem-minHeight)', border: '1px solid transparent', // use `transparent` as a placeholder to prevent the button from jumping when switching to `outlined` variant borderRadius: 'var(--ListItem-radius)', - flexGrow: ownerState.row ? 0 : 1, - flexBasis: ownerState.row ? 'auto' : '0%', // for long text (in vertical), displays in multiple lines. - flexShrink: 0, + flex: 'var(--unstable_ListItem-flex, none)', // prevent children from shrinking when the List's height is limited. fontSize: 'inherit', // prevent user agent style when component="button" lineHeight: 'inherit', // prevent user agent style when component="button" minInlineSize: 0, @@ -90,6 +90,9 @@ export const StyledListItemButton = styled('div')<{ ownerState: ListItemButtonOw zIndex: 1, // to be above of the next element. For example, the first Tab item should be above the second so that the outline is above the second Tab. }, ...theme.variants[ownerState.variant!]?.[ownerState.color!], + [`.${listItemClasses.root} > &`]: { + '--unstable_ListItem-flex': '1 0 0%', // grow to fill the available space of ListItem + }, [`&.${listItemButtonClasses.selected}`]: { ...theme.variants[`${ownerState.variant!}Active`]?.[ownerState.color!], '--Icon-color': 'currentColor', diff --git a/packages/mui-joy/src/ModalClose/ModalClose.tsx b/packages/mui-joy/src/ModalClose/ModalClose.tsx index eaff60f72b60f4..9a351bca5503e0 100644 --- a/packages/mui-joy/src/ModalClose/ModalClose.tsx +++ b/packages/mui-joy/src/ModalClose/ModalClose.tsx @@ -48,6 +48,7 @@ export const ModalCloseRoot = styled(StyledIconButton, { '--IconButton-size': '40px', }), position: 'absolute', + zIndex: 1, // stay on top of the title in case it is positioned relatively top: `var(--ModalClose-inset, ${theme.spacing(1)})`, right: `var(--ModalClose-inset, ${theme.spacing(1)})`, borderRadius: `var(--ModalClose-radius, ${theme.vars.radius.sm})`, diff --git a/packages/mui-joy/src/Tab/Tab.tsx b/packages/mui-joy/src/Tab/Tab.tsx index 2f1758ef5bc7c0..c9d8342d03b361 100644 --- a/packages/mui-joy/src/Tab/Tab.tsx +++ b/packages/mui-joy/src/Tab/Tab.tsx @@ -145,6 +145,7 @@ const Tab = React.forwardRef(function Tab(inProps, ref) { color: colorProp = 'neutral', disableIndicator = false, indicatorPlacement = row ? 'bottom' : 'right', + indicatorInset = false, slots = {}, slotProps = {}, ...other @@ -175,6 +176,7 @@ const Tab = React.forwardRef(function Tab(inProps, ref) { ...props, disableIndicator, indicatorPlacement, + indicatorInset, orientation, row, active, @@ -250,6 +252,7 @@ Tab.propTypes /* remove-proptypes */ = { disableIndicator: PropTypes.bool, /** * If `true`, the indicator stay within the padding based on the `Tabs` orientation. + * @default false */ indicatorInset: PropTypes.bool, /** diff --git a/packages/mui-joy/src/Tab/TabProps.ts b/packages/mui-joy/src/Tab/TabProps.ts index fe2687c5d3d3e2..733a049f9941df 100644 --- a/packages/mui-joy/src/Tab/TabProps.ts +++ b/packages/mui-joy/src/Tab/TabProps.ts @@ -53,6 +53,7 @@ export interface TabTypeMap
{ indicatorPlacement?: 'top' | 'bottom' | 'left' | 'right'; /** * If `true`, the indicator stay within the padding based on the `Tabs` orientation. + * @default false */ indicatorInset?: boolean; /** diff --git a/packages/mui-joy/src/TabList/TabList.tsx b/packages/mui-joy/src/TabList/TabList.tsx index a2ddecfeb89b7e..0deee34964e486 100644 --- a/packages/mui-joy/src/TabList/TabList.tsx +++ b/packages/mui-joy/src/TabList/TabList.tsx @@ -117,6 +117,7 @@ const TabList = React.forwardRef(function TabList(inProps, ref) { size: sizeProp, disableUnderline = false, underlinePlacement = orientation === 'horizontal' ? 'bottom' : 'right', + tabFlex, sticky, slots = {}, slotProps = {}, @@ -135,6 +136,7 @@ const TabList = React.forwardRef(function TabList(inProps, ref) { color, size, sticky, + tabFlex, nesting: false, disableUnderline, underlinePlacement, diff --git a/packages/mui-joy/src/Typography/Typography.tsx b/packages/mui-joy/src/Typography/Typography.tsx index 679c7884d2cd19..6001aa8e639ad8 100644 --- a/packages/mui-joy/src/Typography/Typography.tsx +++ b/packages/mui-joy/src/Typography/Typography.tsx @@ -87,6 +87,7 @@ const TypographyRoot = styled('span', { } : { display: 'block', // don't rely on user agent, always `block`. + position: 'relative', }), ...((ownerState.startDecorator || ownerState.endDecorator) && { display: 'flex', diff --git a/packages/mui-joy/src/styles/extendTheme.ts b/packages/mui-joy/src/styles/extendTheme.ts index 48a021a05f236c..d7d6eed4aabe89 100644 --- a/packages/mui-joy/src/styles/extendTheme.ts +++ b/packages/mui-joy/src/styles/extendTheme.ts @@ -447,7 +447,7 @@ export default function extendTheme(themeOptions?: CssVarsThemeOptions): Theme { fontFamily: getCssVar(`fontFamily-display, ${fontFamily.display}`), fontWeight: getCssVar(`fontWeight-lg, ${fontWeight.lg}`), fontSize: getCssVar(`fontSize-xl2, ${fontSize.xl2}`), - lineHeight: getCssVar(`lineHeight-md, ${lineHeight.md}`), + lineHeight: getCssVar(`lineHeight-xs, ${lineHeight.xs}`), letterSpacing: '-0.025em', color: getCssVar(`palette-text-primary, ${lightColorSystem.palette.text.primary}`), }, @@ -456,7 +456,7 @@ export default function extendTheme(themeOptions?: CssVarsThemeOptions): Theme { fontFamily: getCssVar(`fontFamily-display, ${fontFamily.display}`), fontWeight: getCssVar(`fontWeight-lg, ${fontWeight.lg}`), fontSize: getCssVar(`fontSize-xl, ${fontSize.xl}`), - lineHeight: getCssVar(`lineHeight-lg, ${lineHeight.lg}`), + lineHeight: getCssVar(`lineHeight-md, ${lineHeight.md}`), letterSpacing: '-0.025em', color: getCssVar(`palette-text-primary, ${lightColorSystem.palette.text.primary}`), }, @@ -465,7 +465,7 @@ export default function extendTheme(themeOptions?: CssVarsThemeOptions): Theme { fontFamily: getCssVar(`fontFamily-body, ${fontFamily.body}`), fontWeight: getCssVar(`fontWeight-lg, ${fontWeight.lg}`), fontSize: getCssVar(`fontSize-lg, ${fontSize.lg}`), - lineHeight: getCssVar(`lineHeight-xl, ${lineHeight.xl}`), + lineHeight: getCssVar(`lineHeight-xs, ${lineHeight.xs}`), color: getCssVar(`palette-text-primary, ${lightColorSystem.palette.text.primary}`), }, @@ -488,7 +488,7 @@ export default function extendTheme(themeOptions?: CssVarsThemeOptions): Theme { 'body-lg': { fontFamily: getCssVar(`fontFamily-body, ${fontFamily.body}`), fontSize: getCssVar(`fontSize-lg, ${fontSize.lg}`), - lineHeight: getCssVar(`lineHeight-lg, ${lineHeight.lg}`), + lineHeight: getCssVar(`lineHeight-md, ${lineHeight.md}`), color: getCssVar(`palette-text-secondary, ${lightColorSystem.palette.text.secondary}`), }, @@ -502,7 +502,7 @@ export default function extendTheme(themeOptions?: CssVarsThemeOptions): Theme { 'body-sm': { fontFamily: getCssVar(`fontFamily-body, ${fontFamily.body}`), fontSize: getCssVar(`fontSize-sm, ${fontSize.sm}`), - lineHeight: getCssVar(`lineHeight-sm, ${lineHeight.sm}`), + lineHeight: getCssVar(`lineHeight-md, ${lineHeight.md}`), color: getCssVar(`palette-text-tertiary, ${lightColorSystem.palette.text.tertiary}`), }, @@ -510,7 +510,7 @@ export default function extendTheme(themeOptions?: CssVarsThemeOptions): Theme { fontFamily: getCssVar(`fontFamily-body, ${fontFamily.body}`), fontWeight: getCssVar(`fontWeight-md, ${fontWeight.md}`), fontSize: getCssVar(`fontSize-xs, ${fontSize.xs}`), - lineHeight: getCssVar(`lineHeight-xl, ${lineHeight.xl}`), + lineHeight: getCssVar(`lineHeight-md, ${lineHeight.md}`), color: getCssVar(`palette-text-tertiary, ${lightColorSystem.palette.text.tertiary}`), }, }, diff --git a/packages/mui-joy/src/styles/variantUtils.test.js b/packages/mui-joy/src/styles/variantUtils.test.js index 1f790a0239a73f..3d02f0452bf10c 100644 --- a/packages/mui-joy/src/styles/variantUtils.test.js +++ b/packages/mui-joy/src/styles/variantUtils.test.js @@ -240,6 +240,7 @@ describe('variant utils', () => { }, outlinedDisabled: { primary: { + '--Icon-color': 'currentColor', color: 'var(--any-token)', borderColor: 'var(--any-token)', backgroundColor: 'var(--any-token)', diff --git a/packages/mui-joy/src/styles/variantUtils.ts b/packages/mui-joy/src/styles/variantUtils.ts index b96a85b75f632e..6d8f512b530a2b 100644 --- a/packages/mui-joy/src/styles/variantUtils.ts +++ b/packages/mui-joy/src/styles/variantUtils.ts @@ -67,6 +67,7 @@ export const createVariantStyle = ( if (variantVar.includes('Disabled')) { result.pointerEvents = 'none'; result.cursor = 'default'; + result['--Icon-color'] = 'currentColor'; } if (variantVar.match(/(Hover|Active|Disabled)/)) { assignCss(result as any, variantVar, cssVar); @@ -280,7 +281,7 @@ export const createSoftInversion = ( [prefixVar('--palette-text-tertiary')]: `rgba(${getCssVar( `palette-${color}-darkChannel`, )} / 0.68)`, - [prefixVar('--palette-text-icon')]: getCssVar(`palette-${color}-400`), + [prefixVar('--palette-text-icon')]: getCssVar(`palette-${color}-500`), [prefixVar('--palette-divider')]: `rgba(${getCssVar( `palette-${color}-mainChannel`, )} / 0.32)`,