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

[CircularProgress] String format for size prop not documented #17039

Closed
cmeeren opened this issue Aug 17, 2019 · 6 comments · Fixed by #17081
Closed

[CircularProgress] String format for size prop not documented #17039

cmeeren opened this issue Aug 17, 2019 · 6 comments · Fixed by #17081
Labels
component: CircularProgress The React component component: progress This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@cmeeren
Copy link
Contributor

cmeeren commented Aug 17, 2019

There seems to be an error in the CircularProgress docs. The size prop says it can be a number or a string. But setting a string value seems to have no effect on the size. Only a number works.

@safaiyeh
Copy link

safaiyeh commented Aug 18, 2019

I checked out the CircularProgress. You're right, the implementation only accounts for number sizes.

@mbrookes mbrookes changed the title CircularProgress.size can only be number, not string [CircularProgress] size can only be number, not string Aug 18, 2019
@mbrookes mbrookes added bug 🐛 Something doesn't work component: CircularProgress The React component good first issue Great for first contributions. Enable to learn the contribution process. labels Aug 18, 2019
@devsumanmdn
Copy link
Contributor

devsumanmdn commented Aug 19, 2019

size is directly used as height and width:
https://github.com/mui-org/material-ui/blob/e5b4aa019294c99a84f1a3c3ea3da8e535cf3f70/packages/material-ui/src/CircularProgress/CircularProgress.js#L144
So if someone passes 24 or "24px" it works, because React will automatically append a “px” suffix to certain numeric inline style properties. But for a string value "24" it will not append any prefix.

In my personal opinion, it's fine to not append a "px" to a string.
CodeSandbox
New bug: nothing shown when setting size as "24".

@cmeeren
Copy link
Contributor Author

cmeeren commented Aug 19, 2019

It also seems e.g. 4em works, so I guess any CSS unit works?

@devsumanmdn
Copy link
Contributor

It also seems e.g. 4em works, so I guess any CSS unit works?

Yes, if its a string it'll use that as it is. React uses CSS-in-JS pattern for its inline styling.

@mbrookes mbrookes added docs Improvements or additions to the documentation and removed bug 🐛 Something doesn't work good first issue Great for first contributions. Enable to learn the contribution process. labels Aug 19, 2019
@mbrookes
Copy link
Member

I was thinking we should convert the string to a number; but since it seems it accepts a string with units, we should document that instead, otherwise it would be a breaking change.

@mbrookes mbrookes added the good first issue Great for first contributions. Enable to learn the contribution process. label Aug 19, 2019
@mbrookes mbrookes changed the title [CircularProgress] size can only be number, not string [CircularProgress] String format for size prop not documented Aug 19, 2019
@oliviertassinari
Copy link
Member

Agree, so something like this?

diff --git a/packages/material-ui/src/CircularProgress/CircularProgress.js b/packages/material-ui/src/CircularProgress/CircularProgress.js
index 143174a8b..29b0f49e9 100644
--- a/packages/material-ui/src/CircularProgress/CircularProgress.js
+++ b/packages/material-ui/src/CircularProgress/CircularProgress.js
@@ -196,6 +196,7 @@ CircularProgress.propTypes = {
   }),
   /**
    * The size of the circle.
+   * If using a string, you need to provide the CSS unit, e.g '3rem'.
    */
   size: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
   /**

@oliviertassinari oliviertassinari added the component: progress This is the name of the generic UI component, not the React module! label Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: CircularProgress The React component component: progress This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants