Перейти к контенту

Переходы

The theme key enables you to customize the durations and easings of the various transitions used across Material-UI components, and offers a utility for creating custom transitions.

API

theme.transitions.create(props, options) => transition

Аргументы

  1. props (String | String[]): Defaults to ['all']. Provides a CSS property, or a list of CSS properties that should be transitioned.
  2. варианты (объекта [optional]):
  • options.duration (String | Number [optional]): Defaults to theme.transitions.duration.standard. Provides the duration of the transition.
  • options.easing (String [optional]): Defaults to theme.transitions.easing.easeInOut. Provides the easing for the transition.
  • options.delay (String | Number [optional]): Defaults to 0. Provides the delay for the transition.

Возвращает

transition: A CSS transition value, which composes all CSS properties that should be transitioned, together with the defined duration, easing and delay.

Use the theme.transitions.create() helper to create consistent transitions for the elements of your UI.

theme.transitions.create(['background-color', 'transform']);

Пример

theme.transitions.getAutoHeightDuration(height) => duration

Аргументы

  1. height (Number): The height of the component.

Возвращает

duration: The calculated duration based on the height.

Durations

You can change some or all of the duration values, or provide your own (for use in the create() helper). This example shows all the default values (in milliseconds), but you only need to provide the keys you wish to change or add.

const theme = createMuiTheme({
  transitions: {
    duration: {
      shortest: 150,
      shorter: 200,
      short: 250,
      // most basic recommended timing
      standard: 300,
      // this is to be used in complex animations
      complex: 375,
      // recommended when something is entering screen
      enteringScreen: 225,
      // recommended when something is leaving screen
      leavingScreen: 195,
    },
  },
});

Easings

You can change some or all of the easing values, or provide your own, by providing a custom CSS transition-timing-function value.

const theme = createMuiTheme({
  transitions: {
    easing: {
      // This is the most common easing curve.
      easeInOut: 'cubic-bezier(0.4, 0, 0.2, 1)',
      // Objects enter the screen at full velocity from off-screen and
      // slowly decelerate to a resting point.
      easeOut: 'cubic-bezier(0.0, 0, 0.2, 1)',
      // Objects leave the screen at full velocity. They do not decelerate when off-screen.
      easeIn: 'cubic-bezier(0.4, 0, 1, 1)',
      // The sharp curve is used by objects that may return to the screen at any time.
      sharp: 'cubic-bezier(0.4, 0, 0.6, 1)',
    },
  },
});

References

Check out the Transitions page to explore the transition components that are included with Material-UI.