Projected Shadow Animation
ericts-ui/projected-shadow-animationFreeComponent
A CSS-powered primitive that layers an element with projected and contact shadows, then gathers them on hover or active state.
Live preview
live · rendered by the registry
Rendered by ericts-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.ericts.com/r/projected-shadow-animation.jsonSource
1import * as React from "react";23import { cn } from "@/lib/utils";45import "./projected-shadow-animation.css";67type ProjectedShadowTimingValue = number | string;8type ProjectedShadowLengthValue = number | string;9type CssVariableStyle = React.CSSProperties & Record<`--${string}`, string>;1011export type ProjectedShadowOffset = {12 /** Horizontal offset. Numeric values are converted to px. */13 x?: ProjectedShadowLengthValue;14 /** Vertical offset. Numeric values are converted to px. */15 y?: ProjectedShadowLengthValue;16};1718export type ProjectedShadowProps = React.ComponentPropsWithoutRef<"span"> & {19 /** Keep the gathered state active without requiring hover. */20 active?: boolean;21 /** Animation duration for release. Numeric values are converted to ms. */22 duration?: ProjectedShadowTimingValue;23 /** Animation duration for gather. Numeric values are converted to ms. */24 activeDuration?: ProjectedShadowTimingValue;25 /** CSS easing used by the transform and opacity transitions. */26 ease?: string;27 /** Blur radius for the far projected shadow. Numeric values are converted to px. */28 projectedShadowBlur?: ProjectedShadowLengthValue;29 /** Resting offset for the far projected shadow. */30 projectedShadowOffset?: ProjectedShadowOffset;31 /** Optional decorative content for the shadow layers. Defaults to children. */32 shadow?: React.ReactNode;33 /** Classes applied to the visible animated child wrapper. */34 targetClassName?: string;35 /** Classes applied to the far projected shadow layer. */36 projectedShadowClassName?: string;37 /** Classes applied to the close contact shadow layer. */38 contactShadowClassName?: string;39 /** Hide the far projected shadow layer. */40 showProjectedShadow?: boolean;41 /** Hide the close contact shadow layer. */42 showContactShadow?: boolean;43};4445export function ProjectedShadow({46 active,47 activeDuration,48 children,49 className,50 contactShadowClassName,51 duration,52 ease,53 projectedShadowClassName,54 projectedShadowBlur,55 projectedShadowOffset,56 shadow,57 showContactShadow = true,58 showProjectedShadow = true,59 style,60 targetClassName,61 ...props62}: ProjectedShadowProps) {63 const shadowContent = shadow ?? children;6465 return (66 <span67 data-slot="projected-shadow"68 data-active={active ? "true" : undefined}69 className={cn(70 "projected-shadow relative inline-flex items-center justify-center",71 className,72 )}73 style={getProjectedShadowStyle(74 {75// … truncated
Files it writes
More from ericts-ui
All 38 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Adaptive Draweradaptive-drawer | ericts-ui | Components | Free | 2 deps | |
| Check Animationcheck-animation | ericts-ui | Components | Free | no deps · 2 files | |
| Context Cursorcontext-cursor | ericts-ui | Components | Free | 1 dep | |
| Copy Buttoncopy-button | ericts-ui | Components | Free | 2 deps | |
| Expandable Dialogexpandable-modal | ericts-ui | Components | Free | 1 dep | |
| Expandable Tabsexpandable-tabs | ericts-ui | Components | Free | 1 dep | |
| Expandable Toolbarexpandable-toolbar | ericts-ui | Components | Free | 1 dep | |
| Expanding Panelexpanding-panel | ericts-ui | Components | Free | 2 deps |
