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

Support array in sx prop #46

Closed
siriwatknp opened this issue May 2, 2024 · 1 comment · Fixed by #52
Closed

Support array in sx prop #46

siriwatknp opened this issue May 2, 2024 · 1 comment · Fixed by #52
Assignees
Labels
new feature New feature or request

Comments

@siriwatknp
Copy link
Member

siriwatknp commented May 2, 2024

Summary

The sx prop should support array format to cover these cases:

  • array of styles

    // developer's codebase
    <div
      sx={[
        { display: 'flex',  },
        numSelected > 0 && {
           bgcolor: 'white',
         },
      ]}
    />
    
    // transformed
    <div {...sx(['s1o8xp19', 's1o8xp19-1'], {})} />
  • array of function

     // developer's codebase
     <div
       sx={[
         theme => ({ display: 'flex', fontSize: theme.vars.font.xl }),
         numSelected > 0 && (theme => {
            bgcolor: theme.vars.palette.primary.main,
            …theme.applyStyles('dark', {
              bgcolor: theme.vars.palette.primary.light,
            })
          }),
       ]}
     />
    
     // transformed
     <div {...sx(['s1xbsywq', numSelected > 0 && 's1xbsywq-0'], {})} />

Examples

No response

Motivation

To ease v5 to v6 migration and ensure feature parity with the current MUI system's sx.

Search keywords: array sx prop

@siriwatknp siriwatknp added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 2, 2024
@siriwatknp siriwatknp added new feature New feature or request and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 2, 2024
@brijeshb42
Copy link
Contributor

This, though possible, is slightly tricky to implement, especially with all the conditionals. I have started working on it and I'll see where this leads to.

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants