ArticleCard
An editorial card with media, a title, and one link.
A field guide to small ideas
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 ArticleCardExample from './ArticleCardExample.svelte';
</script>
<ArticleCardExample media={"image"} actionLabel={"Read"} />
<script lang="ts">
import { ArticleCard } from 'portal-bits';
let {
media = 'image',
actionLabel = 'Read',
}: { media?: 'image' | 'fallback'; actionLabel?: 'Read' | 'Open' } = $props();
// 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="#e6ddd0"/><circle cx="370" cy="170" r="120" fill="none" stroke="#776749" stroke-width="2" opacity=".45"/><text x="32" y="178" fill="#776749" font-family="Arial,sans-serif" font-size="66" font-weight="500">field</text></svg>',
)}`;
</script>
<div class="narrow">
<ArticleCard
title="A field guide to small ideas"
href="#field-guide"
image={media === 'image' ? poster : undefined}
imageAlt={media === 'image' ? 'Geometric illustration' : ''}
{actionLabel}
/>
</div>
<style>
.narrow {
max-width: 360px;
}
</style>
API reference
These tables list the props and snippets that ArticleCard 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 heading. It is rendered as text, not HTML. |
href | string | None | Yes | One-way | The destination of the single action link. |
image | string | None | No | One-way | The media URL. A failed load keeps the media region with a placeholder. |
imageAlt | string | "" | No | One-way | Alt text for the media. Empty marks it decorative. |
actionLabel | string | Read | No | One-way | The action text. The link name is the action label followed by the title. |
headingLevel | 2 | 3 | 4 | 3 | No | One-way | The heading level of the title. |
Forwarded attributes
None. ArticleCard forwards no attributes.
No data attributes are documented as stable.
Limits
- One native link carries the whole action. The card has no nested buttons or click handler.
- Intrinsic height, image fitting, and the placeholder art are adaptations.