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

[joy-ui] Make the size prop breakpoint-aware #41402

Open
cipherlogs opened this issue Mar 7, 2024 · 1 comment
Open

[joy-ui] Make the size prop breakpoint-aware #41402

cipherlogs opened this issue Mar 7, 2024 · 1 comment
Assignees
Labels
new feature New feature or request package: joy-ui Specific to @mui/joy waiting for 👍 Waiting for upvotes

Comments

@cipherlogs
Copy link
Contributor

cipherlogs commented Mar 7, 2024

Summary

Take a look at this code snippet:

<IconButton size="lg">{icon}</IconButton>

If you want to change the size prop on certain screen sizes with Material UI, you can use hooks:

import { useTheme } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';

function MyComponent() {
  const theme = useTheme();
  const matches = useMediaQuery(theme.breakpoints.up('sm'));

  return <IconButton size={matches ? "sm" : "lg"}>{icon}</IconButton>;
}

Often it might be too complicated for a simple task. However, it helps us reuse the predefined settings in Material UI's design system. The size prop not only changes the font size but could also affects other properties like margin, padding, height, and width etc ...

With Joy UI, we have to redefine each property separately, which can lead to inconsistencies:

<IconButton
  sx={{
    "--Icon-fontSize": {xs: "new val", md: "new val"},
    "--IconButton-size": {xs: "new val", md: "new val"},
    and other vars ...
  }}
>

It would be better to stay within the design system and respect the predefined settings that were already set up.

One suggestion is to add support for props to handle breakpoint changes, similar to how ButtonGroup already supports this:

<ButtonGroup spacing={{ xs: 0, sm: 1, md: '2rem' }}>...</ButtonGroup>

This approach would allow you to write something like:

<IconButton size={{xs: "lg", md: "lg"}}>{icon}</IconButton>;

This way, we can easily change the size prop based on different screen sizes while still using the predefined settings in the design system.

Examples

No response

Motivation

No response

Search keywords: breakpoint

@cipherlogs cipherlogs added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 7, 2024
@zannager zannager added the package: joy-ui Specific to @mui/joy label Mar 8, 2024
@danilo-leal danilo-leal added new feature New feature or request waiting for 👍 Waiting for upvotes and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 8, 2024
@danilo-leal
Copy link
Contributor

Hey @cipherlogs, thanks for opening up this issue and for the suggestion! It definitely resonates with me; I also have personally felt this need in many other projects I've worked on before, and it's quite common, I'd say, just given the fact you usually need beefier buttons, for example, on mobile than on desktop.

Given we're currently focused on the Material UI v6 development, we might take a while to return to iterating on this. In the meantime, I've added the "waiting for 👍" label to gauge further community interest! This could actually be something brought up to both Joy UI and Material UI — it'd be handy on both.

@danilo-leal danilo-leal changed the title [joy-ui] Proposing Breakpoint-Aware Size Prop [joy-ui] Make the size prop breakpoint-aware Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request package: joy-ui Specific to @mui/joy waiting for 👍 Waiting for upvotes
Projects
Status: Backlog
Development

No branches or pull requests

4 participants