diff --git a/src/mantine-core/src/Title/Title.styles.ts b/src/mantine-core/src/Title/Title.styles.ts index 1db8c3d9631..f8553bd77bc 100644 --- a/src/mantine-core/src/Title/Title.styles.ts +++ b/src/mantine-core/src/Title/Title.styles.ts @@ -7,6 +7,7 @@ export interface TitleStylesParams { element: HeadingElement; size: TitleSize; weight: React.CSSProperties['fontWeight']; + inline: boolean; } function getFontSize(size: TitleSize, element: HeadingElement, theme: MantineTheme) { @@ -19,19 +20,19 @@ function getFontSize(size: TitleSize, element: HeadingElement, theme: MantineThe function getLineHeight(size: TitleSize, element: HeadingElement, theme: MantineTheme) { if (typeof size !== 'undefined' && size in theme.headings.sizes) { - return theme.headings.sizes[element].lineHeight; + return theme.headings.sizes[size].lineHeight; } return theme.headings.sizes[element].lineHeight; } -export default createStyles((theme, { element, weight, size }: TitleStylesParams) => ({ +export default createStyles((theme, { element, weight, size, inline }: TitleStylesParams) => ({ root: { ...theme.fn.fontStyles(), fontFamily: theme.headings.fontFamily, fontWeight: weight || theme.headings.sizes[element].fontWeight || theme.headings.fontWeight, fontSize: getFontSize(size, element, theme), - lineHeight: getLineHeight(size, element, theme), + lineHeight: inline ? 1 : getLineHeight(size, element, theme), margin: 0, }, })); diff --git a/src/mantine-core/src/Title/Title.tsx b/src/mantine-core/src/Title/Title.tsx index d85bc817921..2c191d79af6 100644 --- a/src/mantine-core/src/Title/Title.tsx +++ b/src/mantine-core/src/Title/Title.tsx @@ -22,11 +22,11 @@ const defaultProps: Partial = { }; export const Title = forwardRef((props, ref) => { - const { className, order, children, unstyled, size, weight, ...others } = + const { className, order, children, unstyled, size, weight, inline, ...others } = useComponentDefaultProps('Title', defaultProps, props); const { classes, cx } = useStyles( - { element: `h${order}`, weight, size }, + { element: `h${order}`, weight, size, inline }, { name: 'Title', unstyled } );