PricingCards
PricingCards lays out plans with their prices, features and actions. your app supplies the plans and decides what choosing one does. prices are display strings, so you control currency and billing wording.
Personal
Free
- Your own reading shelves
Shared
$5 per month
- Shared shelves
Read with a small group.
No plan selected
usage
svelte
<script>
import { PricingCards } from '@ciabi/loafkit-ui';
let selected = $state('No plan selected');
</script>
{#snippet personalAction()}
<button type="button" onclick={() => selected = 'Personal'}>Choose Personal</button>
{/snippet}
{#snippet sharedAction()}
<button type="button" onclick={() => selected = 'Shared'}>Choose Shared</button>
{/snippet}
<PricingCards plans={[
{ id: 'personal', name: 'Personal', price: 'Free', features: [{ name: 'Your own reading shelves' }], actions: personalAction },
{ id: 'shared', name: 'Shared', price: '$5', billing: 'per month', features: [{ name: 'Shared shelves', description: 'Read with a small group.' }], actions: sharedAction }
]} />
<p role="status">{selected}</p>composition
- PricingCards
- plans
- actions()(optional)
- features
- content()(optional)
- plans
plan shape
PricingPlan and Feature exist in the source component but aren’t root type exports; you can let this inline data infer its type.
configure a plan before choosing it
reading group
$5 per month
- shared reading shelves
svelte
<script lang="ts">
import { PricingCards, Field, FieldLabel, Input } from '@ciabi/loafkit-ui';
let readingGroup = $state('');
let chosenGroup = $state('');
</script>
{#snippet groupDetails()}
<Field><FieldLabel htmlFor="plan-group-name">reading group name</FieldLabel><Input id="plan-group-name" bind:value={readingGroup} placeholder="Saturday readers" /></Field>
{/snippet}
{#snippet groupAction()}
<button type="button" disabled={!readingGroup.trim()} onclick={() => chosenGroup = readingGroup.trim()}>choose group plan</button>
{/snippet}
<PricingCards plans={[{id:'reading-group',name:'reading group',price:'$5',billing:'per month',features:[{name:'shared reading shelves'}],content:groupDetails,actions:groupAction}]} />
{#if chosenGroup}<p role="status">chosen for {chosenGroup}</p>{/if}API reference
PricingCards
PricingPlan
one plan supplied to PricingCards.
id-
unique plan key.
name-
the visible plan name.
description-
supporting plan text.
price-
display price, including your chosen currency wording.
billing-
billing label shown alongside a supplied price.
features-
the included features.
actions-
app-owned actions before the features.
content-
extra content after the features.
Feature
one feature within a PricingPlan.
name-
feature name.
description-
supporting feature detail.