UIPin
ComponentsIconsIllustrationsMotionTemplatesApps
Boards
UIPin

Free, open-source UI components, icons, illustrations, motion, templates and apps, in one search. Every item links to its source and licence.

UIPin is free. If it saved you time, you can keep it running:

Buy me a coffee
ComponentsIconsIllustrationsMotionTemplatesAppsLibrariesCompareNew this weekMCP for agentsBoardsPrivacy

Components, icons and artwork belong to their authors and are shown under their open-source licences.

Eldora UI/Grid

Other
1 of 13
Compiling

Theme it

Every preview, live

Brand colour

Corner radius

Font

Recolours shadcn’s tokens, Tailwind’s accent colours and colours set in the code. Red, amber and green classes stay, since they usually mean error, warning or success.

13 versions·5 libraries

  • Grid
  • Bg Animated Fractal Dot Grid
  • Canvas Fractal Grid
  • Tweet Grid
  • Animated Grid Pattern
  • Kokonut UI
  • Animated Grid Pattern
  • Bento Grid
  • Flickering Grid
  • Grid Pattern
  • Interactive Grid Pattern
  • Retro Grid
  • React Bits

Grid

A grid component.

npx shadcn@latest add https://eldoraui.site/r/grid.json
Open in v0 Docs Repo
Library
Eldora UI
License
MIT
Stack
React · Tailwind CSS
Size
122 lines
Demo
From Eldora UI

Code

registry/eldoraui/grid.tsx

"use client"

import { ReactNode, SVGProps } from "react"

import { cn } from "@/lib/utils"

interface GridProps {
  /** Number of columns in the grid */
  columns?: number
  /** Number of rows in the grid */
  rows?: number
  /** Height of the grid container */
  height?: string
  /** Width of the grid container */
  width?: string
  /** Whether to show the plus icons at corners */
  showPlusIcons?: boolean
  /** Custom className for the grid container */
  className?: string
  /** Children to render inside the grid */
  children?: ReactNode
  /** ARIA label for accessibility */
  "aria-label"?: string
}

interface PlusIconProps extends SVGProps<SVGSVGElement> {
  className?: string
}

/**
 * A flexible grid component with customizable columns, rows, and optional decorative plus icons.
 *
 * @param columns - Number of columns in the grid (default: 9)
 * @param rows - Number of rows in the grid (default: 2)
 * @param height - Height of the grid container (default: "h-24")
 * @param width - Width of the grid container (default: "w-full")
 * @param showPlusIcons - Whether to show decorative plus icons at corners (default: true)
 * @param className - Additional CSS classes for the grid container
 * @param children - Content to render inside the grid
 * @param aria-label - ARIA label for accessibility
 */
export function Grid({
  columns = 9,
  rows = 2,
  height = "h-24",
  width = "w-full",
  showPlusIcons = true,
  className,
  children,
  "aria-label": ariaLabel,
}: GridProps) {
  const PlusIcon = ({ className: iconClassName, ...rest }: PlusIconProps) => {
    return (
      <svg
        xmlns="http://www.w3.org/2000/svg"
        fill="none"
        viewBox="0 0 24 24"
        width={24}
        height={24}
        strokeWidth="1"
        stroke="currentColor"
        aria-hidden="true"
        {...rest}
        className={cn(
          "absolute size-6 text-black dark:text-white",
          iconClassName
        )}
      >
        <path strokeLinecap="round" strokeLinejoin="round" d="M12 6v12m6-6H6" />
      </svg>
    )
  }

  const totalItems = columns * rows

  // Generate grid items if no children provided
  const gridItems =
    children ||
    Array.from({ length: totalItems }, (_, i) => {
      const isLastInRow = (i + 1) % columns === 0
      const isLastRow = i >= totalItems - columns

      return (
        <span
          key={i}
          className={cn(
            "h-full w-full",
            !isLastInRow && "border-r",
            !isLastRow && "border-b"
          )}
        />
      )
    })

  return (
    <div
      className={cn("relative grid border", height, width, className)}
      style={{
        gridTemplateColumns: `repeat(${columns}, 1fr)`,
        gridTemplateRows: `repeat(${rows}, 1fr)`,
      }}
      role="grid"
      aria-label={ariaLabel || `Grid with ${columns} columns and ${rows} rows`}
    >
      {showPlusIcons && (
        <>
          <PlusIcon className="absolute -top-5 -left-5 h-10 w-10" />
          <PlusIcon className="absolute -right-5 -bottom-5 h-10 w-10" />
        </>
      )}
      {gridItems}
    </div>
  )
}

// Legacy component for backward compatibility
export function GridDemo() {
  return <Grid />
}

export default Grid

More like this

Input

shadcn/ui·Inputs & forms

Ai Prompt Input

SmoothUI·Inputs & forms

Marking Menu

Kokonut UI·Overlays

Textarea

shadcn/ui·Text effects

Accordion

SmoothUI·Data display

Dot Pattern

Magic UI·Backgrounds

Command

shadcn/ui·Overlays

Alert

SmoothUI·Feedback & loaders

Sidebar

shadcn/ui·Navigation

Carousel

shadcn/ui·Media & 3D

Skeleton

shadcn/ui·Feedback & loaders

Terminal

Eldora UI·Media & 3D

Progress

shadcn/ui·Feedback & loaders

Bubble Menu

React Bits·BackgroundsMIT+

Android

Magic UI·Media & 3D