enes

Card

A card is a container that groups content and actions about a single topic, and can optionally be selected.

Preview

FluentUI Svelte

5h ago · About us - Overview

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

A card is built out of the following components:

  • Card: The root component. It creates all the state, provides context to its parts and handles the selection.
  • CardPreview: The media shown at one edge of the card, with an optional logo overlaid on it.
  • CardHeader: The title of the card, with an optional image, description and action.
  • CardFooter: The actions shown at the bottom of the card.

Usage

<script>
	import { Card, CardPreview, CardHeader, CardFooter, Button } from 'fluentui-svelte';
</script>

{#snippet footerActions()}
	<Button>Like</Button>
	<Button appearance="standard">Share</Button>
{/snippet}

<Card orientation="vertical">
	<CardPreview logoSrc="/logo.png">
		<img src="/preview.png" alt="Preview" />
	</CardPreview>
	<CardHeader title="FluentUI Svelte" description="5h ago · About us - Overview" />
	<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
	<CardFooter action={footerActions} />
</Card>

Appearance

A card can have its background and borders styled for greater emphasis or to be subtle.

Filled

Outlined

Subtle

Orientation

A card lays its parts out horizontally by default. Set orientation to vertical to stack them instead.

Preview

Horizontal

The default orientation

Preview

Vertical

Stacks every part

Selection

A selectable card toggles its selection when clicked anywhere, and reports it through onSelectionChange. Set showFloatingAction to float a checkbox over the top right corner. A card cannot be selectable and a link at the same time.

Selectable card

Not selected

Header

The header takes a title, and optionally an image, a description and an action. A string title renders inside a heading; a snippet or a component receives the id the floating checkbox is labelled by. The action is not available on selectable cards.

FluentUI Svelte mentioned you

5h ago · About us - Overview

Preview

The preview holds the media of the card and rounds the corners it sits against. The logoSrc prop overlays a logo on the bottom left corner.

Preview

The footer renders the actions of the card at the bottom, spread across the available width.

FluentUI Svelte

5h ago · About us - Overview

Component Props (Card)

NameTypeDefaultDescription
ref bindableCardElementDOMType[Tag]The DOM reference of the card element.
as'div' | 'article' | 'section' | 'a''div'The DOM element to render.
orientation'horizontal' | 'vertical''horizontal'The axis the card lays its parts out on.
selectablebooleanfalseLets the user select the card by clicking anywhere on it.
showFloatingActionbooleanfalseFloats the selection checkbox over the top right corner of the card.
idstringThe id of the card element. Falls back to a generated one.
selected bindablebooleanfalseWhether the card is selected. Only available on selectable cards.
disabledbooleanfalseDisables the user interaction.
appearance'filled' | 'outlined' | 'subtle''filled'A card can have its background and borders styled for greater emphasis or to be subtle.
onSelectionChange(id: string, selected: boolean) => voidCalled with the id of the card whenever its selection changes.
HTML Attributes

Component Props (CardPreview)

NameTypeDefaultDescription
ref bindableHTMLDivElementThe DOM reference of the preview element.
logoSrcstringThe URL of the logo overlaid on the bottom left corner of the preview.
logoAltstring''The alternative text of the logo. Empty by default, which marks the logo as decorative.
childrenSnippetThe media to preview, usually an image.
HTMLAttributes<HTMLDivElement> without children

Component Props (CardHeader)

NameTypeDefaultDescription
ref bindableHTMLDivElementThe DOM reference of the header element.
titleSnippet | Component | stringThe title of the card. A snippet or a component receives the id the floating checkbox is labelled by.
imageSnippet | Component | stringThe image rendered before the title. A string is used as the `src` of an `<img>`.
imageAltstring''The alternative text of a string image. Empty by default, which marks the image as decorative.
descriptionSnippet | Component | stringA second line of text below the title.
actionSnippet | ComponentThe action rendered at the end of the header. Not available on selectable cards.
HTMLAttributes<HTMLDivElement> without children, title

Component Props (CardFooter)

NameTypeDefaultDescription
ref bindableHTMLDivElementThe DOM reference of the footer element.
actionSnippet | ComponentThe actions rendered inside the footer. Not available on selectable cards.
HTMLAttributes<HTMLDivElement> without children