Neon Gradient Card
magicui/neon-gradient-cardFreeComponent
A beautiful neon card effect
Live preview
live · rendered by the registry
Rendered by magicui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://magicui.design/r/neon-gradient-card.jsonSource
1"use client"23import {4 useEffect,5 useRef,6 useState,7 type CSSProperties,8 type ReactElement,9 type ReactNode,10} from "react"1112import { cn } from "@/lib/utils"1314interface NeonColorsProps {15 firstColor: string16 secondColor: string17}1819interface NeonGradientCardProps extends React.HTMLAttributes<HTMLDivElement> {20 /**21 * @default <div />22 * @type ReactElement23 * @description24 * The component to be rendered as the card25 * */26 as?: ReactElement27 /**28 * @default ""29 * @type string30 * @description31 * The className of the card32 */33 className?: string3435 /**36 * @default ""37 * @type ReactNode38 * @description39 * The children of the card40 * */41 children?: ReactNode4243 /**44 * @default 545 * @type number46 * @description47 * The size of the border in pixels48 * */49 borderSize?: number5051 /**52 * @default 2053 * @type number54 * @description55 * The size of the radius in pixels56 * */57 borderRadius?: number5859 /**60 * @default "{ firstColor: '#ff00aa', secondColor: '#00FFF1' }"61 * @type string62 * @description63 * The colors of the neon gradient64 * */65 neonColors?: NeonColorsProps66}6768export const NeonGradientCard: React.FC<NeonGradientCardProps> = ({69 className,70 children,71 borderSize = 2,72 borderRadius = 20,73 neonColors = {74 firstColor: "#ff00aa",75 secondColor: "#00FFF1",76 },77 ...props78}) => {79 const containerRef = useRef<HTMLDivElement>(null)80 const [dimensions, setDimensions] = useState({ width: 0, height: 0 })8182 useEffect(() => {83 const updateDimensions = () => {84 if (containerRef.current) {85 const { offsetWidth, offsetHeight } = containerRef.current86 setDimensions({ width: offsetWidth, height: offsetHeight })87 }88 }8990 updateDimensions()91 window.addEventListener("resize", updateDimensions)9293 return () => {94 window.removeEventListener("resize", updateDimensions)95 }96 }, [])9798 useEffect(() => {99 if (containerRef.current) {100 const { offsetWidth, offsetHeight } = containerRef.current101 setDimensions({ width: offsetWidth, height: offsetHeight })102 }103 }, [children])104105 return (106 <div107 ref={containerRef}108 style={109 {110 "--border-size": `${borderSize}px`,111 "--border-radius": `${borderRadius}px`,112 "--neon-first-color": neonColors.firstColor,113 "--neon-second-color": neonColors.secondColor,114 "--card-width": `${dimensions.width}px`,115// … truncated
Files it writes
More from magicui
All 247 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Androidandroid | magicui | Components | Free | no deps | |
| Animated Beamanimated-beam | magicui | Components | Free | 1 dep | |
| Animated Circular Progress Baranimated-circular-progress-bar | magicui | Components | Free | no deps | |
| Animated Gradient Textanimated-gradient-text | magicui | Components | Free | no deps | |
| Animated Grid Patternanimated-grid-pattern | magicui | Components | Free | 1 dep | |
| Animated Listanimated-list | magicui | Components | Free | 1 dep | |
| Animated Shiny Textanimated-shiny-text | magicui | Components | Free | no deps | |
| Theme Toggleranimated-theme-toggler | magicui | Components | Free | 1 dep |
