question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disabling Theme transitions do not work without the presence of CssBaseline

See original GitHub issue

The FAQ documentation states how to disable transitions with

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

const theme = createMuiTheme({
  transitions: {
    // So we have `transition: none;` everywhere
    create: () => 'none',
  },
});
  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior 🤔

Progress bars should not animate.

Current Behavior 😯

Transitions are not disabled. However if I add

import CssBaseline from "@material-ui/core/CssBaseline";

somewhere in the rendering tree, transitions stop

	<MuiThemeProvider theme={theme}>
      <div>
        <CssBaseline />
        <LinearProgress />
        <br />
        <LinearProgress color="secondary" />
      </div>
    </MuiThemeProvider>

Steps to Reproduce 🕹

See example: https://codesandbox.io/s/material-demo-yq0x1

Context 🔦

This is breaking all visual regression thats show progress bars.

Your Environment 🌎

Tech Version
Material-UI v4.1.3
React v16.8.6
Browser Chrome

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
oliviertassinaricommented, Jul 12, 2019

@KamalAman Yes, this would work too. The incentive for using CssBaseline is to rely on the theme configuration exclusively. Maybe we should only show the CSS that needs to be generated and leave the implementation out as a detail.

What do you think, do you want to submit a pull request? 😃

1reaction
KamalAmancommented, Jul 14, 2019

@oliviertassinari While adding CssBaseline did disable the transitions, it has other unnecessary side effects.

I seems like documenting MuiCssBaseline and CssBaseline as a requirement to disable transitions is redundant and has unnecessary side effects since it modifies other styles.

One solution is that you could just document how to disable transitions and animations without using a theme.

e.g. To disable transitions and animations add a global css selector

const useStyles = makeStyles(
  theme => ({
    '@global': {
      '*, *::before, *::after': {
        transition: 'none !important',
        animation: 'none !important',
      },
    },
  }),
  { name: 'CssBaseline' },
);

function CssDisableTransitions(props) {
  const { children = null } = props;
  useStyles();
  return <React.Fragment>{children}</React.Fragment>;
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disabling Theme transitions do not work without the presence ...
I seems like documenting MuiCssBaseline and CssBaseline as a requirement to disable transitions is redundant and has unnecessary side effects ...
Read more >
CSS Baseline - Material UI - MUI
The CssBaseline component helps to kickstart an elegant, consistent, and simple baseline to build upon.
Read more >
how to disable all transitions in material UI while under test
There is a setting that can be applied in the Material UI theme that will globally disable transitions const theme = { transitions: ......
Read more >
@material-ui/core | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
material-ui/core/CHANGELOG.md - UNPKG
This is a reminder that all ongoing work has moved to v5. This means a feature freeze on v4. The development of v4...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found