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

makeStyles in material-ui allows for passing a classes object #49

Closed
paales opened this issue Jan 4, 2022 · 4 comments
Closed

makeStyles in material-ui allows for passing a classes object #49

paales opened this issue Jan 4, 2022 · 4 comments

Comments

@paales
Copy link

paales commented Jan 4, 2022

We've been making styles extendable by something like this:

export type UseStyles<T extends (...args: never[]) => unknown> = {
  classes?: Partial<ReturnType<T>['classes']>
}
const useStyles = makeStyles({ name: 'FixedFab' })((theme: Theme) => ({
  root: {
    width: '100%',
  },
}))

type ComponentProps = UseStyles<typeof useStyles>

function Component(props: ComponentProps) {
  const { classes } = useStyles(props)

  return <div className={classes.root}>asdf</div>
}

function ExtendingComponent() {
  return <Component classes={{ root: 'foo' }} />
}

It currently isn't possible to pass the classes prop, might this be something that can be added?

@garronej
Copy link
Owner

garronej commented Jan 4, 2022

Ok let me have a look.

garronej added a commit that referenced this issue Jan 4, 2022
Signed-off-by: garronej <joseph.garrone.gj@gmail.com>
garronej added a commit that referenced this issue Jan 4, 2022
Signed-off-by: garronej <joseph.garrone.gj@gmail.com>
@garronej
Copy link
Owner

garronej commented Jan 4, 2022

I have released a new utility useMergedClasses in v3.3.0. Hope if fits your needs.

Could you please refer me where this property of makeStyles was documented in material UI v4, couldn't find it?

@paales
Copy link
Author

paales commented Jan 4, 2022

Wooo that was fast! 🎉

It was documented here: https://v4.mui.com/styles/advanced/#makestyles

@garronej
Copy link
Owner

garronej commented Jan 5, 2022

Thank you for pointing this missing feature out. I wasn't aware of its existence but it's a nice addition.
The migration guide should be updated soon.

Best

@garronej garronej closed this as completed Jan 5, 2022
gitbook-com bot pushed a commit that referenced this issue Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants