JGuang

Hexagon Pattern

Hexagon Pattern · Magic UI

Preview
npx shadcn@latest add https://jiguang132.com/r/magic-ui/hexagon-pattern.json

Some upstream demos use online images, videos or tweets. That content depends on network access and third-party services.

Hexagon Pattern

Install: npx shadcn@latest add https://jiguang132.com/r/magic-ui/hexagon-pattern.json

Use case

Draw a repeating hexagonal SVG pattern.

Native props used by the examples

Extracted from all local examples for this entry, grouped by imported module and native owner, including other Magic components used by compound demos. This is not an exhaustive API or a universal host variant. Inspect spread object declarations and the source types/defaults below.

Owning component propExplanationExample source
HexagonPattern.hexagons (hexagon-pattern)Highlighted hexagon column/row coordinate pairs.examples/hexagon-pattern-demo.tsx
HexagonPattern.className (hexagon-pattern)Classes on this native component; initialize Tailwind and its required CSS first.examples/hexagon-pattern-demo.tsx、examples/hexagon-pattern-linear-gradient.tsx
HexagonPattern.radius (hexagon-pattern)Hexagon center-to-vertex radius in pixels.examples/hexagon-pattern-linear-gradient.tsx、examples/hexagon-pattern-dashed.tsx、examples/hexagon-pattern-spacing.tsx
HexagonPattern.x (hexagon-pattern)Horizontal SVG pattern origin offset.examples/hexagon-pattern-linear-gradient.tsx、examples/hexagon-pattern-dashed.tsx、examples/hexagon-pattern-spacing.tsx
HexagonPattern.y (hexagon-pattern)Vertical SVG pattern origin offset.examples/hexagon-pattern-linear-gradient.tsx、examples/hexagon-pattern-dashed.tsx、examples/hexagon-pattern-spacing.tsx
HexagonPattern.strokeDasharray (hexagon-pattern)SVG outline dash pattern; retain the owning type's string/number constraint.examples/hexagon-pattern-dashed.tsx
HexagonPattern.gap (hexagon-pattern)Pixel spacing between hexagons.examples/hexagon-pattern-spacing.tsx

Interaction and state checks

  • Hexagon Pattern Demo — hexagon-pattern-demo
  • Hexagon Pattern Linear Gradient — hexagon-pattern-linear-gradient
  • Hexagon Pattern Dashed — hexagon-pattern-dashed
  • Hexagon Pattern Spacing — hexagon-pattern-spacing

These names identify real example entries, not new component props or extra components. Check pointer/keyboard behavior, themes, small screens and failures for the selected example. Decorative effects must not invent disabled/error/submission states. Complete example installation includes the actual dependency closure.

Business integration boundary

hexagons identifies highlighted columns/rows; radius and gap affect geometry, not a hexagonal data model.

Host and motion setup

Initialize Tailwind CSS v4, semantic CSS variables and the dark variant; import the independent local Registry namespace. Reuse an existing next-themes Provider without substituting JGuang UI/Base UI/HeroUI APIs. Mount effects in view and unmount offscreen; provide static alternatives for unavailable Canvas/WebGL or failed remote media. Respect prefers-reduced-motion and verify timer/RAF/observer/listener cleanup: stopping CSS alone does not prove the engine stopped. Examples provide no backend, login, payment or real AI stream. This practical guide is bilingual; detailed upstream references and demo text retain their original language.

Available examples

hexagon-pattern-demo, hexagon-pattern-linear-gradient, hexagon-pattern-dashed, hexagon-pattern-spacing

Demo state and mock data do not provide a backend service. Inspect the component props before wiring real data.

Installation

<Tabs defaultValue="cli"> <TabsList> <TabsTrigger value="cli">CLI</TabsTrigger> <TabsTrigger value="manual">Manual</TabsTrigger> </TabsList> <TabsContent value="cli">
npx shadcn@latest add @magicui/hexagon-pattern
</TabsContent> <TabsContent value="manual"> <Steps>

<Step>Copy and paste the following code into your project.</Step>

<Step>Update the import paths to match your project setup.</Step>

</Steps> </TabsContent> </Tabs>

Examples

Linear Gradient

Dashed Stroke

Spacing

Usage

import { HexagonPattern } from "@/components/ui/hexagon-pattern"
<div className="relative h-[500px] w-full overflow-hidden">
  <HexagonPattern />
</div>

Props

HexagonPattern

