Abdulkader Safi

LaralCN-UI pricing blocks: the monthly/yearly switch is just tabs

The last batch in v0.7.0 is 18 pricing blocks: plan cards, comparison tables, and many with a monthly/yearly switch. The switch is the library's tabs component, unchanged. Getting it next to the heading, keeping comparison tables readable on a phone, and stopping Arabic pages from printing mo/$49 took the most thought.

4 min read

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

The last batch in v0.7.0 is 18 pricing blocks: plan cards, comparison tables, and many with a monthly/yearly switch. The switch is the library's tabs component, unchanged. Getting it next to the heading, keeping comparison tables readable on a phone, and stopping Arabic pages from printing "mo/$49" took the most thought.

Plans are data

Every pricing block takes plans. A plan is a name, a price and a period, a description, a list of features, and a button label and link. Some layouts add a note for the "or $199 yearly" line, or an icon. Plans usually live in config or the database, so the block reads them straight from a prop:

<x-ui.blocks.pricing-09 heading="Simple pricing" :plans="[
    'monthly' => [
        ['name' => 'Starter', 'price' => '$19', 'period' => '/mo', 'features' => ['5 projects', 'Email support'], 'buttonLabel' => 'Start', 'buttonHref' => '/register'],
    ],
    'yearly' => [
        ['name' => 'Starter', 'price' => '$190', 'period' => '/yr', 'features' => ['5 projects', 'Email support'], 'buttonLabel' => 'Start', 'buttonHref' => '/register'],
    ],
]" />

The cards are x-ui.card, the buttons x-ui.button and the dividers x-ui.separator, so a pricing page picks up whatever you have done to those components.

The switch is the tabs component

Monthly against yearly is two panels behind two buttons, which is exactly what tabs already does, keyboard handling and ARIA included. So none of these blocks ships a script. tabs takes its labels as an array and each panel as a named slot, the same pattern as the accordion in part 25, and a loop fills the slots:

<x-ui.tabs :tabs="['monthly' => $monthlyLabel, 'yearly' => $yearlyLabel]">
    @foreach (['monthly', 'yearly'] as $billing)
        <x-slot :name="'tab_' . $billing">
            {{-- the cards, written once, reading the price for $billing --}}
        </x-slot>
    @endforeach
</x-ui.tabs>

The cards or the comparison table are written once in the block and rendered in both panels, each reading the price for its period.

Putting the switch beside the heading

Three designs put the switch at the top right, level with the heading, with the plans in a full-width row underneath. The tabs component renders its button strip and its panels inside one wrapper, and consumer classes only reach the strip, so there is no way to move the strip without moving the panels too.

CSS has an answer: display: contents makes an element's box disappear, so its children join the parent's layout. The block's grid applies it to the tabs wrapper:

<div class="grid grid-cols-1 md:grid-cols-[1fr_auto] md:items-end
            [&>[data-ui-tabs]]:contents md:[&_[role=tabpanel]]:col-span-2">

With the wrapper gone from the layout, the tab strip becomes a grid item and sits in the second column beside the heading, and each panel spans both columns on the next row. The tabs component still owns the behaviour and never knew its wrapper was dissolved.

Comparison tables on a phone

Six blocks are comparison tables on x-ui.table: plan columns across the top, feature rows grouped by category, and a check, an empty cell or a value in each cell. A value of true draws a check with a screen-reader "Included", false or null leaves the cell empty, and a string prints as written.

On a phone, a four-plan table with a label column does not fit. The Relume mobile frames put each feature's name on its own full-width row above its values, so each feature renders as two rows: the label cell is hidden md:table-cell, and an extra md:hidden row carries the label on small screens. Category headings needed the same split. A colspan that counts the label column leaves an empty phantom column on mobile, where that column is hidden, so the heading row ends in a desktop-only empty cell instead.

mo/$49

On the Arabic preview, every price read "mo/$49". The price and its period are separate spans, and in a right-to-left paragraph the bidi algorithm reorders the neutral / and the $ around them. A price is a number with a unit, which reads left to right in Arabic too, so each one now sits in its own <span dir="ltr">. The cards still mirror, with the price block on the right, and the price itself reads "$49/mo" in both languages.

Shipping all four batches

Gallery, contact, FAQ and pricing went out as four pull requests stacked on top of each other, each with only its own blocks, its own regenerated registry index and its own Arabic strings, so every branch passed the registry-sync test on its own. They were squash-merged in order, and each next branch was rebased onto main before merging so it carried only its own commit. v0.7.0 tagged the result: 41 components and 78 blocks.

Where it is

composer require --dev safi/laralcn-ui
php artisan ui:init
php artisan ui:add-block pricing-16

Previews: https://laralcn-ui.abdulkadersafi.com/blocks, Arabic under /ar/blocks. Release notes: https://github.com/Abdulkader-Safi/LaralCN-UI/releases/tag/v0.7.0. MIT licensed.

Next: hero and auth blocks, then dashboards.

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

Every entry on this project

26 build notes, in order

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

Read the series →

FAQ

Frequently asked questions

Do the pricing blocks need JavaScript for the monthly/yearly switch?

No script of their own. The switch is the library's tabs component, which carries its own small inline script.

How do I mark a plan as included in a comparison table?

In a feature's values, pass true for a check, false or null for an empty cell, or a string such as "Unlimited".

Why do prices sit in a dir="ltr" span?

So Arabic pages show "$49/mo" instead of "mo/$49". A price reads left to right in both languages, while the card around it still mirrors.

Can I load plans from the database?

Yes. plans is a plain array, so map your models into the plan shape in the controller and pass it in.

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 →