info-card
karrix/info-cardFreeBlock
Information cards can serve as callout cards, banners, toast notifications, or announcement boxes to deliver news, updates, and alerts to your users.
Live preview
live · rendered by the registry
Rendered by karrix on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://karrix.dev/r/info-card.jsonSource
1"use client";23import {4 useState,5 useRef,6 useEffect,7 createContext,8 useContext,9 useMemo,10 useCallback,11} from "react";12import { motion, AnimatePresence } from "motion/react";13import { cn } from "@/lib/utils";14import React from "react";1516interface InfoCardTitleProps extends React.HTMLAttributes<HTMLDivElement> {17 children: React.ReactNode;18}1920interface InfoCardDescriptionProps21 extends React.HTMLAttributes<HTMLDivElement> {22 children: React.ReactNode;23}2425const InfoCardTitle = React.memo(26 ({ children, className, ...props }: InfoCardTitleProps) => {27 return (28 <div className={cn("font-medium mb-1", className)} {...props}>29 {children}30 </div>31 );32 }33);34InfoCardTitle.displayName = "InfoCardTitle";3536const InfoCardDescription = React.memo(37 ({ children, className, ...props }: InfoCardDescriptionProps) => {38 return (39 <div40 className={cn("text-muted-foreground leading-4", className)}41 {...props}42 >43 {children}44 </div>45 );46 }47);48InfoCardDescription.displayName = "InfoCardDescription";4950interface CommonCardProps extends React.HTMLAttributes<HTMLDivElement> {51 children: React.ReactNode;52}5354interface InfoCardProps extends React.HTMLAttributes<HTMLDivElement> {55 children: React.ReactNode;56 storageKey?: string;57 dismissType?: "once" | "forever";58}5960type InfoCardContentProps = CommonCardProps;61type InfoCardFooterProps = CommonCardProps;62type InfoCardDismissProps = React.HTMLAttributes<HTMLDivElement> & {63 children: React.ReactNode;64 onDismiss?: () => void;65};66type InfoCardActionProps = CommonCardProps;6768const InfoCardContent = React.memo(69 ({ children, className, ...props }: InfoCardContentProps) => {70 return (71 <div className={cn("flex flex-col gap-1 text-xs", className)} {...props}>72 {children}73 </div>74 );75 }76);77InfoCardContent.displayName = "InfoCardContent";7879interface MediaItem {80 type?: "image" | "video";81 src: string;82 alt?: string;83 className?: string;84 [key: string]: any;85}8687interface InfoCardMediaProps extends React.HTMLAttributes<HTMLDivElement> {88 media: MediaItem[];89 loading?: "eager" | "lazy";90 shrinkHeight?: number;91 expandHeight?: number;92}9394const InfoCardImageContext = createContext<{95 handleMediaLoad: (mediaSrc: string) => void;96 setAllImagesLoaded: (loaded: boolean) => void;97}>({98 handleMediaLoad: () => {},99 setAllImagesLoaded: () => {},100});101102const InfoCardContext = createContext<{103 isHovered: boolean;104// … truncated
What it pulls in
npm packages
Files it writes
More from karrix
All 4 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| unsave-popupunsave-popup | karrix | Blocks | Free | 1 dep |
