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

cambio

> 前端框架
开源

一个简单的 React 共享动画组件

200 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个简单的 React 共享动画组件

Cambio

Cambio is a simple shared animation component for React.

Cambio simplifies shared animations in React by removing the complexity that many developers face when setting up these interactions. By eliminating boilerplate code, it streamlines both implementation and maintenance workflows.

Built on Base UI's accessible primitives and Motion's powerful animation library, Cambio ensures your animations are both performant and inclusive by default.

For the source code, check out the GitHub.

Installation

bash
pnpm add cambio

Setup

Cambio leverages Base UI's Dialog component to render popups outside of the main DOM hierarchy. To make portalled components always appear on top of the entire page, add the following style to your application layout root.

typescript
// layout.tsx

  

// styles.css
.root {
  isolation: isolate;
}

For more information, see the Base UI Documentation.

Usage

It can be used anywhere in your application as follows.

typescript
"use client";

import { Cambio } from "cambio";

export default function MyModal() {
  return (
    
      {/* Your Trigger Content */}
      
        
        
          
          
          
          {/* Your Additional Content */}
        
      
    
  );
}

For complete code examples, refer to the examples directory.

Motion

Cambio leverages the power of Motion to provide a seamless animation experience. All components are built on Motion primitives, giving you fine-grained control over animations without the complexity.

You can easily customize transitions by passing a transition prop to any component:

typescript

This eliminates the need to wrap components in `` elements while maintaining full Motion capabilities.

Presets

Cambio includes four built-in motion presets, each optimized for different interaction patterns. You can configure the motion preset globally at the root level.

snappy - 240ms ease-out animations for quick, responsive interactions

smooth - 300ms ease-in-out animations for balanced, general-purpose motion

bouncy - Spring animations with organic movement for playful interfaces

reduced - 10ms linear animations for accessibility compliance

typescript

Variants

Configure different motion presets for different components when you need granular control over the animation experience. This is useful when you want each component to have its own distinct motion characteristics:

typescript

  {/* Uses snappy motion */}
  
    
    {/* Uses smooth motion */}
    {/* Uses bouncy motion */}
  

Overrides

Override motion for individual components. Component-level motion takes the highest priority, followed by motion variants, then global motion settings:

typescript

  {/* Overrides to snappy */}
  
    
    {/* Overrides to reduced */}
    {/* Overrides to bouncy */}
  

Snappy

Fast ease-out animations (240ms) for quick, responsive interactions. Ideal for buttons, toggles, and frequent actions where immediacy is key.

typescript

Smooth

Balanced ease-in-out animations (300ms) for general-purpose motion. The default preset that works well for most modal and popup interactions.

typescript

Bouncy

Spring animations with playful overshoot for engaging, organic movement. Perfect for delightful interactions and creative interfaces.

typescript

Dismissability

Cambio supports dismissible popups, allowing users to easily close the popup by dragging. You can configure this behavior at the root level.

typescript

Advanced Configuration

Customize dismissal sensitivity:

typescript

  

Accessibility

Cambio respects user accessibility preferences, specifically the prefers-reduced-motion media query. By default, Cambio automatically detects and respects this system preference to provide a more accessible experience for users who prefer reduced motion.

typescript

Why Cambio?

Cambio offers a unique combination of simplicity, accessibility, and powerful animation capabilities that sets it apart from other libraries.

Other libraries cater mainly towards image/video zooming. Cambio is not limited to do this. It's powered by Motion and Base UI which provides a more comprehensive solution for building shared animations in React applications.

This means you can create expanded states, draggable elements, and interactions that feel natural, all while maintaining accessibility for every user.

What you can create with it, is limited only by your imagination.

Support

For any issues or feature requests, please open an issue on GitHub.

You can also reach out to me on Twitter.

Issues· 4 开放

查看全部 Issues在 GitHub 打开

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

> 标签

TypeScriptbasemotionreact

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

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架