Layered Card
boldkit/layered-cardFreeComponent
Card component with stacked layers effect showing offset depth - neubrutalist depth illusion
Live preview
live · rendered by the registry
Rendered by boldkit on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://boldkit.dev/r/layered-card.jsonSource
1/* eslint-disable react-refresh/only-export-components */2import * as React from 'react'3import { cva, type VariantProps } from 'class-variance-authority'4import { cn } from '@/lib/utils'56const layeredCardVariants = cva('relative', {7 variants: {8 layers: {9 single: '',10 double: '',11 triple: '',12 },13 offset: {14 sm: '',15 default: '',16 lg: '',17 },18 layerColor: {19 default: '',20 primary: '',21 secondary: '',22 accent: '',23 muted: '',24 },25 },26 defaultVariants: {27 layers: 'double',28 offset: 'default',29 layerColor: 'default',30 },31})3233export interface LayeredCardProps34 extends React.HTMLAttributes<HTMLDivElement>,35 VariantProps<typeof layeredCardVariants> {36 /** Make the card interactive with hover effects */37 interactive?: boolean38}3940const LayeredCard = React.forwardRef<HTMLDivElement, LayeredCardProps>(41 ({ className, layers, offset, layerColor, interactive = false, children, ...props }, ref) => {42 // Calculate offsets based on size43 const offsetSizes = {44 sm: 6,45 default: 8,46 lg: 12,47 }48 const offsetPx = offsetSizes[offset || 'default']4950 // Get layer count51 const layerCount = layers === 'single' ? 1 : layers === 'triple' ? 3 : 25253 // Get background color class for layers54 const colorClasses = {55 default: 'bg-muted',56 primary: 'bg-primary',57 secondary: 'bg-secondary',58 accent: 'bg-accent',59 muted: 'bg-muted',60 }61 const layerBg = colorClasses[layerColor || 'default']6263 return (64 <div65 ref={ref}66 className={cn(layeredCardVariants({ layers, offset, layerColor }), className)}67 {...props}68 >69 {/* Layer 3 (furthest back) */}70 {layerCount >= 3 && (71 <div72 className={cn(73 'absolute inset-0 border-3 border-foreground',74 layerBg,75 'opacity-50'76 )}77 style={{78 transform: `translate(${offsetPx * 3}px, ${offsetPx * 3}px)`,79 }}80 />81 )}8283 {/* Layer 2 */}84 {layerCount >= 2 && (85 <div86 className={cn(87 'absolute inset-0 border-3 border-foreground',88 layerBg,89 'opacity-70'90 )}91 style={{92 transform: `translate(${offsetPx * 2}px, ${offsetPx * 2}px)`,93 }}94 />95 )}9697 {/* Layer 1 */}98 {layerCount >= 1 && (99// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from boldkit
All 94 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | boldkit | Components | Free | 2 deps | |
| Alertalert | boldkit | Components | Free | 2 deps | |
| Alert Dialogalert-dialog | boldkit | Components | Free | 1 dep | |
| ASCII Shapesascii-shapes | boldkit | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | boldkit | Components | Free | 1 dep | |
| Avataravatar | boldkit | Components | Free | 1 dep | |
| Badgebadge | boldkit | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | boldkit | Components | Free | 2 deps |
