mui / mui/material-ui

[RFC] standardize & document optimal styling method: class vs ownerState

Open
#35,984 3 comments 0 reactions 1 assignee View on GitHub

@siriwatknp is already working on this.

Since Jan 31, 2023.

RFC scope: all components
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

What's the problem? 🤔

For Material, ListItemButton uses &.${listItemButtonClasses.selected} : https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ListItemButton/ListItemButton.js#L77-L103

For Joy-UI, ListItemButton uses ...(ownerState.selected && {: https://github.com/mui/material-ui/blob/master/packages/mui-joy/src/ListItemButton/ListItemButton.tsx#L87-L98

What are the requirements? ❓

It seems as if using the class styling might lead to fewer distinct styles, as I think the ownerState would result in a new distinct CSS class for selected items, replicating the CSS properties from the unselected item.

It'd be great if there was documentation about the optimal method to produce the most efficient CSS or the trade-offs of each.

What are our options? 💡

Both ownerState and the classes seem equally easy to use, so I think it ultimately comes down to which creates optimal CSS.

Proposed solution 🟢
  • Determine if there's any benefit to one method over the other.
  • Document said benefits/trade-offs.
  • Standardize provided components with optimal method.
Resources and benchmarks 🔗

No response

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.