Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[typography] Allow sx prop-like responsive values on the variant prop #41530

Open
drico opened this issue Mar 17, 2024 · 3 comments
Open

[typography] Allow sx prop-like responsive values on the variant prop #41530

drico opened this issue Mar 17, 2024 · 3 comments
Labels
component: Typography The React component. customization: theme Centered around the theming features

Comments

@drico
Copy link

drico commented Mar 17, 2024

Summary

For a lot of props, the Sx syntax is availble, like

<Typography color={{xs: 'red', md: 'blue'}} >

Or even

<Typography color={(theme) => ({xs: 'red', md: 'blue'})} >

But this syntax doesn't work with the variant prop. => the following is not working

<Typography variant={{xs: 'h1', md: 'h2'}} > // not working
<Typography variant={(theme) => ({xs: 'h1', md: 'h2'})} > // not working

Examples

No response

Motivation

It would be great if this syntax could work. :
Simply to use a different variant depending on screen size (very common use case I think)
It would be very usefull in projects that deal with multiple themes.
It's also usefull during double run (theme migration while both old theme and new theme must coexist in the code).

Search keywords: variant typography

@drico drico added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 17, 2024
@danilo-leal danilo-leal changed the title AllowSx like syntax on Typography's variant prop [typography] Allow sx prop-like responsive values on the variant prop Mar 18, 2024
@danilo-leal danilo-leal added component: Typography The React component. customization: theme Centered around the theming features and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 18, 2024
@danilo-leal
Copy link
Contributor

Hey @drico, thanks for opening the issue! This sounds very much related to this issue: #41402, where they propose to make the size prop "breakpoint-aware". This could work the same with other props, such as variant, in this case.

@brijeshb42 & @siriwatknp, should both of these issues be generalized into something Pigment CSS could handle? I guess whatever approach we take here, it should be standardized and available for Material UI and Joy UI (in the long term). What do y'all think?

@brijeshb42
Copy link
Contributor

I am not sure if this comes under Pigment CSS or even @mui/system. The props for which the sx syntax is available are native css properties and unrelated to that specific component. But @mui/system or Pigment CSS only deals with native CSS properties with some extended syntax.
This requirement is asking to deviate from that and include other properties as well (eg: variant). As an example, variant for one component (primary/secondary for Button) may not mean the same thing for some other component (ie, example above). So it'll ideally have to be dealt with in the package that has these prop definitions.

@danilo-leal
Copy link
Contributor

Ah yeah, true. I guess what both of these issues are requesting is a similar responsive syntax to the sx prop for using different variants depending on the breakpoint. We have the useMediaQuery hook for that already, but maybe there's a more sx-like way to write it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Typography The React component. customization: theme Centered around the theming features
Projects
None yet
Development

No branches or pull requests

3 participants