Abdulkader Safi

LaralCN-UI gallery blocks: 17 layouts and a carousel that learned dots

LaralCN-UI now ships 17 gallery blocks, from a single wide image to sliders whose slides run off the edge of the page. Nine are plain CSS grids. The other eight needed the carousel component to grow dots and custom controls, and one assumption in its scroll maths turned out to be wrong.

4 min read

Share
The LaralCN-UI docs showing a component preview beside its Blade source.

LaralCN-UI now ships 17 gallery blocks, from a single wide image to sliders whose slides run off the edge of the page. Nine are plain CSS grids. The other eight needed the carousel component to grow dots and custom controls, and one assumption in its scroll maths turned out to be wrong.

Where the layouts came from

Every block in v0.7.0 is built from a layout in the Relume Figma kit. Each design is a desktop frame and a mobile frame, and I read the spacing and type sizes from Figma through its MCP server instead of eyeballing screenshots. Relume draws everything in black and white with Roboto, so every block translates that into the theme: black text becomes text-foreground, grey image boxes become bg-muted, and the font is whatever your app already uses.

Two rules applied to every block. All content is a prop, the same way the navbars and footers work. And nothing the library already has gets rebuilt: a button is x-ui.button, never a hand-styled <a> that looks like one.

Images you have not picked yet

A gallery with empty boxes looks broken, and shipping stock photos in a copy-and-own file is worse. So an image is ['src' => ..., 'alt' => ...], and when src is missing the block draws a muted box at the design's shape with an image icon in the middle:

<x-ui.blocks.gallery-03 heading="Our studio" :images="[
    ['src' => '/img/desk.jpg', 'alt' => 'The front desk'],
    ['src' => '/img/kitchen.jpg', 'alt' => 'The kitchen'],
    ['src' => null, 'alt' => ''],
]" />

The third box stays a placeholder until you have the photo. Defaults never point at Figma asset URLs, which expire after a week anyway.

Grids that change shape at a breakpoint

gallery-01 to gallery-09 are grids: one image, two to four columns, 3x2 and 4x2, a tall image beside two stacked ones, a large image beside a 2x2 grid, and a masonry layout on CSS columns. No JavaScript.

I expected to use the aspect-ratio component everywhere, and three blocks could not. It sets its ratio as an inline style, so the ratio cannot change at a breakpoint, and gallery-01 is 16:9 on a phone but 1280:738 on desktop. Those three use Tailwind's aspect classes on a plain box instead; the other six use the component. That is the kind of exception I want written down, not quietly copied markup.

The sliders, gallery-10 to gallery-17, needed arrows where the design puts them and dots under the track. Several also wanted slides that peek into the page margin. Each block could have shipped its own script. Instead the carousel learned them, all backwards compatible:

<x-ui.carousel :arrows="false" track="gap-8 ps-[5%] scroll-ps-[5%]">
    @foreach ($images as $image)
        <x-ui.carousel.item class="basis-full md:basis-1/2">...</x-ui.carousel.item>
    @endforeach

    <x-slot:controls>
        <x-ui.button variant="outline" size="icon" data-ui-carousel-prev aria-label="Previous slide">...</x-ui.button>
        <x-ui.button variant="outline" size="icon" data-ui-carousel-next aria-label="Next slide">...</x-ui.button>
        <div data-ui-carousel-dots></div>
    </x-slot:controls>
</x-ui.carousel>

:arrows="false" hides the built-in arrows. The controls slot exists because anything in the default slot lands inside the scrolling track and becomes a slide. An empty data-ui-carousel-dots element gets one button per slide; the current one carries aria-current and data-active, and the active dot follows the scroll on scrollend, with a debounced scroll fallback for browsers without it.

The bug: Next did nothing

With padding on the track, the Next arrow stopped working. The script finds the next slide by measuring each slide's edge from the track's start edge and scrolling to the first one past the current position. Padding shifts every slide right, so the first slide's edge sat at the padding width instead of zero, and the maths treated it as already scrolled past.

The obvious fix was to read scroll-padding and subtract it. That failed too: when scroll padding is a percentage, getComputedStyle hands it back unresolved, so there is no pixel value to subtract. The script now measures every slide relative to the first one, which needs no CSS at all and gives the same result as before when there is no padding.

Slides that run off the page

gallery-15 to gallery-17 put the heading on one side and the slides on the other, running past the container to the screen edge. The slider column is a CSS size container, slides are sized in cqw, and the carousel is pulled to the page edge with a negative margin that uses the same max() as the container's centring. It holds from 375px to wide screens, and it mirrors under dir="rtl" because the margin is me-, not mr-.

Where it is

composer require --dev safi/laralcn-ui
php artisan ui:init
php artisan ui:add-block gallery-15

ui:add-block installs the carousel and button with it. Docs and previews: https://laralcn-ui.abdulkadersafi.com/blocks (Arabic previews under /ar/blocks). Source: https://github.com/Abdulkader-Safi/LaralCN-UI. MIT licensed.

Next: 18 contact blocks, and a null that never meant what the docs said.

Last updated 1 Dec 2026 · filed under Laravel, blade, tailwindcss, javascript, laralcn-ui

Every entry on this project

26 build notes, in order

Including the ones where nothing worked. You are on part 23.

Read the series →

FAQ

Frequently asked questions

Do the gallery blocks need JavaScript?

The nine grid blocks have none. The sliders use the carousel component's small inline script, and no block ships a script of its own.

How do I add my own images?

Pass :images as a list of ['src' => ..., 'alt' => ...]. Any image without a src renders as a placeholder box at the right shape.

Does the carousel change break my existing carousels?

No. The new arrows prop defaults to true and the controls slot and dots are optional, so an existing carousel renders and behaves as before.

Do the sliders work right to left?

Yes. The carousel measures slides from the start edge, so the whole slider mirrors under dir="rtl".

Written by

Abdulkader Safi

Software Engineer

Lead engineer at DSRPT, from Lebanon and based in Kuwait. I write about the tools and bugs from real client work, with the numbers I measured.

About me → GitHub LinkedIn

Need this kind of work done on your project?

Start a project →

Keep reading

More from LaralCN-UI: shadcn-style Blade components and blocks you own

All 26 entries →