Paper-Button always as upper case

I am using Paper-Button but I am facing issue that the button text always gets capitalized instead or normal case. I do not see any CSS or Javascript property being applied to make it upper case.

How should I resolve this problem?

92261 次浏览

As was mentioned in the comments above, the material design spec for buttons specifies that the text should be uppercase, but you can easily override its CSS property:

paper-button {
text-transform: none;
}

I had the same issue and I solved the problem via adjusting the default theme. Add the following code to a file (name of your choice).js

import { createMuiTheme } from '@material-ui/core/styles';


const theme = createMuiTheme({
typography: {
button: {
textTransform: 'none'
}
}
});


export default theme;

You can then add the file to your app in index.js. I named it theme.js:

...
import theme from './theme';
...
const app = () => (
<ThemeProvider theme={theme}>
<CssBaseline />
<App />
</ThemeProvider>
);


ReactDOM.render(app, document.getElementById('root'));

Inspired by the the CSS style above here is the inline styling for localized Button text transformation -

import {Button} from '@material-ui/core';


// Begin Component Logic
 

<Button style=\{\{textTransform: 'none'}}>
Hello World
</Button>


// End Component Logic

If you use Mui 5 then you can use the sx syntax

<Button sx=\{\{textTransform: "none"}}/>