Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add borderTop to React Material UI Table?

enter image description here

What I want to do add top-border to above table.

I tried

const styles = theme => {
    root : { borderTopWidth: 1, borderColor: 'red'}
}

...

class TableComponent ...

{ classes } = this.props; 

<Table className={classes.root}>
</Table

export default withStyles(styles)(TableComponent)

I believe it's not a syntax problem, because other option like background: 'red' working properly. Perhaps I missed something. How can I implement topBorder to this table?

like image 710
ton1 Avatar asked May 16 '18 14:05

ton1


People also ask

How do you add border radius in MUI?

To quickly add a border radius to all instances of a component, create a custom theme and add an overrides section. To create a custom theme, use the createMuiTheme hook. Then import that theme at a high level in your component and wrap all subcomponents in a ThemeProvider that uses that theme.

How do I add a border to my material UI card?

You should use the borderColor prop on it like this: <Box borderColor="primary. main">… <Box borderColor="secondary.


1 Answers

You forgot to define a borderStyle property

const styles = theme => {
    root : { borderTopWidth: 1, borderColor: 'red',borderStyle: 'solid'} // or borderTop: '1px solid red'
}

...

class TableComponent ...

{ classes } = this.props; 

<Table className={classes.root}>
</Table

export default withStyles(styles)(TableComponent)

or you can just add inline style like

<Table style={{borderTop: '1px solid red'}}>
</Table>
like image 191
Liam Avatar answered Oct 09 '22 22:10

Liam