Material-ui: Possible border radius for dialogue?

Created on 29 Aug 2018  路  7Comments  路  Source: mui-org/material-ui

When using the dialogue component, it seems that I'm unable to add a borderRadius to it. Has anyone tried to do this?

Thanks!

Most helpful comment

I solved it with paperProps property.

<Dialog
  PaperProps={{
    style: { borderRadius: 2 }
  }}
  >
  ....
</Dialog>

All 7 comments

You can set the default border radius using MuiThemeProvider:

import YourApp from './YourApp'
import ReactDOM from 'react-dom'
import {createMuiTheme, MuiThemeProvider} from '@material-ui/core/styles'

const theme = createMuiTheme({
    shape: {
        borderRadius: 2
    },
    palette: ...,
    ...
})

ReactDOM.render(
    <MuiThemeProvider theme={theme}>
        <YourApp/>
    </MuiThemeProvider>,
    document.getElementById('root')
)

This will create a global styling applied to all Material-UI components across your application on any level of nesting.

If you don't want other components in your app to be affected, you can always add a className to your Dialog component and set it in your CSS:

.yourClassName > div:nth-child(2) {
    border-radius: 2px;
}
<Dialog className="yourClassName" open>
    ...
</Dialog>

Thank you, that worked great!

I solved it with paperProps property.

<Dialog
  PaperProps={{
    style: { borderRadius: 2 }
  }}
  >
  ....
</Dialog>

Here's for the Drawer https://codesandbox.io/s/vmj9q

@nakanori Is there a simpler way like yours?

I solved it with paperProps property.

<Dialog
  paperProps={{
    style: { borderRadius: 2 }
  }}
  >
  ....
</Dialog>

I think Paper P is capital

You can set the default border radius using MuiThemeProvider:

import YourApp from './YourApp'
import ReactDOM from 'react-dom'
import {createMuiTheme, MuiThemeProvider} from '@material-ui/core/styles'

const theme = createMuiTheme({
    shape: {
        borderRadius: 2
    },
    palette: ...,
    ...
})

ReactDOM.render(
    <MuiThemeProvider theme={theme}>
        <YourApp/>
    </MuiThemeProvider>,
    document.getElementById('root')
)

This will create a global styling applied to all Material-UI components across your application on any level of nesting.

If you don't want other components in your app to be affected, you can always add a className to your Dialog component and set it in your CSS:

.yourClassName > div:nth-child(2) {
    border-radius: 2px;
}
<Dialog className="yourClassName" open>
    ...
</Dialog>

How did you come to know that we have to use "shape"?
Is there any documentation to refer?
If yes, please provide a link.
Thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TimoRuetten picture TimoRuetten  路  3Comments

rbozan picture rbozan  路  3Comments

finaiized picture finaiized  路  3Comments

mb-copart picture mb-copart  路  3Comments

ericraffin picture ericraffin  路  3Comments