Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-spring/core

Package Overview
Dependencies
Maintainers
1
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-spring/core

The platform-agnostic core of `react-spring`

  • 9.7.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9M
decreased by-13.2%
Maintainers
1
Weekly downloads
 
Created

What is @react-spring/core?

@react-spring/core is a library for creating animations in React applications. It provides a set of hooks and utilities to create smooth and interactive animations with ease. The library is highly flexible and can be used for a wide range of animation tasks, from simple transitions to complex gesture-based interactions.

What are @react-spring/core's main functionalities?

Basic Spring Animation

This feature allows you to create a basic spring animation. The `useSpring` hook is used to define the animation properties, and the `animated` component is used to apply these properties to a React element.

import { useSpring, animated } from '@react-spring/web';

function App() {
  const styles = useSpring({
    from: { opacity: 0 },
    to: { opacity: 1 },
  });

  return <animated.div style={styles}>I will fade in</animated.div>;
}

Gesture-based Animation

This feature allows you to create gesture-based animations. The `useDrag` hook from `@use-gesture/react` is used to handle drag gestures, and the `useSpring` hook is used to animate the position of the element based on the drag gestures.

import { useSpring, animated } from '@react-spring/web';
import { useDrag } from '@use-gesture/react';

function Draggable() {
  const [styles, api] = useSpring(() => ({ x: 0, y: 0 }));
  const bind = useDrag(({ offset: [x, y] }) => api.start({ x, y }));

  return <animated.div {...bind()} style={{ ...styles, width: 100, height: 100, background: 'lightblue' }} />;
}

Keyframe Animation

This feature allows you to create keyframe animations. The `useSpring` hook is used to define the keyframes and looping behavior of the animation.

import { useSpring, animated } from '@react-spring/web';

function KeyframeAnimation() {
  const styles = useSpring({
    loop: { reverse: true },
    from: { x: 0 },
    to: { x: 100 },
  });

  return <animated.div style={{ ...styles, width: 100, height: 100, background: 'lightcoral' }} />;
}

Other packages similar to @react-spring/core

Keywords

FAQs

Package last updated on 07 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc