diff --git a/content/docs/components/aurora-text.mdx b/content/docs/components/aurora-text.mdx index 2dd95024f..452a61977 100644 --- a/content/docs/components/aurora-text.mdx +++ b/content/docs/components/aurora-text.mdx @@ -32,6 +32,50 @@ npx shadcn@latest add "https://magicui.design/r/aurora-text" +Update the import paths to match your project setup. + +Update `tailwind.config.js` + +Add the following animations to your `tailwind.config.js` file: + +```js title="tailwind.config.js" {5-32} +/** @type {import('tailwindcss').Config} */ +module.exports = { + theme: { + extend: { + keyframes: { + "aurora-border": { + "0%, 100%": { borderRadius: "37% 29% 27% 27% / 28% 25% 41% 37%" }, + "25%": { borderRadius: "47% 29% 39% 49% / 61% 19% 66% 26%" }, + "50%": { borderRadius: "57% 23% 47% 72% / 63% 17% 66% 33%" }, + "75%": { borderRadius: "28% 49% 29% 100% / 93% 20% 64% 25%" }, + }, + "aurora-1": { + "0%, 100%": { top: "0", right: "0" }, + "50%": { top: "50%", right: "25%" }, + "75%": { top: "25%", right: "50%" }, + }, + "aurora-2": { + "0%, 100%": { top: "0", left: "0" }, + "60%": { top: "75%", left: "25%" }, + "85%": { top: "50%", left: "50%" }, + }, + "aurora-3": { + "0%, 100%": { bottom: "0", left: "0" }, + "40%": { bottom: "50%", left: "25%" }, + "65%": { bottom: "25%", left: "50%" }, + }, + "aurora-4": { + "0%, 100%": { bottom: "0", right: "0" }, + "50%": { bottom: "25%", right: "40%" }, + "90%": { bottom: "50%", right: "25%" }, + }, + }, + }, + }, +}; +``` + @@ -40,7 +84,8 @@ npx shadcn@latest add "https://magicui.design/r/aurora-text" ## Props -| Prop | Type | Default | Description | -| ----------- | ----------- | ------- | --------------------------------------------- | -| `className` | `string` | `-` | The class name to be applied to the component | -| `children` | `ReactNode` | `-` | Children elements | +| Prop | Type | Default | Description | +| ----------- | ------------------- | ------- | --------------------------------------------- | +| `className` | `string` | `-` | The class name to be applied to the component | +| `children` | `ReactNode` | `-` | Children elements | +| `as` | `React.ElementType` | `"div"` | The element type to render as | diff --git a/public/r/index.json b/public/r/index.json index e66ee5036..7a4ae1404 100644 --- a/public/r/index.json +++ b/public/r/index.json @@ -46,7 +46,87 @@ "path": "magicui/aurora-text.tsx", "type": "registry:ui" } - ] + ], + "tailwind": { + "config": { + "theme": { + "extend": { + "keyframes": { + "aurora-border": { + "0%, 100%": { + "borderRadius": "37% 29% 27% 27% / 28% 25% 41% 37%" + }, + "25%": { + "borderRadius": "47% 29% 39% 49% / 61% 19% 66% 26%" + }, + "50%": { + "borderRadius": "57% 23% 47% 72% / 63% 17% 66% 33%" + }, + "75%": { + "borderRadius": "28% 49% 29% 100% / 93% 20% 64% 25%" + } + }, + "aurora-1": { + "0%, 100%": { + "top": "0", + "right": "0" + }, + "50%": { + "top": "50%", + "right": "25%" + }, + "75%": { + "top": "25%", + "right": "50%" + } + }, + "aurora-2": { + "0%, 100%": { + "top": "0", + "left": "0" + }, + "60%": { + "top": "75%", + "left": "25%" + }, + "85%": { + "top": "50%", + "left": "50%" + } + }, + "aurora-3": { + "0%, 100%": { + "bottom": "0", + "left": "0" + }, + "40%": { + "bottom": "50%", + "left": "25%" + }, + "65%": { + "bottom": "25%", + "left": "50%" + } + }, + "aurora-4": { + "0%, 100%": { + "bottom": "0", + "right": "0" + }, + "50%": { + "bottom": "25%", + "right": "40%" + }, + "90%": { + "bottom": "50%", + "right": "25%" + } + } + } + } + } + } + } }, { "name": "morphing-text", diff --git a/public/r/styles/default/aurora-text.json b/public/r/styles/default/aurora-text.json index 5db15620d..55db6abe4 100644 --- a/public/r/styles/default/aurora-text.json +++ b/public/r/styles/default/aurora-text.json @@ -7,9 +7,89 @@ "files": [ { "path": "magicui/aurora-text.tsx", - "content": "import React from \"react\";\nimport { cn } from \"@/lib/utils\";\n\ninterface AuroraTextProps {\n className?: string;\n children: React.ReactNode;\n}\n\nexport function AuroraText({ className, children }: AuroraTextProps) {\n return (\n \n {children}\n
\n {[...Array(5)].map((_, i) => (\n \n ))}\n
\n \n
\n );\n}\n\nfunction getInitialPosition(index: number): React.CSSProperties {\n const positions = [\n { top: \"-50%\" },\n { right: 0, top: 0 },\n { left: 0, bottom: 0 },\n { right: 0, bottom: \"-50%\" },\n ];\n return positions[index] || {};\n}\n", + "content": "import { cn } from \"@/lib/utils\";\nimport { motion, MotionProps } from \"motion/react\";\nimport React from \"react\";\n\ninterface AuroraTextProps\n extends Omit, keyof MotionProps> {\n className?: string;\n children: React.ReactNode;\n as?: React.ElementType;\n}\n\nexport function AuroraText({\n className,\n children,\n as: Component = \"div\",\n ...props\n}: AuroraTextProps) {\n const MotionComponent = motion.create(Component);\n\n return (\n \n {children}\n
\n
\n
\n
\n
\n
\n \n );\n}\n", "type": "registry:ui", "target": "" } - ] + ], + "tailwind": { + "config": { + "theme": { + "extend": { + "keyframes": { + "aurora-border": { + "0%, 100%": { + "borderRadius": "37% 29% 27% 27% / 28% 25% 41% 37%" + }, + "25%": { + "borderRadius": "47% 29% 39% 49% / 61% 19% 66% 26%" + }, + "50%": { + "borderRadius": "57% 23% 47% 72% / 63% 17% 66% 33%" + }, + "75%": { + "borderRadius": "28% 49% 29% 100% / 93% 20% 64% 25%" + } + }, + "aurora-1": { + "0%, 100%": { + "top": "0", + "right": "0" + }, + "50%": { + "top": "50%", + "right": "25%" + }, + "75%": { + "top": "25%", + "right": "50%" + } + }, + "aurora-2": { + "0%, 100%": { + "top": "0", + "left": "0" + }, + "60%": { + "top": "75%", + "left": "25%" + }, + "85%": { + "top": "50%", + "left": "50%" + } + }, + "aurora-3": { + "0%, 100%": { + "bottom": "0", + "left": "0" + }, + "40%": { + "bottom": "50%", + "left": "25%" + }, + "65%": { + "bottom": "25%", + "left": "50%" + } + }, + "aurora-4": { + "0%, 100%": { + "bottom": "0", + "right": "0" + }, + "50%": { + "bottom": "25%", + "right": "40%" + }, + "90%": { + "bottom": "50%", + "right": "25%" + } + } + } + } + } + } + } } \ No newline at end of file diff --git a/registry/default/example/aurora-text-demo.tsx b/registry/default/example/aurora-text-demo.tsx index 6d49cbf81..08305036a 100644 --- a/registry/default/example/aurora-text-demo.tsx +++ b/registry/default/example/aurora-text-demo.tsx @@ -2,7 +2,7 @@ import { AuroraText } from "@/registry/default/magicui/aurora-text"; export default function AuroraTextDemo() { return ( -

+

Ship beautiful

); diff --git a/registry/default/magicui/aurora-text.tsx b/registry/default/magicui/aurora-text.tsx index ac9f2006d..2e9dd49af 100644 --- a/registry/default/magicui/aurora-text.tsx +++ b/registry/default/magicui/aurora-text.tsx @@ -1,14 +1,24 @@ import { cn } from "@/lib/utils"; +import { motion, MotionProps } from "motion/react"; import React from "react"; -interface AuroraTextProps extends React.HTMLAttributes { +interface AuroraTextProps + extends Omit, keyof MotionProps> { className?: string; children: React.ReactNode; + as?: React.ElementType; } -export function AuroraText({ className, children, ...props }: AuroraTextProps) { +export function AuroraText({ + className, + children, + as: Component = "div", + ...props +}: AuroraTextProps) { + const MotionComponent = motion.create(Component); + return ( - @@ -19,6 +29,6 @@ export function AuroraText({ className, children, ...props }: AuroraTextProps) {
-
+ ); } diff --git a/registry/registry-ui.ts b/registry/registry-ui.ts index 07bb57590..94f1ccb77 100644 --- a/registry/registry-ui.ts +++ b/registry/registry-ui.ts @@ -23,6 +23,44 @@ export const ui: Registry = [ type: "registry:ui", dependencies: ["motion"], files: ["magicui/aurora-text.tsx"], + tailwind: { + config: { + theme: { + extend: { + keyframes: { + "aurora-border": { + "0%, 100%": { + borderRadius: "37% 29% 27% 27% / 28% 25% 41% 37%", + }, + "25%": { borderRadius: "47% 29% 39% 49% / 61% 19% 66% 26%" }, + "50%": { borderRadius: "57% 23% 47% 72% / 63% 17% 66% 33%" }, + "75%": { borderRadius: "28% 49% 29% 100% / 93% 20% 64% 25%" }, + }, + "aurora-1": { + "0%, 100%": { top: "0", right: "0" }, + "50%": { top: "50%", right: "25%" }, + "75%": { top: "25%", right: "50%" }, + }, + "aurora-2": { + "0%, 100%": { top: "0", left: "0" }, + "60%": { top: "75%", left: "25%" }, + "85%": { top: "50%", left: "50%" }, + }, + "aurora-3": { + "0%, 100%": { bottom: "0", left: "0" }, + "40%": { bottom: "50%", left: "25%" }, + "65%": { bottom: "25%", left: "50%" }, + }, + "aurora-4": { + "0%, 100%": { bottom: "0", right: "0" }, + "50%": { bottom: "25%", right: "40%" }, + "90%": { bottom: "50%", right: "25%" }, + }, + }, + }, + }, + }, + }, }, { name: "morphing-text", diff --git a/tailwind.config.cjs b/tailwind.config.cjs index e1a377cdb..760760b14 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.cjs @@ -86,11 +86,6 @@ module.exports = { shine: "shine var(--duration) infinite linear", pulse: "pulse var(--duration) ease-out infinite", rainbow: "rainbow var(--speed, 2s) infinite linear", - "aurora-border": "aurora-border 6s ease-in-out infinite", - "aurora-1": "aurora-1 12s ease-in-out infinite alternate", - "aurora-2": "aurora-2 12s ease-in-out infinite alternate", - "aurora-3": "aurora-3 12s ease-in-out infinite alternate", - "aurora-4": "aurora-4 12s ease-in-out infinite alternate", }, keyframes: { "accordion-down": {