Pattern Craft

repository·main·Indexed 25 days ago

https://github.com/megh-bari/pattern-craft

A collection of 100+ modern CSS background patterns and gradient snippets optimized for JSX (React/Next.js) and Tailwind CSS. It provides production-ready, responsive code for geometric, decorative, gradient, and effect-based backgrounds, including grid overlays and radial glow patterns.

Tokens
18.7K
Snippets
45
Records
60
Agent score
85%

What's inside pattern-craft

  1. Add new patterns to the collection

    main

    To contribute new patterns, add them to src/data/patterns.ts. Each pattern must follow the established object format and include a category from the following list:

    • gradients
    • geometric
    • decorative
    • effects
    {
      id: "unique-pattern-id",
      name: "Pattern Display Name",
      category: "gradients" | "geometric" | "decorative" | "effects",
      badge: "New", // Optional
      style: {
        background: "#ffffff",
        backgroundImage: `// CSS patterns`,
        backgroundSize: "96px 64px, 100% 100%",
      },
      code: `<div className="min-h-screen w-full bg-white relative">...</div>`,
    }
  2. Use CSS/Tailwind patterns in your project

    main

    Pattern Craft provides production-ready design snippets optimized for JSX (React/Next.js) and Tailwind CSS.

    Note: This project does not provide plain HTML or vanilla CSS snippets.

    To use a pattern:

    1. Visit https://patterncraft.store.
    2. Browse the collection and click a pattern to open its preview modal.
    3. Copy the JSX/Tailwind-compatible code snippet.
    4. Paste it into your project (e.g., in a Hero section, landing page, or card background).
  3. Install and run Pattern Craft locally

    main
    To set up the Pattern Craft development environment, ensure you have Node.js 18+ and a package manager (npm, yarn, pnpm, or bun) installed. Follow these steps to clone, install dependencies, and start the development server.
  4. Customize background patterns manually

    main

    You can modify existing patterns by adjusting the pattern object structure. Patterns are defined by an id, name, style (containing background, backgroundImage, and backgroundSize), and a code snippet containing the JSX implementation.

    {
      id: "unique-pattern-id",
      name: "Pattern Display Name",
      badge: "New",
      style: {
        background: "#ffffff",
        backgroundImage: `
          // Your CSS background patterns here
          linear-gradient(to right, #f0f0f0 1px, transparent 1px),
          radial-gradient(circle 800px at 100% 200px, #d5c5ff, transparent)
        `,
        backgroundSize: "96px 64px, 100% 100%",
      },
      code: `<div className="min-h-screen w-full bg-white relative">
      {/* Pattern Name Background */}
      <div
        className="absolute inset-0 z-0"
        style={{
          backgroundImage: `
            // Your background image styles
          `,
          backgroundSize: "96px 64px, 100% 100%",
        }}
      />
      {/* Your Content/Components */}
    </div>`,
    }
  5. Implement decorative background patterns

    main

    Pattern Craft provides a collection of pre-defined background patterns (decorative, gradients, and geometric) that can be integrated into React components. Each pattern includes a specific id, name, category, and a code snippet containing the necessary JSX and inline styles to replicate the effect.

    To use a pattern, copy the provided code snippet into your component. Most patterns use an absolute-positioned div with z-0 to serve as a background layer, allowing you to place your content in a higher z-index layer.

    <div className="min-h-screen w-full bg-white relative overflow-hidden">
      {/* Rose Corner Elegant Background */}
      <div
        className="absolute inset-0 z-0"
        style={{
          backgroundImage: `
            radial-gradient(circle 600px at 0% 200px, #fda4af, transparent),
            radial-gradient(circle 600px at 100% 200px, #fda4af, transparent)
          `,
        }}
      />
      {/* Your Content Here */}
    </div>
  6. Use Diagonal Fade Grid patterns

    main

    A collection of grid patterns that fade diagonally from specific corners or the center. These use maskImage to create the fade effect.

    • Top Left: diagonal-fade-grid-left (fades from 0% 0%)
    • Top Right: diagonal-fade-grid-right (fades from 100% 0%)
    • Bottom Left: diagonal-fade-bottom-grid-Left (fades from 0% 100%)
    • Bottom Right: diagonal-fade-bottom-grid-right (fades from 100% 100%)
    • Center: diagonal-fade-center-grid (fades from 50% 50%)
    // Example: Diagonal Fade Center Grid
    <div className="min-h-screen w-full bg-[#f9fafb] relative">
      <div
        className="absolute inset-0 z-0"
        style={{
          backgroundImage: `
            linear-gradient(to right, #d1d5db 1px, transparent 1px),
            linear-gradient(to bottom, #d1d5db 1px, transparent 1px)
          `,
          backgroundSize: "32px 32px",
          WebkitMaskImage:
             "radial-gradient(ellipse 60% 60% at 50% 50%, #000 30%, transparent 70%)",
          maskImage:
             "radial-gradient(ellipse 60% 60% at 50% 50%, #000 30%, transparent 70%)",
        }}
      />
    </div>
  7. Use Diagonal Cross Grid patterns

    main

    A collection of patterns featuring a diagonal cross-hatch grid (using 45deg and -45deg linear gradients) with various fade effects applied via maskImage.

    • Full Grid: diagonal-cross-grid (no mask)
    • Top Fade: diagonal-cross-grid-top (fades from top center)
    • Bottom Fade: diagonal-cross-grid-bottom (fades from bottom center)
    • Top Right Fade: diagonal-cross-top-right-fade-grid (fades from top left)
    • Top Left Fade: diagonal-cross-top-left-fade-grid (fades from top right)
    • Bottom Right Fade: diagonal-cross-Bottom-right-fade-grid (fades from bottom left)
    • Bottom Left Fade: diagonal-cross-Bottom-left-fade-grid (fades from bottom right)
    • Center Fade: diagonal-cross-center-fade-grid (fades from center)
    // Example: Diagonal Cross Grid
    <div className="min-h-screen w-full bg-white relative">
      <div
        className="absolute inset-0"
        style={{
          backgroundImage: `
            linear-gradient(45deg, transparent 49%, #e5e7eb 49%, #e5e7eb 51%, transparent 51%),
            linear-gradient(-45deg, transparent 49%, #e5e7eb 49%, #e5e7eb 51%, transparent 51%)
          `,
          backgroundSize: "40px 40px",
        }}
      />
    </div>
  8. Configure next-sitemap settings

    main

    The next-sitemap.config.js file defines the configuration for generating sitemaps and robots.txt files using the next-sitemap package. The configuration object accepts the following keys:

    • siteUrl: The base URL of your website (e.g., 'https://patterncraft.store').
    • generateRobotsTxt: Boolean indicating whether to generate a robots.txt file.
    • generateIndexSitemap: Boolean indicating whether to generate a sitemap index file (useful for very large sites).
    • exclude: An array of paths to exclude from the sitemap (supports glob patterns like '/api/*').
    • changefreq: How frequently the page content is expected to change (e.g., 'weekly').
    • priority: A number between 0.0 and 1.0 representing the importance of the URL.
    • trailingSlash: Boolean indicating whether to include a trailing slash in the generated URLs.
    • sourceMap: Boolean indicating whether to generate source maps.
    /** @type {import('next-sitemap').IConfig} */
    module.exports = {
      siteUrl: 'https://patterncraft.store',
      generateRobotsTxt: true,
      generateIndexSitemap: false,
      exclude: [
        '/api/*',
        '/admin/*',
        '/private/*',
        '/_next/*',
        '/404',
        '/500',
      ],
      changefreq: 'weekly',
      priority: 0.7,
      trailingSlash: false,
      sourceMap: false,
    };
  9. Use Vercel Grid Subtle pattern

    main

    The Vercel Grid Subtle pattern uses a 60px grid of low-opacity white lines on a black background, often used with an opacity-30 utility class to achieve a subtle effect.

    <div className="min-h-screen w-full bg-black relative">
        {/* Vercel Grid */}
        <div
          className="absolute inset-0 opacity-30"
          style={{
            backgroundImage: `
              linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
              linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px)
            `,
            backgroundSize: "60px 60px",
          }}
        />
        {/* Your Content/Components */
      </div>
  10. Use Gradient Glow Patterns

    main

    Gradient patterns create soft, atmospheric lighting effects, typically using radial gradients at the top or bottom of a container. Examples include 'Aurora Midnight Glow', 'Crimson Shadow Glow', and 'Emerald Depths Glow'.

    <div className="min-h-screen w-full relative bg-black">
      {/* Aurora Midnight Glow Background with Top Glow */}
      <div
        className="absolute inset-0 z-0"
        style={{
         background: "radial-gradient(ellipse 80% 60% at 50% 0%, rgba(120, 180, 255, 0.25), transparent 70%), #000000",
        }}
      />
      {/* Your Content/Components */}
    </div>
  11. Use Aurora Dream background effects

    main

    The Aurora Dream series provides complex, multi-layered radial gradient backgrounds. These effects are designed to be used as absolute-positioned background layers within a relative container.

    <div className="min-h-screen w-full relative">
      {/* Aurora Dream Corner Whispers */}
      <div
        className="absolute inset-0 z-0"
        style={{
          background: `
            radial-gradient(ellipse 85% 65% at 8% 8%, rgba(175, 109, 255, 0.42), transparent 60%),
                radial-gradient(ellipse 75% 60% at 75% 35%, rgba(255, 235, 170, 0.55), transparent 62%),
                radial-gradient(ellipse 70% 60% at 15% 80%, rgba(255, 100, 180, 0.40), transparent 62%),
                radial-gradient(ellipse 70% 60% at 92% 92%, rgba(120, 190, 255, 0.45), transparent 62%),
                linear-gradient(180deg, #f7eaff 0%, #fde2ea 100%)
          `,
        }}
      />
      {/* Your content goes here */}
    </div>