PropTypeDefaultDescription
radiusnumber40Radius from center to vertex for each hexagon
gapnumber0Extra spacing between adjacent hexagons (pixels)
xnumber-1X offset of the pattern origin
ynumber-1Y offset of the pattern origin
direction"horizontal" | "vertical""horizontal"horizontal — flat-top honeycomb; vertical — pointy-top honeycomb
hexagonsArray<[col, row]>—Grid coordinates of highlighted (filled) hexagons
strokeDasharraystring"0"SVG stroke-dasharray for outline hexagons in the repeating pattern
classNamestring—Additional classes on the root SVG (for example Tailwind color utilities)

Also accepts standard SVG attributes on the root <svg> (for example aria-hidden, role) where applicable.

Credits

Complete example installation

The component command installs the component. Each example command also includes its actual imported components, native support UI, utilities and pinned dependencies. Helpers are not additional catalog components.

Hexagon Pattern Demo

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/hexagon-pattern/hexagon-pattern-demo.json

Default import: @/components/magicui/examples/hexagon-pattern-demo

Dependencies: clsx@2.1.1, tailwind-merge@3.6.0

Hexagon Pattern Linear Gradient

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/hexagon-pattern/hexagon-pattern-linear-gradient.json

Default import: @/components/magicui/examples/hexagon-pattern-linear-gradient

Dependencies: clsx@2.1.1, tailwind-merge@3.6.0

Hexagon Pattern Dashed

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/hexagon-pattern/hexagon-pattern-dashed.json

Default import: @/components/magicui/examples/hexagon-pattern-dashed

Dependencies: clsx@2.1.1, tailwind-merge@3.6.0

Hexagon Pattern Spacing

npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/hexagon-pattern/hexagon-pattern-spacing.json

Default import: @/components/magicui/examples/hexagon-pattern-spacing

Dependencies: clsx@2.1.1, tailwind-merge@3.6.0

Minimal usage and theme

import Demo from '@/components/magicui/examples/hexagon-pattern-demo';
import { ThemeProvider } from 'next-themes';
export default function Example() {
  return <ThemeProvider attribute="class" defaultTheme="system" enableSystem><Demo /></ThemeProvider>;
}

Initialize Tailwind CSS v4, semantic color variables and the dark variant first. Reuse an existing next-themes provider rather than nesting another. Next Link examples require a Next.js environment; in static Vite projects adapt the demo links to your router without changing the native component API. Some media and tweets require network access. Examples do not supply authentication or backend services.

Source-backed parameter reference

Implementation signatures and types are generated from the pinned local source. Optional props, native inherited types, union branches and never exclusions are preserved. A forwardRef implementation's ref is a React reference, not an additional business prop.

HexagonPattern({
  radius = 40,
  gap = 0,
  x = -1,
  y = -1,
  strokeDasharray = "0",
  direction = "horizontal",
  hexagons,
  className,
  ...props
}: HexagonPatternProps)
interface HexagonPatternProps extends React.SVGProps<SVGSVGElement> {
  /**
   * The radius of each hexagon (center to vertex).
   * @default 40
   */
  radius?: number
  /**
   * Spacing in pixels between adjacent hexagons.
   * The tile grows by this amount while the visual radius stays fixed,
   * so the gap is evenly distributed on all sides of each hexagon.
   * @default 0
   */
  gap?: number
  /**
   * Offset applied to the pattern origin on the x-axis.
   * @default -1
   */
  x?: number
  /**
   * Offset applied to the pattern origin on the y-axis.
   * @default -1
   */
  y?: number
  /**
   * Controls the orientation of the hexagons.
   * - `"horizontal"` — flat-top hexagons tiled in a horizontal honeycomb grid.
   * - `"vertical"` — pointy-top hexagons tiled in a vertical honeycomb grid.
   * @default "horizontal"
   */
  direction?: "horizontal" | "vertical"
  /**
   * SVG stroke-dasharray applied to each hexagon outline.
   * @default "0"
   */
  strokeDasharray?: string
  /**
   * Array of [col, row] coordinates for hexagons that should be highlighted
   * (filled) on top of the repeating pattern — mirrors the `squares` prop of
   * GridPattern.
   */
  hexagons?: Array<[col: number, row: number]>
  className?: string
  [key: string]: unknown
}

Destructuring defaults in source

Only defaults written directly in parameter/props destructuring are listed. Conditional expressions, runtime theme and computed values require source inspection; this is not an exhaustive behavior-default list.

// HexagonPattern
radius = 40

// HexagonPattern
gap = 0

// HexagonPattern
x = -1

// HexagonPattern
y = -1

// HexagonPattern
strokeDasharray = "0"

// HexagonPattern
direction = "horizontal"

Native and external types

External types remain defined by React or native dependencies, not manually expanded into guessed props. The installed version's TypeScript definitions are authoritative.

React.SVGProps<SVGSVGElement>
SVGSVGElement
Array<[col: number, row: number]>