Background Boxes
A skewed, flat, or perspective grid of tiles that light up under the cursor and fade back, using only CSS hover.
Design in blocks
Move your cursor across the grid and watch each tile light up.
Design in blocks
Move your cursor across the grid and watch each tile light up.
Design in blocks
Move your cursor across the grid and watch each tile light up.
Design in blocks
Move your cursor across the grid and watch each tile light up.
Design in blocks
Move your cursor across the grid and watch each tile light up.
<x-markas.background-boxes class="rounded-xl border border-line bg-surface px-6 py-16">
<div class="grid justify-items-center gap-4 text-center">
<h2 class="text-4xl font-bold tracking-tight text-ink">
Design in blocks
</h2>
<p class="max-w-72 rounded-md bg-surface/80 text-sm text-muted">
Move your cursor across the grid and watch each tile light up.
</p>
<x-markas.button>Explore blocks</x-markas.button>
</div>
</x-markas.background-boxes>import { BackgroundBoxes } from "@/components/markas/BackgroundBoxes";
import { Button } from "@/components/markas/Button";
export default function BackgroundBoxesExample() {
return (
<BackgroundBoxes className="rounded-xl border border-line bg-surface px-6 py-16">
<div className="grid justify-items-center gap-4 text-center">
<h2 className="text-4xl font-bold tracking-tight text-ink">
Design in blocks
</h2>
<p className="max-w-72 rounded-md bg-surface/80 text-sm text-muted">
Move your cursor across the grid and watch each tile light up.
</p>
<Button>Explore blocks</Button>
</div>
</BackgroundBoxes>
);
}<script setup lang="ts">
import BackgroundBoxes from "@/components/markas/BackgroundBoxes.vue";
import Button from "@/components/markas/Button.vue";
</script>
<template>
<BackgroundBoxes class="rounded-xl border border-line bg-surface px-6 py-16">
<div class="grid justify-items-center gap-4 text-center">
<h2 class="text-4xl font-bold tracking-tight text-ink">
Design in blocks
</h2>
<p class="max-w-72 rounded-md bg-surface/80 text-sm text-muted">
Move your cursor across the grid and watch each tile light up.
</p>
<Button>Explore blocks</Button>
</div>
</BackgroundBoxes>
</template><script lang="ts">
import BackgroundBoxes from "$lib/components/markas/BackgroundBoxes.svelte";
import Button from "$lib/components/markas/Button.svelte";
</script>
<BackgroundBoxes class="rounded-xl border border-line bg-surface px-6 py-16">
<div class="grid justify-items-center gap-4 text-center">
<h2 class="text-4xl font-bold tracking-tight text-ink">Design in blocks</h2>
<p class="max-w-72 rounded-md bg-surface/80 text-sm text-muted">
Move your cursor across the grid and watch each tile light up.
</p>
<Button>Explore blocks</Button>
</div>
</BackgroundBoxes>---
import BackgroundBoxes from "@/components/markas/BackgroundBoxes.astro";
import Button from "@/components/markas/Button.astro";
---
<BackgroundBoxes class="rounded-xl border border-line bg-surface px-6 py-16">
<div class="grid justify-items-center gap-4 text-center">
<h2 class="text-4xl font-bold tracking-tight text-ink">
Design in blocks
</h2>
<p class="max-w-72 rounded-md bg-surface/80 text-sm text-muted">
Move your cursor across the grid and watch each tile light up.
</p>
<Button>Explore blocks</Button>
</div>
</BackgroundBoxes>import { Component } from "@angular/core";
import { BackgroundBoxes } from "./markas/background-boxes.component";
import { Button } from "./markas/button.component";
@Component({
selector: "markas-example",
imports: [BackgroundBoxes, Button],
template: `
<div
markas-background-boxes
class="rounded-xl border border-line bg-surface px-6 py-16"
>
<div class="grid justify-items-center gap-4 text-center">
<h2 class="text-4xl font-bold tracking-tight text-ink">
Design in blocks
</h2>
<p class="max-w-72 rounded-md bg-surface/80 text-sm text-muted">
Move your cursor across the grid and watch each tile light up.
</p>
<button markas-button>Explore blocks</button>
</div>
</div>
`,
})
export default class BackgroundBoxesFixture {}Examples
Flat grid feature section
Everything in its place
-
Boards
Plan work in columns.
-
Docs
Write specs next to tasks.
-
Goals
Track progress weekly.
-
Reports
Share wins with one link.
Everything in its place
Boards
Plan work in columns.
Docs
Write specs next to tasks.
Goals
Track progress weekly.
Reports
Share wins with one link.
Everything in its place
Boards
Plan work in columns.
Docs
Write specs next to tasks.
Goals
Track progress weekly.
Reports
Share wins with one link.
Everything in its place
Boards
Plan work in columns.
Docs
Write specs next to tasks.
Goals
Track progress weekly.
Reports
Share wins with one link.
Everything in its place
Boards
Plan work in columns.
Docs
Write specs next to tasks.
Goals
Track progress weekly.
Reports
Share wins with one link.
<x-markas.background-boxes
variant="flat"
color="success"
:rows="8"
:cols="14"
:size="36"
class="rounded-xl border border-line bg-canvas p-6"
>
<div class="grid gap-4">
<h3 class="text-2xl font-semibold text-ink">Everything in its place</h3>
<ul class="grid grid-cols-2 gap-3">
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Boards</p>
<p class="text-xs text-muted">Plan work in columns.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Docs</p>
<p class="text-xs text-muted">Write specs next to tasks.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Goals</p>
<p class="text-xs text-muted">Track progress weekly.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Reports</p>
<p class="text-xs text-muted">Share wins with one link.</p>
</li>
</ul>
</div>
</x-markas.background-boxes>import { BackgroundBoxes } from "@/components/markas/BackgroundBoxes";
export default function Example() {
return (
<BackgroundBoxes
variant="flat"
color="success"
rows={8}
cols={14}
size={36}
className="rounded-xl border border-line bg-canvas p-6"
>
<div className="grid gap-4">
<h3 className="text-2xl font-semibold text-ink">
Everything in its place
</h3>
<ul className="grid grid-cols-2 gap-3">
<li className="rounded-lg border border-line bg-surface p-3">
<p className="text-sm font-semibold text-ink">Boards</p>
<p className="text-xs text-muted">Plan work in columns.</p>
</li>
<li className="rounded-lg border border-line bg-surface p-3">
<p className="text-sm font-semibold text-ink">Docs</p>
<p className="text-xs text-muted">Write specs next to tasks.</p>
</li>
<li className="rounded-lg border border-line bg-surface p-3">
<p className="text-sm font-semibold text-ink">Goals</p>
<p className="text-xs text-muted">Track progress weekly.</p>
</li>
<li className="rounded-lg border border-line bg-surface p-3">
<p className="text-sm font-semibold text-ink">Reports</p>
<p className="text-xs text-muted">Share wins with one link.</p>
</li>
</ul>
</div>
</BackgroundBoxes>
);
}<script setup lang="ts">
import BackgroundBoxes from "@/components/markas/BackgroundBoxes.vue";
</script>
<template>
<BackgroundBoxes
variant="flat"
color="success"
:rows="8"
:cols="14"
:size="36"
class="rounded-xl border border-line bg-canvas p-6"
>
<div class="grid gap-4">
<h3 class="text-2xl font-semibold text-ink">Everything in its place</h3>
<ul class="grid grid-cols-2 gap-3">
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Boards</p>
<p class="text-xs text-muted">Plan work in columns.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Docs</p>
<p class="text-xs text-muted">Write specs next to tasks.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Goals</p>
<p class="text-xs text-muted">Track progress weekly.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Reports</p>
<p class="text-xs text-muted">Share wins with one link.</p>
</li>
</ul>
</div>
</BackgroundBoxes>
</template><script lang="ts">
import BackgroundBoxes from "$lib/components/markas/BackgroundBoxes.svelte";
</script>
<BackgroundBoxes
variant="flat"
color="success"
rows={8}
cols={14}
size={36}
class="rounded-xl border border-line bg-canvas p-6"
>
<div class="grid gap-4">
<h3 class="text-2xl font-semibold text-ink">Everything in its place</h3>
<ul class="grid grid-cols-2 gap-3">
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Boards</p>
<p class="text-xs text-muted">Plan work in columns.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Docs</p>
<p class="text-xs text-muted">Write specs next to tasks.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Goals</p>
<p class="text-xs text-muted">Track progress weekly.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Reports</p>
<p class="text-xs text-muted">Share wins with one link.</p>
</li>
</ul>
</div>
</BackgroundBoxes>---
import BackgroundBoxes from "@/components/markas/BackgroundBoxes.astro";
---
<BackgroundBoxes
variant="flat"
color="success"
rows={8}
cols={14}
size={36}
class="rounded-xl border border-line bg-canvas p-6"
>
<div class="grid gap-4">
<h3 class="text-2xl font-semibold text-ink">
Everything in its place
</h3>
<ul class="grid grid-cols-2 gap-3">
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Boards</p>
<p class="text-xs text-muted">Plan work in columns.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Docs</p>
<p class="text-xs text-muted">Write specs next to tasks.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Goals</p>
<p class="text-xs text-muted">Track progress weekly.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Reports</p>
<p class="text-xs text-muted">Share wins with one link.</p>
</li>
</ul>
</div>
</BackgroundBoxes>import { Component } from "@angular/core";
import { BackgroundBoxes } from "./markas/background-boxes.component";
@Component({
selector: "markas-example",
imports: [BackgroundBoxes],
template: `
<div
markas-background-boxes
variant="flat"
color="success"
[rows]="8"
[cols]="14"
[size]="36"
class="rounded-xl border border-line bg-canvas p-6"
>
<div class="grid gap-4">
<h3 class="text-2xl font-semibold text-ink">Everything in its place</h3>
<ul class="grid grid-cols-2 gap-3">
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Boards</p>
<p class="text-xs text-muted">Plan work in columns.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Docs</p>
<p class="text-xs text-muted">Write specs next to tasks.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Goals</p>
<p class="text-xs text-muted">Track progress weekly.</p>
</li>
<li class="rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-semibold text-ink">Reports</p>
<p class="text-xs text-muted">Share wins with one link.</p>
</li>
</ul>
</div>
</div>
`,
})
export default class BackgroundBoxesFeaturesExample {}404 page in perspective
404
This tile is missing
The page may have moved. Try the dashboard instead.
404
This tile is missing
The page may have moved. Try the dashboard instead.
404
This tile is missing
The page may have moved. Try the dashboard instead.
404
This tile is missing
The page may have moved. Try the dashboard instead.
404
This tile is missing
The page may have moved. Try the dashboard instead.
<x-markas.background-boxes
variant="perspective"
color="warning"
:rows="14"
:cols="20"
class="rounded-xl border border-line bg-surface px-6 pt-10 pb-24"
>
<div class="grid justify-items-center gap-3 text-center">
<p class="text-6xl font-bold tracking-tight text-ink">404</p>
<h3 class="text-lg font-semibold text-ink">
This tile is missing
</h3>
<p class="max-w-72 text-sm text-muted">
The page may have moved. Try the dashboard instead.
</p>
<x-markas.button variant="secondary">Go to dashboard</x-markas.button>
</div>
</x-markas.background-boxes>import { BackgroundBoxes } from "@/components/markas/BackgroundBoxes";
import { Button } from "@/components/markas/Button";
export default function Example() {
return (
<BackgroundBoxes
variant="perspective"
color="warning"
rows={14}
cols={20}
className="rounded-xl border border-line bg-surface px-6 pt-10 pb-24"
>
<div className="grid justify-items-center gap-3 text-center">
<p className="text-6xl font-bold tracking-tight text-ink">404</p>
<h3 className="text-lg font-semibold text-ink">This tile is missing</h3>
<p className="max-w-72 text-sm text-muted">
The page may have moved. Try the dashboard instead.
</p>
<Button variant="secondary">Go to dashboard</Button>
</div>
</BackgroundBoxes>
);
}<script setup lang="ts">
import BackgroundBoxes from "@/components/markas/BackgroundBoxes.vue";
import Button from "@/components/markas/Button.vue";
</script>
<template>
<BackgroundBoxes
variant="perspective"
color="warning"
:rows="14"
:cols="20"
class="rounded-xl border border-line bg-surface px-6 pt-10 pb-24"
>
<div class="grid justify-items-center gap-3 text-center">
<p class="text-6xl font-bold tracking-tight text-ink">404</p>
<h3 class="text-lg font-semibold text-ink">This tile is missing</h3>
<p class="max-w-72 text-sm text-muted">
The page may have moved. Try the dashboard instead.
</p>
<Button variant="secondary">Go to dashboard</Button>
</div>
</BackgroundBoxes>
</template><script lang="ts">
import BackgroundBoxes from "$lib/components/markas/BackgroundBoxes.svelte";
import Button from "$lib/components/markas/Button.svelte";
</script>
<BackgroundBoxes
variant="perspective"
color="warning"
rows={14}
cols={20}
class="rounded-xl border border-line bg-surface px-6 pt-10 pb-24"
>
<div class="grid justify-items-center gap-3 text-center">
<p class="text-6xl font-bold tracking-tight text-ink">404</p>
<h3 class="text-lg font-semibold text-ink">This tile is missing</h3>
<p class="max-w-72 text-sm text-muted">
The page may have moved. Try the dashboard instead.
</p>
<Button variant="secondary">Go to dashboard</Button>
</div>
</BackgroundBoxes>---
import BackgroundBoxes from "@/components/markas/BackgroundBoxes.astro";
import Button from "@/components/markas/Button.astro";
---
<BackgroundBoxes
variant="perspective"
color="warning"
rows={14}
cols={20}
class="rounded-xl border border-line bg-surface px-6 pt-10 pb-24"
>
<div class="grid justify-items-center gap-3 text-center">
<p class="text-6xl font-bold tracking-tight text-ink">404</p>
<h3 class="text-lg font-semibold text-ink">This tile is missing</h3>
<p class="max-w-72 text-sm text-muted">
The page may have moved. Try the dashboard instead.
</p>
<Button variant="secondary">Go to dashboard</Button>
</div>
</BackgroundBoxes>import { Component } from "@angular/core";
import { BackgroundBoxes } from "./markas/background-boxes.component";
import { Button } from "./markas/button.component";
@Component({
selector: "markas-example",
imports: [BackgroundBoxes, Button],
template: `
<div
markas-background-boxes
variant="perspective"
color="warning"
[rows]="14"
[cols]="20"
class="rounded-xl border border-line bg-surface px-6 pt-10 pb-24"
>
<div class="grid justify-items-center gap-3 text-center">
<p class="text-6xl font-bold tracking-tight text-ink">404</p>
<h3 class="text-lg font-semibold text-ink">This tile is missing</h3>
<p class="max-w-72 text-sm text-muted">
The page may have moved. Try the dashboard instead.
</p>
<button markas-button variant="secondary">Go to dashboard</button>
</div>
</div>
`,
})
export default class BackgroundBoxesNotFoundExample {}Compact promo banner
Black Friday deal
Half off every annual plan.
Black Friday deal
Half off every annual plan.
Black Friday deal
Half off every annual plan.
Black Friday deal
Half off every annual plan.
Black Friday deal
Half off every annual plan.
<x-markas.background-boxes
color="danger"
:rows="10"
:cols="16"
:size="28"
speed="fast"
class="rounded-xl border border-line bg-surface p-6"
>
<div class="flex items-center justify-between gap-4">
<div class="grid gap-1">
<h3 class="text-lg font-semibold text-ink">Black Friday deal</h3>
<p class="text-sm text-muted">Half off every annual plan.</p>
</div>
<x-markas.button>Claim offer</x-markas.button>
</div>
</x-markas.background-boxes>import { BackgroundBoxes } from "@/components/markas/BackgroundBoxes";
import { Button } from "@/components/markas/Button";
export default function Example() {
return (
<BackgroundBoxes
color="danger"
rows={10}
cols={16}
size={28}
speed="fast"
className="rounded-xl border border-line bg-surface p-6"
>
<div className="flex items-center justify-between gap-4">
<div className="grid gap-1">
<h3 className="text-lg font-semibold text-ink">Black Friday deal</h3>
<p className="text-sm text-muted">Half off every annual plan.</p>
</div>
<Button>Claim offer</Button>
</div>
</BackgroundBoxes>
);
}<script setup lang="ts">
import BackgroundBoxes from "@/components/markas/BackgroundBoxes.vue";
import Button from "@/components/markas/Button.vue";
</script>
<template>
<BackgroundBoxes
color="danger"
:rows="10"
:cols="16"
:size="28"
speed="fast"
class="rounded-xl border border-line bg-surface p-6"
>
<div class="flex items-center justify-between gap-4">
<div class="grid gap-1">
<h3 class="text-lg font-semibold text-ink">Black Friday deal</h3>
<p class="text-sm text-muted">Half off every annual plan.</p>
</div>
<Button>Claim offer</Button>
</div>
</BackgroundBoxes>
</template><script lang="ts">
import BackgroundBoxes from "$lib/components/markas/BackgroundBoxes.svelte";
import Button from "$lib/components/markas/Button.svelte";
</script>
<BackgroundBoxes
color="danger"
rows={10}
cols={16}
size={28}
speed="fast"
class="rounded-xl border border-line bg-surface p-6"
>
<div class="flex items-center justify-between gap-4">
<div class="grid gap-1">
<h3 class="text-lg font-semibold text-ink">Black Friday deal</h3>
<p class="text-sm text-muted">Half off every annual plan.</p>
</div>
<Button>Claim offer</Button>
</div>
</BackgroundBoxes>---
import BackgroundBoxes from "@/components/markas/BackgroundBoxes.astro";
import Button from "@/components/markas/Button.astro";
---
<BackgroundBoxes
color="danger"
rows={10}
cols={16}
size={28}
speed="fast"
class="rounded-xl border border-line bg-surface p-6"
>
<div class="flex items-center justify-between gap-4">
<div class="grid gap-1">
<h3 class="text-lg font-semibold text-ink">Black Friday deal</h3>
<p class="text-sm text-muted">Half off every annual plan.</p>
</div>
<Button>Claim offer</Button>
</div>
</BackgroundBoxes>import { Component } from "@angular/core";
import { BackgroundBoxes } from "./markas/background-boxes.component";
import { Button } from "./markas/button.component";
@Component({
selector: "markas-example",
imports: [BackgroundBoxes, Button],
template: `
<div
markas-background-boxes
color="danger"
[rows]="10"
[cols]="16"
[size]="28"
speed="fast"
class="rounded-xl border border-line bg-surface p-6"
>
<div class="flex items-center justify-between gap-4">
<div class="grid gap-1">
<h3 class="text-lg font-semibold text-ink">Black Friday deal</h3>
<p class="text-sm text-muted">Half off every annual plan.</p>
</div>
<button markas-button>Claim offer</button>
</div>
</div>
`,
})
export default class BackgroundBoxesCtaExample {}Installation
npx markasui@latest add background-boxespnpm dlx markasui@latest add background-boxesyarn dlx markasui@latest add background-boxesbunx --bun markasui@latest add background-boxes- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
resources/views/components/markas/background-boxes.blade.php.
@props([
'variant' => 'skewed',
'rows' => 12,
'cols' => 18,
'size' => 40,
'speed' => 'normal',
'color' => 'primary',
])
@php
$base = 'relative isolate overflow-hidden';
$layer = 'absolute inset-0 overflow-hidden';
$grid = 'absolute top-1/2 left-1/2 grid grid-cols-[repeat(var(--markas-boxes-cols),var(--markas-boxes-size))] auto-rows-[var(--markas-boxes-size)] border-t border-l border-line';
$cell = 'border-r border-b border-line transition-colors duration-1000 ease-out hover:bg-current/40 hover:duration-0 motion-reduce:transition-none';
$ember = 'animate-[markas-boxes-glow_var(--markas-boxes-duration)_ease-in-out_infinite] motion-reduce:animate-none';
$content = 'pointer-events-none relative [&_:is(a,button,input,select,textarea,label,summary)]:pointer-events-auto';
$variants = [
'skewed' => ['layer' => '[mask-image:radial-gradient(ellipse_at_center,black_40%,transparent_85%)]', 'grid' => '[transform:translate(-50%,-50%)_skewX(-48deg)_skewY(14deg)]'],
'flat' => ['layer' => '[mask-image:radial-gradient(ellipse_at_center,black_40%,transparent_85%)]', 'grid' => '-translate-x-1/2 -translate-y-1/2'],
'perspective' => ['layer' => '[perspective:520px] [mask-image:linear-gradient(to_bottom,transparent_25%,black_60%)]', 'grid' => '[transform:translate(-50%,-38%)_rotateX(58deg)]'],
];
$colors = [
'muted' => 'text-muted',
'primary' => 'text-primary',
'success' => 'text-success',
'warning' => 'text-warning',
'danger' => 'text-danger',
];
$speeds = ['slow' => '9s', 'normal' => '6s', 'fast' => '3.5s'];
$keyframes = '@keyframes markas-boxes-glow{0%,100%{box-shadow:none}50%{box-shadow:inset 0 0 0 999px color-mix(in oklab,currentColor 30%,transparent)}}';
$maxCells = 600;
$maxSide = 40;
$emberTarget = 6;
$emberDelayMs = 700;
$shape = $variants[$variant] ?? $variants['skewed'];
$columns = max(1, min((int) $cols, $maxSide));
$total = min(max(1, min((int) $rows, $maxSide)) * $columns, $maxCells);
// Sel ke-i. Sekitar 6% sel (dua modulus berbeda supaya tidak membentuk garis) menyala pelan supaya latar terasa hidup tanpa hover.
$cells = [];
for ($i = 0; $i < $total; $i++) {
$lit = ($i * 7) % 13 + ($i * $i) % 11 === $emberTarget;
$cells[] = $lit ? ['class' => $cell.' '.$ember, 'style' => 'animation-delay: '.(($i % 9) * -$emberDelayMs).'ms'] : ['class' => $cell, 'style' => null];
}
$vars = '--markas-boxes-cols: '.$columns.'; --markas-boxes-size: '.(float) $size.'px; --markas-boxes-duration: '.($speeds[$speed] ?? $speeds['normal']);
@endphp
<div {{ $attributes->merge(['style' => $vars])->class([$base]) }}>
<style>{!! $keyframes !!}</style>
<div aria-hidden="true" wire:ignore @class([$layer, $shape['layer'], $colors[$color] ?? $colors['primary']])>
<div @class([$grid, $shape['grid']])>
@foreach ($cells as $item)
<span class="{{ $item['class'] }}" @if ($item['style']) style="{{ $item['style'] }}" @endif></span>
@endforeach
</div>
</div>
<div class="{{ $content }}">{{ $slot }}</div>
</div>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/BackgroundBoxes.tsx.
import type { ComponentProps, CSSProperties } from "react";
const base = "relative isolate overflow-hidden";
const layer = "absolute inset-0 overflow-hidden";
const grid =
"absolute top-1/2 left-1/2 grid grid-cols-[repeat(var(--markas-boxes-cols),var(--markas-boxes-size))] auto-rows-[var(--markas-boxes-size)] border-t border-l border-line";
const cell =
"border-r border-b border-line transition-colors duration-1000 ease-out hover:bg-current/40 hover:duration-0 motion-reduce:transition-none";
const ember =
"animate-[markas-boxes-glow_var(--markas-boxes-duration)_ease-in-out_infinite] motion-reduce:animate-none";
const content =
"pointer-events-none relative [&_:is(a,button,input,select,textarea,label,summary)]:pointer-events-auto";
const variants = {
skewed: {
layer:
"[mask-image:radial-gradient(ellipse_at_center,black_40%,transparent_85%)]",
grid: "[transform:translate(-50%,-50%)_skewX(-48deg)_skewY(14deg)]",
},
flat: {
layer:
"[mask-image:radial-gradient(ellipse_at_center,black_40%,transparent_85%)]",
grid: "-translate-x-1/2 -translate-y-1/2",
},
perspective: {
layer:
"[perspective:520px] [mask-image:linear-gradient(to_bottom,transparent_25%,black_60%)]",
grid: "[transform:translate(-50%,-38%)_rotateX(58deg)]",
},
};
const colors = {
muted: "text-muted",
primary: "text-primary",
success: "text-success",
warning: "text-warning",
danger: "text-danger",
};
const speeds = { slow: "9s", normal: "6s", fast: "3.5s" };
const keyframes =
"@keyframes markas-boxes-glow{0%,100%{box-shadow:none}50%{box-shadow:inset 0 0 0 999px color-mix(in oklab,currentColor 30%,transparent)}}";
const MAX_CELLS = 600;
const MAX_SIDE = 40;
const EMBER_TARGET = 6;
const EMBER_DELAY_MS = 700;
const cx = (...c: (string | false | null | undefined)[]) =>
c.filter(Boolean).join(" ");
const side = (value: number) =>
Math.max(1, Math.min(Math.trunc(value), MAX_SIDE));
/** Sel ke-i. Sekitar 6% sel (dua modulus berbeda supaya tidak membentuk garis) menyala pelan supaya latar terasa hidup tanpa hover. */
function makeCells(rows: number, cols: number) {
const columns = side(cols);
const total = Math.min(side(rows) * columns, MAX_CELLS);
return Array.from({ length: total }, (_, index) => {
const lit = ((index * 7) % 13) + ((index * index) % 11) === EMBER_TARGET;
return lit
? { lit, style: { animationDelay: `${(index % 9) * -EMBER_DELAY_MS}ms` } }
: { lit, style: undefined };
});
}
export type BackgroundBoxesProps = ComponentProps<"div"> & {
variant?: keyof typeof variants;
rows?: number;
cols?: number;
size?: number;
speed?: keyof typeof speeds;
color?: keyof typeof colors;
};
export function BackgroundBoxes({
variant = "skewed",
rows = 12,
cols = 18,
size = 40,
speed = "normal",
color = "primary",
className,
style,
children,
...props
}: BackgroundBoxesProps) {
const vars = {
"--markas-boxes-cols": side(cols),
"--markas-boxes-size": `${size}px`,
"--markas-boxes-duration": speeds[speed],
} as CSSProperties;
return (
<div
{...props}
className={cx(base, className)}
style={{ ...vars, ...style }}
>
<style>{keyframes}</style>
<div
aria-hidden="true"
className={cx(layer, variants[variant].layer, colors[color])}
>
<div className={cx(grid, variants[variant].grid)}>
{makeCells(rows, cols).map((item, index) => (
<span
key={index}
className={cx(cell, item.lit && ember)}
style={item.style}
/>
))}
</div>
</div>
<div className={content}>{children}</div>
</div>
);
}- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/BackgroundBoxes.vue.
<script setup lang="ts">
import { computed } from "vue";
const base = "relative isolate overflow-hidden";
const layer = "absolute inset-0 overflow-hidden";
const grid =
"absolute top-1/2 left-1/2 grid grid-cols-[repeat(var(--markas-boxes-cols),var(--markas-boxes-size))] auto-rows-[var(--markas-boxes-size)] border-t border-l border-line";
const cell =
"border-r border-b border-line transition-colors duration-1000 ease-out hover:bg-current/40 hover:duration-0 motion-reduce:transition-none";
const ember =
"animate-[markas-boxes-glow_var(--markas-boxes-duration)_ease-in-out_infinite] motion-reduce:animate-none";
const content =
"pointer-events-none relative [&_:is(a,button,input,select,textarea,label,summary)]:pointer-events-auto";
const variants = {
skewed: {
layer:
"[mask-image:radial-gradient(ellipse_at_center,black_40%,transparent_85%)]",
grid: "[transform:translate(-50%,-50%)_skewX(-48deg)_skewY(14deg)]",
},
flat: {
layer:
"[mask-image:radial-gradient(ellipse_at_center,black_40%,transparent_85%)]",
grid: "-translate-x-1/2 -translate-y-1/2",
},
perspective: {
layer:
"[perspective:520px] [mask-image:linear-gradient(to_bottom,transparent_25%,black_60%)]",
grid: "[transform:translate(-50%,-38%)_rotateX(58deg)]",
},
};
const colors = {
muted: "text-muted",
primary: "text-primary",
success: "text-success",
warning: "text-warning",
danger: "text-danger",
};
const speeds = { slow: "9s", normal: "6s", fast: "3.5s" };
const keyframes =
"@keyframes markas-boxes-glow{0%,100%{box-shadow:none}50%{box-shadow:inset 0 0 0 999px color-mix(in oklab,currentColor 30%,transparent)}}";
const MAX_CELLS = 600;
const MAX_SIDE = 40;
const EMBER_TARGET = 6;
const EMBER_DELAY_MS = 700;
const side = (value: number) =>
Math.max(1, Math.min(Math.trunc(value), MAX_SIDE));
/** Sel ke-i. Sekitar 6% sel (dua modulus berbeda supaya tidak membentuk garis) menyala pelan supaya latar terasa hidup tanpa hover. */
function makeCells(rows: number, cols: number) {
const columns = side(cols);
const total = Math.min(side(rows) * columns, MAX_CELLS);
return Array.from({ length: total }, (_, index) => {
const lit = ((index * 7) % 13) + ((index * index) % 11) === EMBER_TARGET;
return lit
? { lit, style: { animationDelay: `${(index % 9) * -EMBER_DELAY_MS}ms` } }
: { lit, style: undefined };
});
}
const props = withDefaults(
defineProps<{
variant?: keyof typeof variants;
rows?: number;
cols?: number;
size?: number;
speed?: keyof typeof speeds;
color?: keyof typeof colors;
}>(),
{
variant: "skewed",
rows: 12,
cols: 18,
size: 40,
speed: "normal",
color: "primary",
},
);
const vars = computed(() => ({
"--markas-boxes-cols": side(props.cols),
"--markas-boxes-size": `${props.size}px`,
"--markas-boxes-duration": speeds[props.speed],
}));
const cells = computed(() => makeCells(props.rows, props.cols));
</script>
<template>
<div :class="base" :style="vars">
<component :is="'style'">{{ keyframes }}</component>
<div
aria-hidden="true"
:class="[layer, variants[props.variant].layer, colors[props.color]]"
>
<div :class="[grid, variants[props.variant].grid]">
<span
v-for="(item, index) in cells"
:key="index"
:class="[cell, item.lit && ember]"
:style="item.style"
/>
</div>
</div>
<div :class="content"><slot /></div>
</div>
</template>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/lib/components/markas/BackgroundBoxes.svelte.
<script lang="ts">
import type { Snippet } from "svelte";
import type { HTMLAttributes } from "svelte/elements";
const base = "relative isolate overflow-hidden";
const layer = "absolute inset-0 overflow-hidden";
const grid =
"absolute top-1/2 left-1/2 grid grid-cols-[repeat(var(--markas-boxes-cols),var(--markas-boxes-size))] auto-rows-[var(--markas-boxes-size)] border-t border-l border-line";
const cell =
"border-r border-b border-line transition-colors duration-1000 ease-out hover:bg-current/40 hover:duration-0 motion-reduce:transition-none";
const ember =
"animate-[markas-boxes-glow_var(--markas-boxes-duration)_ease-in-out_infinite] motion-reduce:animate-none";
const content =
"pointer-events-none relative [&_:is(a,button,input,select,textarea,label,summary)]:pointer-events-auto";
const variants = {
skewed: {
layer:
"[mask-image:radial-gradient(ellipse_at_center,black_40%,transparent_85%)]",
grid: "[transform:translate(-50%,-50%)_skewX(-48deg)_skewY(14deg)]",
},
flat: {
layer:
"[mask-image:radial-gradient(ellipse_at_center,black_40%,transparent_85%)]",
grid: "-translate-x-1/2 -translate-y-1/2",
},
perspective: {
layer:
"[perspective:520px] [mask-image:linear-gradient(to_bottom,transparent_25%,black_60%)]",
grid: "[transform:translate(-50%,-38%)_rotateX(58deg)]",
},
};
const colors = {
muted: "text-muted",
primary: "text-primary",
success: "text-success",
warning: "text-warning",
danger: "text-danger",
};
const speeds = { slow: "9s", normal: "6s", fast: "3.5s" };
const keyframes =
"@keyframes markas-boxes-glow{0%,100%{box-shadow:none}50%{box-shadow:inset 0 0 0 999px color-mix(in oklab,currentColor 30%,transparent)}}";
const MAX_CELLS = 600;
const MAX_SIDE = 40;
const EMBER_TARGET = 6;
const EMBER_DELAY_MS = 700;
const side = (value: number) =>
Math.max(1, Math.min(Math.trunc(value), MAX_SIDE));
/** Sel ke-i. Sekitar 6% sel (dua modulus berbeda supaya tidak membentuk garis) menyala pelan supaya latar terasa hidup tanpa hover. */
function makeCells(rows: number, cols: number) {
const columns = side(cols);
const total = Math.min(side(rows) * columns, MAX_CELLS);
return Array.from({ length: total }, (_, index) => {
const lit = ((index * 7) % 13) + ((index * index) % 11) === EMBER_TARGET;
return lit
? { lit, style: `animation-delay:${(index % 9) * -EMBER_DELAY_MS}ms` }
: { lit, style: undefined };
});
}
type Props = HTMLAttributes<HTMLDivElement> & {
variant?: keyof typeof variants;
rows?: number;
cols?: number;
size?: number;
speed?: keyof typeof speeds;
color?: keyof typeof colors;
children?: Snippet;
};
let {
variant = "skewed",
rows = 12,
cols = 18,
size = 40,
speed = "normal",
color = "primary",
class: className,
style,
children,
...rest
}: Props = $props();
const vars = $derived(
`--markas-boxes-cols:${side(cols)};--markas-boxes-size:${size}px;--markas-boxes-duration:${speeds[speed]}`,
);
const cells = $derived(makeCells(rows, cols));
</script>
<div {...rest} class={[base, className]} style="{vars};{style ?? ''}">
{@html `<style>${keyframes}</style>`}
<div
aria-hidden="true"
class={[layer, variants[variant].layer, colors[color]]}
>
<div class={[grid, variants[variant].grid]}>
{#each cells as item, index (index)}
<span class={[cell, item.lit && ember]} style={item.style}></span>
{/each}
</div>
</div>
<div class={content}>{@render children?.()}</div>
</div>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/BackgroundBoxes.astro.
---
import type { HTMLAttributes } from "astro/types";
const base = "relative isolate overflow-hidden";
const layer = "absolute inset-0 overflow-hidden";
const grid =
"absolute top-1/2 left-1/2 grid grid-cols-[repeat(var(--markas-boxes-cols),var(--markas-boxes-size))] auto-rows-[var(--markas-boxes-size)] border-t border-l border-line";
const cell =
"border-r border-b border-line transition-colors duration-1000 ease-out hover:bg-current/40 hover:duration-0 motion-reduce:transition-none";
const ember =
"animate-[markas-boxes-glow_var(--markas-boxes-duration)_ease-in-out_infinite] motion-reduce:animate-none";
const content =
"pointer-events-none relative [&_:is(a,button,input,select,textarea,label,summary)]:pointer-events-auto";
const variants = {
skewed: {
layer:
"[mask-image:radial-gradient(ellipse_at_center,black_40%,transparent_85%)]",
grid: "[transform:translate(-50%,-50%)_skewX(-48deg)_skewY(14deg)]",
},
flat: {
layer:
"[mask-image:radial-gradient(ellipse_at_center,black_40%,transparent_85%)]",
grid: "-translate-x-1/2 -translate-y-1/2",
},
perspective: {
layer:
"[perspective:520px] [mask-image:linear-gradient(to_bottom,transparent_25%,black_60%)]",
grid: "[transform:translate(-50%,-38%)_rotateX(58deg)]",
},
};
const colors = {
muted: "text-muted",
primary: "text-primary",
success: "text-success",
warning: "text-warning",
danger: "text-danger",
};
const speeds = { slow: "9s", normal: "6s", fast: "3.5s" };
const keyframes =
"@keyframes markas-boxes-glow{0%,100%{box-shadow:none}50%{box-shadow:inset 0 0 0 999px color-mix(in oklab,currentColor 30%,transparent)}}";
const MAX_CELLS = 600;
const MAX_SIDE = 40;
const EMBER_TARGET = 6;
const EMBER_DELAY_MS = 700;
const side = (value: number) =>
Math.max(1, Math.min(Math.trunc(value), MAX_SIDE));
/** Sel ke-i. Sekitar 6% sel (dua modulus berbeda supaya tidak membentuk garis) menyala pelan supaya latar terasa hidup tanpa hover. */
function makeCells(rows: number, cols: number) {
const columns = side(cols);
const total = Math.min(side(rows) * columns, MAX_CELLS);
return Array.from({ length: total }, (_, index) => {
const lit = ((index * 7) % 13) + ((index * index) % 11) === EMBER_TARGET;
return lit
? { lit, style: `animation-delay:${(index % 9) * -EMBER_DELAY_MS}ms` }
: { lit, style: undefined };
});
}
type Props = Omit<HTMLAttributes<"div">, "style"> & {
variant?: keyof typeof variants;
rows?: number;
cols?: number;
size?: number;
speed?: keyof typeof speeds;
color?: keyof typeof colors;
style?: string;
};
const {
variant = "skewed",
rows = 12,
cols = 18,
size = 40,
speed = "normal",
color = "primary",
class: className,
style,
...rest
} = Astro.props;
const vars = `--markas-boxes-cols:${side(cols)};--markas-boxes-size:${size}px;--markas-boxes-duration:${speeds[speed]}`;
---
<div {...rest} class:list={[base, className]} style={`${vars};${style ?? ""}`}>
<style is:inline set:html={keyframes} />
<div
aria-hidden="true"
class:list={[layer, variants[variant].layer, colors[color]]}
>
<div class:list={[grid, variants[variant].grid]}>
{
makeCells(rows, cols).map((item) => (
<span class:list={[cell, item.lit && ember]} style={item.style} />
))
}
</div>
</div>
<div class={content}><slot /></div>
</div>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/app/markas/background-boxes.component.ts.
import {
ChangeDetectionStrategy,
Component,
computed,
input,
numberAttribute,
ViewEncapsulation,
} from "@angular/core";
const base = "relative isolate overflow-hidden";
const layer = "absolute inset-0 overflow-hidden";
const grid =
"absolute top-1/2 left-1/2 grid grid-cols-[repeat(var(--markas-boxes-cols),var(--markas-boxes-size))] auto-rows-[var(--markas-boxes-size)] border-t border-l border-line";
const cell =
"border-r border-b border-line transition-colors duration-1000 ease-out hover:bg-current/40 hover:duration-0 motion-reduce:transition-none";
const ember =
"animate-[markas-boxes-glow_var(--markas-boxes-duration)_ease-in-out_infinite] motion-reduce:animate-none";
const content =
"pointer-events-none relative [&_:is(a,button,input,select,textarea,label,summary)]:pointer-events-auto";
const variants = {
skewed: {
layer:
"[mask-image:radial-gradient(ellipse_at_center,black_40%,transparent_85%)]",
grid: "[transform:translate(-50%,-50%)_skewX(-48deg)_skewY(14deg)]",
},
flat: {
layer:
"[mask-image:radial-gradient(ellipse_at_center,black_40%,transparent_85%)]",
grid: "-translate-x-1/2 -translate-y-1/2",
},
perspective: {
layer:
"[perspective:520px] [mask-image:linear-gradient(to_bottom,transparent_25%,black_60%)]",
grid: "[transform:translate(-50%,-38%)_rotateX(58deg)]",
},
};
const colors = {
muted: "text-muted",
primary: "text-primary",
success: "text-success",
warning: "text-warning",
danger: "text-danger",
};
const speeds = { slow: "9s", normal: "6s", fast: "3.5s" };
const keyframes =
"@keyframes markas-boxes-glow{0%,100%{box-shadow:none}50%{box-shadow:inset 0 0 0 999px color-mix(in oklab,currentColor 30%,transparent)}}";
const MAX_CELLS = 600;
const MAX_SIDE = 40;
const EMBER_TARGET = 6;
const EMBER_DELAY_MS = 700;
export type BackgroundBoxesVariant = keyof typeof variants;
export type BackgroundBoxesSpeed = keyof typeof speeds;
export type BackgroundBoxesColor = keyof typeof colors;
const side = (value: number) =>
Math.max(1, Math.min(Math.trunc(value), MAX_SIDE));
/** Sel ke-i. Sekitar 6% sel (dua modulus berbeda supaya tidak membentuk garis) menyala pelan supaya latar terasa hidup tanpa hover. */
function makeCells(rows: number, cols: number) {
const columns = side(cols);
const total = Math.min(side(rows) * columns, MAX_CELLS);
return Array.from({ length: total }, (_, index) => {
const lit = ((index * 7) % 13) + ((index * index) % 11) === EMBER_TARGET;
return lit
? {
className: `${cell} ${ember}`,
style: `animation-delay:${(index % 9) * -EMBER_DELAY_MS}ms`,
}
: { className: cell, style: null };
});
}
/**
* Attribute selector on a native div: the user's class, style, and attributes stay on the
* root. The keyframes are a global style, so encapsulation is off.
*/
@Component({
selector: "div[markas-background-boxes]",
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
styles: [keyframes],
host: {
"[class]": "base",
"[style.--markas-boxes-cols]": "columns()",
"[style.--markas-boxes-size]": "size() + 'px'",
"[style.--markas-boxes-duration]": "duration()",
},
template: `
<div aria-hidden="true" [class]="layerClasses()">
<div [class]="gridClasses()">
@for (item of cells(); track $index) {
<span [class]="item.className" [style]="item.style"></span>
}
</div>
</div>
<div [class]="content"><ng-content /></div>
`,
})
export class BackgroundBoxes {
readonly variant = input<BackgroundBoxesVariant>("skewed");
readonly rows = input(12, { transform: numberAttribute });
readonly cols = input(18, { transform: numberAttribute });
readonly size = input(40, { transform: numberAttribute });
readonly speed = input<BackgroundBoxesSpeed>("normal");
readonly color = input<BackgroundBoxesColor>("primary");
protected readonly base = base;
protected readonly content = content;
protected readonly columns = computed(() => side(this.cols()));
protected readonly duration = computed(() => speeds[this.speed()]);
protected readonly layerClasses = computed(
() => `${layer} ${variants[this.variant()].layer} ${colors[this.color()]}`,
);
protected readonly gridClasses = computed(
() => `${grid} ${variants[this.variant()].grid}`,
);
protected readonly cells = computed(() =>
makeCells(this.rows(), this.cols()),
);
}Usage
<x-markas.background-boxes variant="skewed" :rows="12" :cols="18" class="rounded-xl bg-surface px-6 py-16">
<h2 class="text-center text-3xl font-bold text-ink">Design in blocks</h2>
</x-markas.background-boxes>No JavaScript or Alpine.js needed.
import { BackgroundBoxes } from "@/components/markas/BackgroundBoxes";
<BackgroundBoxes
variant="skewed"
rows={12}
cols={18}
className="rounded-xl bg-surface px-6 py-16"
>
<h2 className="text-center text-3xl font-bold text-ink">Design in blocks</h2>
</BackgroundBoxes>;<template>
<BackgroundBoxes
variant="skewed"
:rows="12"
:cols="18"
class="rounded-xl bg-surface px-6 py-16"
>
<h2 class="text-center text-3xl font-bold text-ink">Design in blocks</h2>
</BackgroundBoxes>
</template><script lang="ts">
import BackgroundBoxes from "$lib/components/markas/BackgroundBoxes.svelte";
</script>
<BackgroundBoxes
variant="skewed"
rows={12}
cols={18}
class="rounded-xl bg-surface px-6 py-16"
>
<h2 class="text-center text-3xl font-bold text-ink">Design in blocks</h2>
</BackgroundBoxes>---
import BackgroundBoxes from "@/components/markas/BackgroundBoxes.astro";
---
<BackgroundBoxes
variant="skewed"
rows={12}
cols={18}
class="rounded-xl bg-surface px-6 py-16"
>
<h2 class="text-center text-3xl font-bold text-ink">Design in blocks</h2>
</BackgroundBoxes>No client-side JavaScript; the markup is rendered on the server.
import { Component } from "@angular/core";
import { BackgroundBoxes } from "./markas/background-boxes.component";
@Component({
selector: "app-hero",
imports: [BackgroundBoxes],
template: `
<div
markas-background-boxes
variant="skewed"
[rows]="12"
[cols]="18"
class="rounded-xl bg-surface px-6 py-16"
>
<h2 class="text-center text-3xl font-bold text-ink">Design in blocks</h2>
</div>
`,
})
export class Hero {}The component is an attribute on a div, so class, style, and other attributes stay on the root element.
- Tiles light up with plain CSS
:hoverand fade back over one second. Touch screens see the few tiles that glow on their own. - The content wrapper lets the pointer through to the grid. Links, buttons, labels, and form fields stay clickable; text inside the content cannot be selected with the mouse.
- Keep rows times cols small: the grid stops at 600 tiles.
- The component has no built-in text, so there are no label props to translate.
Props
| Name | Type | Default | Description |
|---|---|---|---|
variant | skewed | flat | perspective | skewed | skewed tilts the grid like an isometric floor, flat keeps it square, perspective lays it back toward the horizon. |
rows | number | 12 | Number of rows, up to 40. The grid stops at 600 tiles. |
cols | number | 18 | Number of columns, up to 40. |
size | number | 40 | Tile size in pixels. |
speed | slow | normal | fast | normal | Cycle of the few tiles that glow on their own: 9s, 6s, or 3.5s. |
color | muted | primary | success | warning | danger | primary | Token color a tile lights up with. |
children / slot | slot / ReactNode / snippet | - | Content shown on top of the grid. |
Accessibility
- The grid is aria-hidden and its tiles are not focusable.
- Content lets the pointer through to the grid, except links, buttons, labels, and form fields, which stay clickable.
- With reduced motion, tiles stop glowing on their own and change color without a fade.
Related components
More backgrounds components with the same classes in every framework.
- Aurora BackgroundSoft glowing color fields that drift slowly behind your content, made from primary and an accent token.
- Background BeamsThin curved light beams that flow, pulse, or fall and splash behind your content. Pure SVG and CSS, no JavaScript.
- Background LinesSVG lines that draw in and fade out one after another, as waves, rays from a point, or a lattice. Made for hero sections.
- Dot PatternA grid of small dots behind your content, with an optional radial or linear fade. Pure CSS, no JavaScript.
- Gradient BorderWraps a card, button, or field in a moving gradient border that spins, shines, or pulses, with an optional soft glow.
- Grid PatternThin grid lines behind your content, with highlighted cells that pulse softly and an optional fade.