UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
✨ feat: add a few more components
Dillion Vermac7f2261a3343
diff --git a/content/components/number-ticker.mdx b/content/components/number-ticker.mdxnew file mode 100644index 00000000..a37a6d4f--- /dev/null+++ b/content/components/number-ticker.mdx@@ -0,0 +1,35 @@+---+title: Number Ticker+date: 2023-11-18+summary: Animate numbers to count up or down to a target number+author: dillionverma+published: true+video: https://cdn.magicui.design/number-ticker.mp4+---++<ComponentPreview name="number-ticker-demo" />++<Steps>++<Step>++## Installation++Copy and paste the following code into your project.++```text+components/magicui/number-ticker.tsx+```++<ComponentSource name="number-ticker" />++</Step>++</Steps>++## Props++| Prop | Type | Description | Default |+| --------- | ---------- | ------------------------- | ------- |+| value | int | The value to count to | 0 |+| direction | up \| down | The direction to count in | up |diff --git a/content/components/retro-grid.mdx b/content/components/retro-grid.mdxnew file mode 100644index 00000000..61660cf9--- /dev/null+++ b/content/components/retro-grid.mdx@@ -0,0 +1,34 @@+---+title: Retro Grid+date: 2023-11-17+summary: An animated scrolling retro grid effect+author: dillionverma+published: false+video: https://cdn.magicui.design/retro-grid.mp4+---++<ComponentPreview name="retro-grid-demo" />++<Steps>++<Step>++## Installation++Copy and paste the following code into your project.++```text+components/magicui/retro-grid.tsx+```++<ComponentSource name="retro-grid" />++</Step>++</Steps>++## Props++| Prop | Type | Description | Default |+| ----- | ---- | --------------------- | ------- |+| value | int | The value to count to | 0 |diff --git a/content/components/ripple.mdx b/content/components/ripple.mdxnew file mode 100644index 00000000..f2777f42--- /dev/null+++ b/content/components/ripple.mdx@@ -0,0 +1,28 @@+---+title: Ripple+date: 2023-11-18+summary: An animated ripple effect typically used behind elements to emphasize them.+author: dillionverma+published: true+video: https://cdn.magicui.design/ripple.mp4+---++<ComponentPreview name="ripple-demo" />++<Steps>++<Step>++## Installation++Copy and paste the following code into your project.++```text+components/magicui/ripple.tsx+```++<ComponentSource name="ripple" />++</Step>++</Steps>diff --git a/registry/components/example/number-ticker-demo.tsx b/registry/components/example/number-ticker-demo.tsxnew file mode 100644index 00000000..c6101e3d--- /dev/null+++ b/registry/components/example/number-ticker-demo.tsx@@ -0,0 +1,11 @@+import NumberTicker from "@/registry/components/magicui/number-ticker";++const NumberTickerDemo = () => {+ return (+ <p className="whitespace-pre-wrap text-8xl font-medium tracking-tighter text-black dark:text-white">+ <NumberTicker value={100} />+ </p>+ );+};++export default NumberTickerDemo;diff --git a/registry/components/example/retro-grid-demo.tsx b/registry/components/example/retro-grid-demo.tsxnew file mode 100644index 00000000..449d2fa6--- /dev/null+++ b/registry/components/example/retro-grid-demo.tsx@@ -0,0 +1,17 @@+"use client";++import RetroGrid from "@/registry/components/magicui/retro-grid";++const RippleDemo = () => {+ return (+ <div className="relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg border bg-background p-20 shadow-2xl">+ <span className="pointer-events-none z-10 whitespace-pre-wrap bg-gradient-to-b from-[#ffd319] via-[#ff2975] to-[#8c1eff] bg-clip-text text-center text-7xl font-bold leading-none tracking-tighter text-transparent">+ Retro Grid+ </span>++ <RetroGrid />+ </div>+ );+};++export default RippleDemo;diff --git a/registry/components/example/ripple-demo.tsx b/registry/components/example/ripple-demo.tsxnew file mode 100644index 00000000..c6e46566--- /dev/null+++ b/registry/components/example/ripple-demo.tsx@@ -0,0 +1,14 @@+import Ripple from "@/registry/components/magicui/ripple";++const RippleDemo = () => {+ return (+ <div className="relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg border bg-background p-20 shadow-2xl">+ <p className="z-10 whitespace-pre-wrap text-center text-5xl font-medium tracking-tighter text-white">+ Ripple+ </p>+ <Ripple />+ </div>+ );+};++export default RippleDemo;diff --git a/registry/components/magicui/number-ticker.tsx b/registry/components/magicui/number-ticker.tsxnew file mode 100644index 00000000..1fa17cf0--- /dev/null+++ b/registry/components/magicui/number-ticker.tsx@@ -0,0 +1,40 @@+"use client";++import { useInView, useMotionValue, useSpring } from "framer-motion";+import { useEffect, useRef } from "react";++export default function NumberTicker({+ value,+ direction = "up",+}: {+ value: number;+ direction?: "up" | "down";+}) {+ const ref = useRef<HTMLSpanElement>(null);+ const motionValue = useMotionValue(direction === "down" ? value : 0);+ const springValue = useSpring(motionValue, {+ damping: 60,+ stiffness: 100,+ });+ const isInView = useInView(ref, { once: true, margin: "-100px" });++ useEffect(() => {+ if (isInView) {+ motionValue.set(direction === "down" ? 0 : value);+ }+ }, [motionValue, isInView]);++ useEffect(+ () =>+ springValue.on("change", (latest) => {+ if (ref.current) {+ ref.current.textContent = Intl.NumberFormat("en-US").format(+ latest.toFixed(0),+ );+ }+ }),+ [springValue],+ );++ return <span ref={ref} />;+}diff --git a/registry/components/magicui/retro-grid.tsx b/registry/components/magicui/retro-grid.tsxindex 32cb565f..452410db 100644--- a/registry/components/magicui/retro-grid.tsx+++ b/registry/components/magicui/retro-grid.tsx@@ -1,41 +1,32 @@-"use client";-import { cn } from "@/lib/utils";const RetroGrid = ({ className }: { className?: string }) => {- const gridStyle = {- width: "100%",- height: "600px",- overflow: "hidden",- zIndex: 10,- perspective: "450px",- };-- // const gridFadeStyle = {- // width: "100%",- // height: "100%",- // // position: "absolute",- // zIndex: 11,- // background:- // "radial-gradient(circle at 50% 50%, rgba(120,119,198,0.3) 0%, rgba(0, 0, 0, 0.6) 80%)",- // };-const gridLinesStyle = {backgroundImage:"linear-gradient(to right, rgba(255, 255, 255, 0.3) 1px, transparent 0), linear-gradient(to bottom, rgba(255, 255, 255, 0.3) 1px, transparent 0)",- backgroundSize: "40px 40px",+ backgroundSize: "60px 60px",backgroundRepeat: "repeat",transformOrigin: "100% 0 0",+ inset: "-100% 0px",+ width: "200vw",+ height: "100vh",+ marginLeft: "-50%",};return (- <div className={cn("overflow-hidden", className)}>- <div style={gridStyle}>- <div- className="h-screen w-screen animate-grid"- style={gridLinesStyle}- />+ <div+ className={cn(+ "absolute h-full w-full overflow-hidden [perspective:600px]",+ className,+ )}+ >+ {/* Grid */}+ <div className="absolute inset-0 [transform:rotateX(65deg)]">+ <div className="animate-grid" style={gridLinesStyle} /></div>++ {/* Background Gradient */}+ <div className="absolute inset-0 bg-gradient-to-b from-black to-transparent" /></div>);};diff --git a/registry/components/magicui/ripple.tsx b/registry/components/magicui/ripple.tsxnew file mode 100644index 00000000..59efc867--- /dev/null+++ b/registry/components/magicui/ripple.tsx@@ -0,0 +1,29 @@+import React, { CSSProperties } from "react";++// Modify these+const MAIN_CIRCLE_SIZE = 210;+const MAIN_CIRCLE_OPACITY = 0.24;+const NUM_CIRCLES = 8;++const Ripple = React.memo(() => {+ return (+ <div className="absolute left-1/2 top-1/2 h-full w-full overflow-visible">+ {Array.from({ length: NUM_CIRCLES }, (_, i) => (+ <div+ key={i}+ className={`absolute -translate-x-1/2 -translate-y-1/2 animate-ripple rounded-full bg-black transition-opacity ease-in-out dark:bg-white`}+ style={+ {+ width: MAIN_CIRCLE_SIZE + i * 70,+ height: MAIN_CIRCLE_SIZE + i * 70,+ opacity: MAIN_CIRCLE_OPACITY - i * 0.03,+ animationDelay: `${i * 0.06}s`,+ } as CSSProperties+ }+ ></div>+ ))}+ </div>+ );+});++export default Ripple;diff --git a/registry/index.tsx b/registry/index.tsxindex bce4f621..fac47346 100644--- a/registry/index.tsx+++ b/registry/index.tsx@@ -72,6 +72,21 @@ const ui: Registry = {type: "components:ui",files: ["registry/components/magicui/particles.tsx"],},+ "number-ticker": {+ name: "number-ticker",+ type: "components:ui",+ files: ["registry/components/magicui/number-ticker.tsx"],+ },+ ripple: {+ name: "ripple",+ type: "components:ui",+ files: ["registry/components/magicui/ripple.tsx"],+ },+ "retro-grid": {+ name: "retro-grid",+ type: "components:ui",+ files: ["registry/components/magicui/retro-grid.tsx"],+ },};const example: Registry = {@@ -228,6 +243,30 @@ const example: Registry = {() => import("@/registry/components/example/bento-demo-vertical"),),},+ "number-ticker-demo": {+ name: "number-ticker-demo",+ type: "components:example",+ files: ["registry/components/example/number-ticker-demo.tsx"],+ component: React.lazy(+ () => import("@/registry/components/example/number-ticker-demo"),+ ),+ },+ "ripple-demo": {+ name: "ripple-demo",+ type: "components:example",+ files: ["registry/components/example/ripple-demo.tsx"],+ component: React.lazy(+ () => import("@/registry/components/example/ripple-demo"),+ ),+ },+ "retro-grid-demo": {+ name: "retro-grid-demo",+ type: "components:example",+ files: ["registry/components/example/retro-grid-demo.tsx"],+ component: React.lazy(+ () => import("@/registry/components/example/retro-grid-demo"),+ ),+ },};export const registry: Registry = {diff --git a/tailwind.config.ts b/tailwind.config.tsindex 47b4dca3..8aa2f7af 100644--- a/tailwind.config.ts+++ b/tailwind.config.ts@@ -70,6 +70,7 @@ module.exports = {rotate: "rotate var(--spark) linear infinite both",spin: "spin calc(var(--speed) * 2) infinite linear",slide: "slide var(--speed) ease-in-out infinite alternate",+ ripple: "ripple 3400ms ease infinite",},keyframes: {"accordion-down": {@@ -94,10 +95,9 @@ module.exports = {},},grid: {- "0%": { transform: "rotateX(45deg) translateY(-50%)" },- "100%": { transform: "rotateX(45deg) translateY(0)" },+ "0%": { transform: "translateY(-50%)" },+ "100%": { transform: "translateY(0)" },},-marquee: {from: { transform: "translateX(0)" },to: { transform: "translateX(calc(-50% - var(--gap)/2))" },@@ -124,6 +124,14 @@ module.exports = {transform: "translateZ(0) rotate(360deg)",},},+ ripple: {+ "0%, 100%": {+ transform: "translate(-50%, -50%) scale(1)",+ },+ "50%": {+ transform: "translate(-50%, -50%) scale(0.9)",+ },+ },slide: {to: {transform: "translate(calc(100cqw - 100%), 0)",