mui / mui/material-ui

[cssVariables] Creating variables for typography with responsive incorrectly and not work

Open
#44,294 4 comments 2 reactions 1 assignee View on GitHub

@siriwatknp is already working on this.

Since Nov 4, 2024.

customization: theme scope: typography type: new feature
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Steps to reproduce

When create theme with typography with h1 include responsive:

const theme = createTheme({
...
  typography: {
    fontFamily: roboto.style.fontFamily,
    h1: {
      fontSize: '2.8rem',
      color: 'red',
      fontWeight: 'bold',
      '@media (min-width:300px)': {
        fontSize: '3rem',
      },
      '@media (min-width:400px)': {
        fontSize: '4rem',
      },
    },
  ...
  },
...
  },
});
Current behavior
This variable appears to be non-existent or malformed

// output:
  '@media (min-width:400px)': {
    fontSize: var(--typography-h1-@media (min-width:400px)-fontSize)
  },

https://stackblitz.com/edit/github-emurbz?file=src%2Ftheme.ts,src%2Fapp%2Fpage.tsx,src%2Fcomponents%2FProTip.tsx,src%2Fcomponents%2FCopyright.tsx

kk

xx

Expected behavior

Generate variables that match media keys (300px, 400px...) and accept these values.

Context

No response

Your environment

No response

Search keywords: cssVariables typography responsive

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.