百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-show

> 编程语言
开源

⚛️ 一个 3kb 的 CSS 动画组件,适用于 React。

399 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

⚛️ 一个 3kb 的 CSS 动画组件,适用于 React。

React Show

A css powered (graphics accelerated) animation component for React.

Why?

  • You need to animate, reveal, collapse your react components. Everyone does!
  • You want it smoothly animated, even on mobile. Like butter on a glide-cam!
  • You don't want to bloat your app with custom physics-based animation frameworks, request-animation-frame-happy animation loops or even jQuery...heaven forbid.

Features

  • 3.7 kb gzipped
  • Powered by native CSS animations & transitions on the GPU when possible
  • Animates height: auto; and width: auto;

Demo

  • Codesandbox.io

Chat with us on Spectrum!

Need Help? Click here to sign up for the React-Tools Spectrum community. We are constantly discussing implementation details and answering questions. :)

Table of Contents

  • Installation
  • Usage
    • Simple Usage
    • Advanced Usage
  • Duration, Easing, Transition Properties
  • Lifecycle
  • Easing Options
  • API

Installation

bash
$ yarn add react-show
# or
$ npm install --save react-show

Usage

Simple Usage

You can create a simple expander component with the Animate component!

javascript
import { Animate } from "react-show";

const SimpleExample = () => (
  
    Hello world!
  
);

Advanced Usage

You can create a simple expander component with the Animate component!

…

Duration, Easing, Transition Properties

You can configure duration, easing, and transition by:

  • Setting a component-wide default with the duration, easing, and transitionProperty props.
  • Optionally using a lifecycle specific style property like transitionDuration, transitionTimingFunction, transitionProperty or even transitionDelay.

ReactShow comes with a wide variety of easings built-in! See Easing Options for a full list.

javascript
import { Animate } from "react-show";

const DurationAndEasingExample = () => (
  
    Hello world!
  
);

Lifecycle

React-Show uses the following lifecycle to determine which styles to show:

When show === true

  • If component is not mounted
    • If transitionOnMount === true
      • The start styles are set as the initial style
    • If transitionOnMount === false
      • The enter styles are set as the initial style
    • The component is mounted
  • If component is already mounted
    • The enter styles are set as the initial style
  • If a width or height style is/was set to auto
    • The display: block and overflow: hidden styles are temporarily applied
    • The component scrollWidth/scrollHeight is measured
    • The display: block and overflow: hidden styles are removed
  • The enter styles are applied and component waits until all transitions complete
  • All lifecycle styles are removed and component waits until all transitions complete
  • The onFinish prop function is fired

When show === false

  • If a width or height style is/was set to auto
    • The display: block and overflow: hidden styles are temporarily applied
    • The component scrollWidth/scrollHeight is measured
    • The display: block and overflow: hidden styles are removed
  • The leave or start styles are applied and component waits until all transitions complete
  • If stayMounted === false
    • The component is unmounted

Easing Options

React-Show comes packaged with some awesome easings that are accessible via Animate.easings. They are extremely simple to use too:

javascript
import { Animate } from "react-show";

const SimpleExample = () => (
  
    Hello world!
  
);

Below is a full list of the available easings exported at Animate.easings

…

API

``

Props
Prop Required Default Value Description
show true false Determines whether to "show" the content or not.
duration 300 The transition-duration of the transition used to show the content
easing easeOutQuint The transition-timing-function used to show the content
transitionProperty all The transition-property used to show the content
preMount false If true, element will mount on first render if show === false
stayMounted false If true, element will stay mounted when show === false
transitionOnMount false If true, element will animate from the start style on mount
style undefined React style object (See lifecycle for more details)
start undefined React style object (See lifecycle for more details)
enter undefined React style object (See lifecycle for more details)
leave undefined React style object (See lifecycle for more details)
component div Use a (or custom) component as the wrapper instead of a
onFinish noop Function called when the component finishes transitioning.
onMount noop Function called when the children passed to Animate are mounted.
onWillUnmount noop Function called right before the children passed to Animate are unmounted.

Contributing

We are always looking for people to help us grow react-show's capabilities and examples. If you have an issue, feature request, or pull request, let us know!

License

React Show uses the MIT license. For more information on this license, click here.

Issues· 19 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言