Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

✨ feat: Add retro grid

Dillion Verma9e597370b893
diff --git a/content/components/retro-grid.mdx b/content/components/retro-grid.mdx
index 61660cf9..ba3cce5c 100644
--- a/content/components/retro-grid.mdx
+++ b/content/components/retro-grid.mdx
@@ -1,9 +1,9 @@
---
title: Retro Grid
-date: 2023-11-17
+date: 2023-11-23
summary: An animated scrolling retro grid effect
author: dillionverma
-published: false
+published: true
video: https://cdn.magicui.design/retro-grid.mp4
---
@@ -13,6 +13,47 @@ video: https://cdn.magicui.design/retro-grid.mp4
<Step>
+## Prerequisites
+
+```bash
+npm install -D tailwindcss clsx tailwind-merge
+```
+
+Copy and paste the following code into your project.
+
+```typescript
+// lib/utils.ts
+import clsx, { ClassValue } from "clsx";
+import { twMerge } from "tailwind-merge";
+
+export function cn(...inputs: ClassValue[]) {
+ return twMerge(clsx(inputs));
+}
+```
+
+```js
+// tailwind.config.js
+module.exports = {
+ theme: {
+ extend: {
+ animation: {
+ grid: "grid 15s linear infinite",
+ },
+ keyframes: {
+ grid: {
+ "0%": { transform: "translateY(-50%)" },
+ "100%": { transform: "translateY(0)" },
+ },
+ },
+ },
+ },
+};
+```
+
+</Step>
+
+<Step>
+
## Installation
Copy and paste the following code into your project.
@@ -29,6 +70,6 @@ components/magicui/retro-grid.tsx
## Props
-| Prop | Type | Description | Default |
-| ----- | ---- | --------------------- | ------- |
-| value | int | The value to count to | 0 |
+| Prop | Type | Description | Default |
+| --------- | ------ | -------------------------------- | ------- |
+| className | string | The class name for the component | "" |
diff --git a/registry/components/magicui/retro-grid.tsx b/registry/components/magicui/retro-grid.tsx
index 452410db..03262c98 100644
--- a/registry/components/magicui/retro-grid.tsx
+++ b/registry/components/magicui/retro-grid.tsx
@@ -2,8 +2,6 @@ import { cn } from "@/lib/utils";
const RetroGrid = ({ className }: { className?: string }) => {
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: "60px 60px",
backgroundRepeat: "repeat",
transformOrigin: "100% 0 0",
@@ -16,17 +14,28 @@ const RetroGrid = ({ className }: { className?: string }) => {
return (
<div
className={cn(
- "absolute h-full w-full overflow-hidden [perspective:600px]",
+ "absolute h-full w-full overflow-hidden [perspective:400px]",
className,
)}
>
{/* Grid */}
- <div className="absolute inset-0 [transform:rotateX(65deg)]">
- <div className="animate-grid" style={gridLinesStyle} />
+ <div className="absolute inset-0 [transform:rotateX(55deg)]">
+ <div
+ className={cn(
+ "animate-grid",
+
+ // Light Styles
+ "[background-image:linear-gradient(to_right,rgba(0,0,0,0.2)_1px,transparent_0),linear-gradient(to_bottom,rgba(0,0,0,0.2)_1px,transparent_0)]",
+
+ // Dark styles
+ "dark:[background-image:linear-gradient(to_right,rgba(255,255,255,0.2)_1px,transparent_0),linear-gradient(to_bottom,rgba(255,255,255,0.2)_1px,transparent_0)]",
+ )}
+ style={gridLinesStyle}
+ />
</div>
{/* Background Gradient */}
- <div className="absolute inset-0 bg-gradient-to-b from-black to-transparent" />
+ <div className="absolute inset-0 bg-gradient-to-b from-white to-transparent dark:from-black" />
</div>
);
};