Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Material-Ui apply pseudo class '::before' with component class props

I try to use a pseudo class for the mui-app-bar. Ive read some questions about it here. But it didnt bring me any further. My component looks like this:

const styles = (theme: Theme) => createStyles({
    appBar: {
        backgroundColor: theme.palette.background.default,
        height: '48px',
        '&::before': {
            content: "",
            position: 'absolute',
            left: '2.5%',
            bottom: 0,
            right: '2.5%',
            width: '95%',
            borderBottom: '1px solid magenta',
        }
    }
});

class TabBar extends React.Component<WithStyles<typeof styles> & WithTranslation, TabBarInterface> {
...
render() {
        const { classes } = this.props;
        ...

        return (
                <AppBar className={classes.appBar} position="relative">
                  ...
                </AppBar>

        );
    }
}

export default withStyles(styles)(withTranslation()(TabBar));

Edit

Applying the pseudo class with one colon did not work for me either.

like image 209
MarcoLe Avatar asked Oct 31 '25 06:10

MarcoLe


1 Answers

It is because content value actually is empty. You need to use something like:

'&::before': { 
  content: '""',
}
like image 160
Vladislav Zaynchkovsky Avatar answered Nov 01 '25 20:11

Vladislav Zaynchkovsky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!