AppCard
A collection card with media, a favorite, and an optional action.
Creative
Orbit Studio
Creative
Your next idea starts here.
Source
<script lang="ts">
import 'portal-bits/styles.css';
import 'portal-bits/tokens.css';
import type { Snippet } from 'svelte';
let { children }: { children: Snippet } = $props();
</script>
{@render children()}
<script lang="ts">
import AppCardExample from './AppCardExample.svelte';
</script>
<AppCardExample media={"image"} spotlight={false} action={false} />
<script lang="ts">
import { AppCard } from 'portal-bits';
let {
media = 'image',
spotlight = false,
action = false,
}: { media?: 'image' | 'fallback'; spotlight?: boolean; action?: boolean } = $props();
let favorite = $state(false);
// A synthetic poster as inline SVG data. Pass your own image URL as `image` instead.
const poster = `data:image/svg+xml,${encodeURIComponent(
'<svg xmlns="http://www.w3.org/2000/svg" width="640" height="400" viewBox="0 0 640 400"><rect width="640" height="400" fill="#c5d4f6"/><circle cx="370" cy="170" r="120" fill="none" stroke="#263864" stroke-width="2" opacity=".45"/><text x="32" y="178" fill="#263864" font-family="Arial,sans-serif" font-size="66" font-weight="500">ORBIT</text></svg>',
)}`;
</script>
<div class="narrow">
<AppCard
title="Orbit Studio"
category="Creative"
description="Your next idea starts here."
image={media === 'image' ? poster : undefined}
imageAlt={media === 'image' ? 'Orbit geometric poster' : ''}
{spotlight}
href={action ? '#open-orbit' : undefined}
bind:favorite
/>
</div>
<style>
.narrow {
max-width: 360px;
}
</style>
API reference
These tables list the props and snippets that AppCard declares. Attributes passed through to an element or primitive are listed under Forwarded attributes, not here.
Props
| Name | Type | Default | Required | Binding | Description |
|---|---|---|---|---|---|
title | string | None | Yes | One-way | The app name. It is the heading and names the favorite control. |
category | string | None | Yes | One-way | The category shown under the title, and in the badge unless `spotlight` is on. |
description | string | None | No | One-way | Supporting text. It is hidden when `spotlight` is on. |
image | string | None | No | One-way | The cover image URL. A failed load shows the title initial. |
imageAlt | string | "" | No | One-way | Alt text for the cover image. |
favorite | boolean | false | No | Bindable | The favorite state of the heart control. |
spotlight | boolean | false | No | One-way | Shows a Featured badge and hides the description. |
href | string | None | No | One-way | Renders an Explore link button. Ignored when `action` is given. |
Snippets
| Name | Type | Default | Required | Binding | Description |
|---|---|---|---|---|---|
action | Snippet | None | No | One-way | Replaces the Explore link button. |
children | Snippet | None | No | One-way | Extra content below the description. |
Forwarded attributes
None. AppCard forwards no attributes.
No data attributes are documented as stable.
Limits
- The heading is always an `h3`.
- The favorite control is separate from the card. The card has no click handler.
- The "Featured" and "Explore" strings are English text inside the component.