الأسعار
pricing-06
جدول مقارنة لأربع خطط بلا حدود، رؤوس الخطط في المنتصف وصفوف الميزات مجمعة حسب الفئة وصف أزرار في النهاية.
{{--
Every piece of content is a prop, so you can drive this section from a CMS.
A plan is ['name', 'price', 'period', 'description', 'buttonLabel',
'buttonHref']; its button shows above and again below the table. Each
feature row carries one value per plan, in plan order: true draws a
check, false or null leaves the cell empty, and a string ('10',
'Unlimited') is printed as is.
<x-ui.blocks.pricing-06
heading="Compare plans"
:plans="[
['name' => 'Starter', 'price' => '$9', 'period' => '/mo', 'buttonHref' => '/register'],
['name' => 'Team', 'price' => '$29', 'period' => '/mo', 'buttonHref' => '/register?plan=team'],
['name' => 'Scale', 'price' => '$99', 'period' => '/mo', 'buttonHref' => '/contact'],
]"
:categories="[
['title' => 'Usage', 'features' => [
['label' => 'Seats', 'values' => ['3', '20', 'Unlimited']],
['label' => 'Custom domains', 'values' => [false, true, true]],
]],
]"
/>
--}}
@props([
'tagline' => 'Tagline',
'heading' => 'Pricing plan',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'plans' => [
[
'name' => 'Free',
'price' => '$0',
'period' => '/mo',
'description' => 'Lorem ipsum dolor sit amet',
'buttonLabel' => 'Get started',
'buttonHref' => null,
],
[
'name' => 'Basic',
'price' => '$19',
'period' => '/mo',
'description' => 'Lorem ipsum dolor sit amet',
'buttonLabel' => 'Get started',
'buttonHref' => null,
],
[
'name' => 'Business',
'price' => '$29',
'period' => '/mo',
'description' => 'Lorem ipsum dolor sit amet',
'buttonLabel' => 'Get started',
'buttonHref' => null,
],
[
'name' => 'Enterprise',
'price' => '$49',
'period' => '/mo',
'description' => 'Lorem ipsum dolor sit amet',
'buttonLabel' => 'Get started',
'buttonHref' => null,
],
],
'categories' => [
[
'title' => 'Feature Category',
'features' => [
['label' => 'Feature text goes here', 'values' => ['10', '10', '25', 'Unlimited']],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, false, true]],
],
],
[
'title' => 'Feature Category',
'features' => [
['label' => 'Feature text goes here', 'values' => ['10', '10', '25', 'Unlimited']],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, false, true]],
],
],
[
'title' => 'Feature Category',
'features' => [
['label' => 'Feature text goes here', 'values' => ['10', '10', '25', 'Unlimited']],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, false, true]],
],
],
],
'includedLabel' => 'Included',
'excludedLabel' => 'Not included',
])
@php
// The label column is hidden on phones, where each feature gets a
// full-width row of its own above its values. A colspan wider than the
// visible columns would add an empty column, so phones span one less.
$span = count($plans) + 1;
@endphp
<section {{ $attributes->merge(['class' => 'bg-background px-[5%] py-16 text-foreground md:py-24 lg:py-28']) }}>
<div class="mx-auto max-w-7xl">
<div class="mx-auto mb-12 max-w-3xl text-center md:mb-20">
<p class="mb-3 font-semibold md:mb-4">{{ $tagline }}</p>
<h2 class="mb-5 text-4xl font-bold leading-[1.2] md:mb-6 md:text-5xl">{{ $heading }}</h2>
<p class="md:text-lg">{{ $description }}</p>
</div>
<x-ui.table class="table-fixed text-xs md:text-base">
<thead>
<tr>
<td class="hidden md:table-cell md:w-1/3"></td>
@foreach ($plans as $plan)
<th scope="col" class="px-1 pb-6 text-center align-top font-normal md:px-4 md:pb-8">
<div class="flex flex-col items-center gap-1 md:gap-2">
<span class="text-sm font-bold md:text-xl">{{ $plan['name'] ?? '' }}</span>
<span class="font-bold">
<span class="text-base leading-[1.2] md:text-5xl">{{ $plan['price'] ?? '' }}</span><span
class="text-xs md:text-2xl">{{ $plan['period'] ?? '' }}</span>
</span>
<span class="md:mt-2">{{ $plan['description'] ?? '' }}</span>
<x-ui.button :href="$plan['buttonHref'] ?? null" size="lg"
class="mt-3 h-auto min-h-8 w-full whitespace-normal px-1 py-1.5 text-xs md:mt-4 md:h-10 md:px-6 md:text-sm">{{ $plan['buttonLabel'] ?? 'Get started' }}</x-ui.button>
</div>
</th>
@endforeach
</tr>
</thead>
@foreach ($categories as $category)
<tbody>
<tr class="md:hidden">
<th scope="colgroup" colspan="{{ $span - 1 }}"
class="pb-4 pt-6 text-start text-sm font-bold md:pt-8 md:text-xl">{{ $category['title'] ?? '' }}</th>
</tr>
<tr class="hidden md:table-row">
<th scope="colgroup" colspan="{{ $span }}"
class="pb-4 pt-6 text-start text-sm font-bold md:pt-8 md:text-xl">{{ $category['title'] ?? '' }}</th>
</tr>
@foreach ($category['features'] ?? [] as $feature)
<tr class="md:hidden">
<td colspan="{{ $span - 1 }}" class="px-2 py-2">{{ $feature['label'] ?? '' }}</td>
</tr>
<tr>
<th scope="row" class="hidden px-4 py-4 text-start font-normal md:table-cell">
{{ $feature['label'] ?? '' }}</th>
@foreach ($feature['values'] ?? [] as $value)
<td class="px-2 py-2 text-center md:py-4">
@if ($value === true)
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" class="mx-auto size-5 md:size-6"
aria-hidden="true">
<path d="M20 6 9 17l-5-5" />
</svg>
<span class="sr-only">{{ $includedLabel }}</span>
@elseif ($value === false || $value === null)
<span class="sr-only">{{ $excludedLabel }}</span>
@else
<span class="font-semibold">{{ $value }}</span>
@endif
</td>
@endforeach
</tr>
@endforeach
</tbody>
@endforeach
<tfoot>
<tr>
<td class="hidden md:table-cell"></td>
@foreach ($plans as $plan)
<td class="px-1 pt-6 md:px-4 md:pt-8">
<x-ui.button :href="$plan['buttonHref'] ?? null" size="lg"
class="h-auto min-h-8 w-full whitespace-normal px-1 py-1.5 text-xs md:h-10 md:px-6 md:text-sm">{{ $plan['buttonLabel'] ?? 'Get started' }}</x-ui.button>
</td>
@endforeach
</tr>
</tfoot>
</x-ui.table>
</div>
</section>
التثبيت
php artisan ui:add-block pricing-06
أمر واحد يثبّت ملف Blade الخاص بالقالب وكل مكوّن يعتمد عليه. اعرضه في تخطيطك كالتالي
<x-ui.blocks.pricing-06
/>.
1. ثبّت المكونات المطلوبة
php artisan ui:add button table
2. حزم خارجية
- composer:
gehrisandro/tailwind-merge-laravel
3.
انسخ كود القالب إلى
resources/views/components/ui/
resources/views/components/ui/blocks/pricing-06.blade.php
{{--
Every piece of content is a prop, so you can drive this section from a CMS.
A plan is ['name', 'price', 'period', 'description', 'buttonLabel',
'buttonHref']; its button shows above and again below the table. Each
feature row carries one value per plan, in plan order: true draws a
check, false or null leaves the cell empty, and a string ('10',
'Unlimited') is printed as is.
<x-ui.blocks.pricing-06
heading="Compare plans"
:plans="[
['name' => 'Starter', 'price' => '$9', 'period' => '/mo', 'buttonHref' => '/register'],
['name' => 'Team', 'price' => '$29', 'period' => '/mo', 'buttonHref' => '/register?plan=team'],
['name' => 'Scale', 'price' => '$99', 'period' => '/mo', 'buttonHref' => '/contact'],
]"
:categories="[
['title' => 'Usage', 'features' => [
['label' => 'Seats', 'values' => ['3', '20', 'Unlimited']],
['label' => 'Custom domains', 'values' => [false, true, true]],
]],
]"
/>
--}}
@props([
'tagline' => 'Tagline',
'heading' => 'Pricing plan',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'plans' => [
[
'name' => 'Free',
'price' => '$0',
'period' => '/mo',
'description' => 'Lorem ipsum dolor sit amet',
'buttonLabel' => 'Get started',
'buttonHref' => null,
],
[
'name' => 'Basic',
'price' => '$19',
'period' => '/mo',
'description' => 'Lorem ipsum dolor sit amet',
'buttonLabel' => 'Get started',
'buttonHref' => null,
],
[
'name' => 'Business',
'price' => '$29',
'period' => '/mo',
'description' => 'Lorem ipsum dolor sit amet',
'buttonLabel' => 'Get started',
'buttonHref' => null,
],
[
'name' => 'Enterprise',
'price' => '$49',
'period' => '/mo',
'description' => 'Lorem ipsum dolor sit amet',
'buttonLabel' => 'Get started',
'buttonHref' => null,
],
],
'categories' => [
[
'title' => 'Feature Category',
'features' => [
['label' => 'Feature text goes here', 'values' => ['10', '10', '25', 'Unlimited']],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, false, true]],
],
],
[
'title' => 'Feature Category',
'features' => [
['label' => 'Feature text goes here', 'values' => ['10', '10', '25', 'Unlimited']],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, false, true]],
],
],
[
'title' => 'Feature Category',
'features' => [
['label' => 'Feature text goes here', 'values' => ['10', '10', '25', 'Unlimited']],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, false, true]],
],
],
],
'includedLabel' => 'Included',
'excludedLabel' => 'Not included',
])
@php
// The label column is hidden on phones, where each feature gets a
// full-width row of its own above its values. A colspan wider than the
// visible columns would add an empty column, so phones span one less.
$span = count($plans) + 1;
@endphp
<section {{ $attributes->merge(['class' => 'bg-background px-[5%] py-16 text-foreground md:py-24 lg:py-28']) }}>
<div class="mx-auto max-w-7xl">
<div class="mx-auto mb-12 max-w-3xl text-center md:mb-20">
<p class="mb-3 font-semibold md:mb-4">{{ $tagline }}</p>
<h2 class="mb-5 text-4xl font-bold leading-[1.2] md:mb-6 md:text-5xl">{{ $heading }}</h2>
<p class="md:text-lg">{{ $description }}</p>
</div>
<x-ui.table class="table-fixed text-xs md:text-base">
<thead>
<tr>
<td class="hidden md:table-cell md:w-1/3"></td>
@foreach ($plans as $plan)
<th scope="col" class="px-1 pb-6 text-center align-top font-normal md:px-4 md:pb-8">
<div class="flex flex-col items-center gap-1 md:gap-2">
<span class="text-sm font-bold md:text-xl">{{ $plan['name'] ?? '' }}</span>
<span class="font-bold">
<span class="text-base leading-[1.2] md:text-5xl">{{ $plan['price'] ?? '' }}</span><span
class="text-xs md:text-2xl">{{ $plan['period'] ?? '' }}</span>
</span>
<span class="md:mt-2">{{ $plan['description'] ?? '' }}</span>
<x-ui.button :href="$plan['buttonHref'] ?? null" size="lg"
class="mt-3 h-auto min-h-8 w-full whitespace-normal px-1 py-1.5 text-xs md:mt-4 md:h-10 md:px-6 md:text-sm">{{ $plan['buttonLabel'] ?? 'Get started' }}</x-ui.button>
</div>
</th>
@endforeach
</tr>
</thead>
@foreach ($categories as $category)
<tbody>
<tr class="md:hidden">
<th scope="colgroup" colspan="{{ $span - 1 }}"
class="pb-4 pt-6 text-start text-sm font-bold md:pt-8 md:text-xl">{{ $category['title'] ?? '' }}</th>
</tr>
<tr class="hidden md:table-row">
<th scope="colgroup" colspan="{{ $span }}"
class="pb-4 pt-6 text-start text-sm font-bold md:pt-8 md:text-xl">{{ $category['title'] ?? '' }}</th>
</tr>
@foreach ($category['features'] ?? [] as $feature)
<tr class="md:hidden">
<td colspan="{{ $span - 1 }}" class="px-2 py-2">{{ $feature['label'] ?? '' }}</td>
</tr>
<tr>
<th scope="row" class="hidden px-4 py-4 text-start font-normal md:table-cell">
{{ $feature['label'] ?? '' }}</th>
@foreach ($feature['values'] ?? [] as $value)
<td class="px-2 py-2 text-center md:py-4">
@if ($value === true)
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" class="mx-auto size-5 md:size-6"
aria-hidden="true">
<path d="M20 6 9 17l-5-5" />
</svg>
<span class="sr-only">{{ $includedLabel }}</span>
@elseif ($value === false || $value === null)
<span class="sr-only">{{ $excludedLabel }}</span>
@else
<span class="font-semibold">{{ $value }}</span>
@endif
</td>
@endforeach
</tr>
@endforeach
</tbody>
@endforeach
<tfoot>
<tr>
<td class="hidden md:table-cell"></td>
@foreach ($plans as $plan)
<td class="px-1 pt-6 md:px-4 md:pt-8">
<x-ui.button :href="$plan['buttonHref'] ?? null" size="lg"
class="h-auto min-h-8 w-full whitespace-normal px-1 py-1.5 text-xs md:h-10 md:px-6 md:text-sm">{{ $plan['buttonLabel'] ?? 'Get started' }}</x-ui.button>
</td>
@endforeach
</tr>
</tfoot>
</x-ui.table>
</div>
</section>
الاستخدام
Every piece of content is a prop, so you can drive this section from a CMS. A plan is ['name', 'price', 'period', 'description', 'buttonLabel', 'buttonHref']; its button shows above and again below the table. Each feature row carries one value per plan, in plan order: true draws a check, false or null leaves the cell empty, and a string ('10', 'Unlimited') is printed as is.
<x-ui.blocks.pricing-06
heading="Compare plans"
:plans="[
['name' => 'Starter', 'price' => '$9', 'period' => '/mo', 'buttonHref' => '/register'],
['name' => 'Team', 'price' => '$29', 'period' => '/mo', 'buttonHref' => '/register?plan=team'],
['name' => 'Scale', 'price' => '$99', 'period' => '/mo', 'buttonHref' => '/contact'],
]"
:categories="[
['title' => 'Usage', 'features' => [
['label' => 'Seats', 'values' => ['3', '20', 'Unlimited']],
['label' => 'Custom domains', 'values' => [false, true, true]],
]],
]"
/>
الخصائص
كل خاصية مع قيمتها الافتراضية. مرّر أيًّا منها كسمة، واستخدم : لربط قيمة PHP.
@props([
'tagline' => 'Tagline',
'heading' => 'Pricing plan',
'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'plans' => [
[
'name' => 'Free',
'price' => '$0',
'period' => '/mo',
'description' => 'Lorem ipsum dolor sit amet',
'buttonLabel' => 'Get started',
'buttonHref' => null,
],
[
'name' => 'Basic',
'price' => '$19',
'period' => '/mo',
'description' => 'Lorem ipsum dolor sit amet',
'buttonLabel' => 'Get started',
'buttonHref' => null,
],
[
'name' => 'Business',
'price' => '$29',
'period' => '/mo',
'description' => 'Lorem ipsum dolor sit amet',
'buttonLabel' => 'Get started',
'buttonHref' => null,
],
[
'name' => 'Enterprise',
'price' => '$49',
'period' => '/mo',
'description' => 'Lorem ipsum dolor sit amet',
'buttonLabel' => 'Get started',
'buttonHref' => null,
],
],
'categories' => [
[
'title' => 'Feature Category',
'features' => [
['label' => 'Feature text goes here', 'values' => ['10', '10', '25', 'Unlimited']],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, false, true]],
],
],
[
'title' => 'Feature Category',
'features' => [
['label' => 'Feature text goes here', 'values' => ['10', '10', '25', 'Unlimited']],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, false, true]],
],
],
[
'title' => 'Feature Category',
'features' => [
['label' => 'Feature text goes here', 'values' => ['10', '10', '25', 'Unlimited']],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [true, true, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, true, true]],
['label' => 'Feature text goes here', 'values' => [false, false, false, true]],
],
],
],
'includedLabel' => 'Included',
'excludedLabel' => 'Not included',
])