grid
eldoraui/gridFreeComponent
A grid component.
Live preview
live · rendered by the registry
Rendered by eldoraui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://eldoraui.site/r/grid.jsonSource
1"use client"23import { ReactNode, SVGProps } from "react"45import { cn } from "@/lib/utils"67interface GridProps {8 /** Number of columns in the grid */9 columns?: number10 /** Number of rows in the grid */11 rows?: number12 /** Height of the grid container */13 height?: string14 /** Width of the grid container */15 width?: string16 /** Whether to show the plus icons at corners */17 showPlusIcons?: boolean18 /** Custom className for the grid container */19 className?: string20 /** Children to render inside the grid */21 children?: ReactNode22 /** ARIA label for accessibility */23 "aria-label"?: string24}2526interface PlusIconProps extends SVGProps<SVGSVGElement> {27 className?: string28}2930/**31 * A flexible grid component with customizable columns, rows, and optional decorative plus icons.32 *33 * @param columns - Number of columns in the grid (default: 9)34 * @param rows - Number of rows in the grid (default: 2)35 * @param height - Height of the grid container (default: "h-24")36 * @param width - Width of the grid container (default: "w-full")37 * @param showPlusIcons - Whether to show decorative plus icons at corners (default: true)38 * @param className - Additional CSS classes for the grid container39 * @param children - Content to render inside the grid40 * @param aria-label - ARIA label for accessibility41 */42export function Grid({43 columns = 9,44 rows = 2,45 height = "h-24",46 width = "w-full",47 showPlusIcons = true,48 className,49 children,50 "aria-label": ariaLabel,51}: GridProps) {52 const PlusIcon = ({ className: iconClassName, ...rest }: PlusIconProps) => {53 return (54 <svg55 xmlns="http://www.w3.org/2000/svg"56 fill="none"57 viewBox="0 0 24 24"58 width={24}59 height={24}60 strokeWidth="1"61 stroke="currentColor"62 aria-hidden="true"63 {...rest}64 className={cn(65 "absolute size-6 text-black dark:text-white",66 iconClassName67 )}68 >69 <path strokeLinecap="round" strokeLinejoin="round" d="M12 6v12m6-6H6" />70 </svg>71 )72 }7374 const totalItems = columns * rows7576 // Generate grid items if no children provided77 const gridItems =78 children ||79 Array.from({ length: totalItems }, (_, i) => {80 const isLastInRow = (i + 1) % columns === 081 const isLastRow = i >= totalItems - columns8283 return (84 <span85 key={i}86 className={cn(87 "h-full w-full",88 !isLastInRow && "border-r",89// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from eldoraui
All 115 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| animated-badgeanimated-badge | eldoraui | Components | Free | 2 deps | |
| animated-frameworksanimated-frameworks | eldoraui | Components | Free | 2 deps | |
| animated-grid-patternanimated-grid-pattern | eldoraui | Components | Free | 3 deps | |
| animated-listanimated-list | eldoraui | Components | Free | 1 dep | |
| animated-shiny-buttonanimated-shiny-button | eldoraui | Components | Free | 1 dep | |
| blur-in-textblur-in-text | eldoraui | Components | Free | 3 deps | |
| browserbrowser | eldoraui | Components | Free | 2 deps | |
| card-flip-hovercard-flip-hover | eldoraui | Components | Free | 1 dep |
