A package containing a few micro-interactions you can use to reward your users for little things and make them smile!
翻译准备中
开发工具GitHub @thedevelobear自行安装运营者未确认
试用过了吗? 点一下就好,无需登录。
尚未收集仓库信息。
尚未检测到更新。GitHub 发布版本后会显示在这里。
制作者的介绍仅有上面的一句话。 更多详情请阅读仓库 README。 仓库 README ↗
正在加载完整 README。
查看完整 README ↗:sparkles: GPU-rendered: WebGL2, with a Canvas 2D fallback
:evergreen_tree: Tree-shakeable: about 7 kB gzipped for useReward and confetti
:female_detective: Built with TypeScript
:stopwatch: Frame-rate independent, and quiet for people who prefer reduced motion
React-rewards lets you add micro-interactions to your app, and rewards users with the rain of confetti, emoji, balloons or fireworks in seconds. Firing confetti all over the page may seem like a questionable idea, but keep in mind that rewarding users for their actions is not. If a huge cloud of smiling emoji doesn't fit your application well, try changing the physics config to make it more subtle.
You can read more on the subject of micro-interactions in my blog post - https://www.thedevelobear.com/post/microinteractions/
thedevelobear.github.io/react-rewards has every effect live, with its settings and the code for what you pick, and the docs:
useReward: its settings, burst options and return valuefire: effects without ReactsetRendererdefineEffectpnpm add react-rewards
# or
npm install react-rewards
# or
yarn add react-rewards
React 18 or later. The package is ESM only.
Give useReward a ref to the element a reward starts from, and an effect. Each call to reward() fires a burst from the centre of that element.
import { useRef } from 'react';
import { confetti, useReward } from 'react-rewards';
export const RewardButton = () => {
const ref = useRef<HTMLButtonElement>(null);
const { reward, isAnimating } = useReward(ref, confetti);
return (
<button ref={ref} type="button" onClick={() => reward()}>
{isAnimating ? 'Yay!' : 'Reward me'}
</button>
);
};
The effects are confetti, emoji, balloon and firework, and each has its settings on its page of the docs.
The repo uses pnpm, and records its decisions in docs/. Start with AGENTS.md for the commands.
MIT