vael-ui v0.5.7

Data display

Layout

Card

A bordered container that groups related content, with an optional title and actions. Use it for a summary, a setting or a link to more.

Install

import { Card } from 'vael-ui'

Playground

Card content

Placement, behaviour and animation

Usage
<script setup lang="ts">
import { Card } from 'vael-ui'
</script>

<template>
  <Card>Card content</Card>
</template>

Props

NameTypeDefaultDescription
titlestringDefault header title; the #header slot replaces it.
descriptionstringDefault header description; the #header slot replaces it.
asstring'div'Root tag; use 'a' or 'button' for a fully interactive card.
interactivebooleanfalseAdds a hover and press affordance. Always on when as is 'a' or 'button'.
motionCardMotionHow it moves: its parts' appearance ({ initial: { root: { opacity: 0, y: 8 } } }) and, on an interactive card, its press states ({ states: { active: { root: { scale: '0.98' } } } }). false turns its own animation off.
uiPartial<Record<'root' | 'header' | 'title' | 'description' | 'body' | 'footer', UiPartValue>>Class and style overrides for each part.

Events

No events.

Slots

NameTypeDescription
defaultanyCard body content.
headeranyReplaces the default title/description header.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

Card: its parts' appearance, and press states on an interactive card.

<Card
  :motion="{ states: { active: { root: { scale: 1.04 } } } }"
/>
NameTypeDescription
initialexitrootheadertitledescriptionbodyfooterSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
statesactivehoverfocusSets values per part that hold while a state is on. An array is a set of keyframes that plays once as the state turns on, such as a shake on invalid.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

It has no keyboard interaction of its own.

  • Card renders a <div> with no role and no keyboard handling.
  • For a clickable card, set as="a" (with an href) or as="button", so it is focusable and works with the keyboard. interactive on its own adds only the hover and press look.
  • The title prop renders an <h3>. Use the #header slot when your page outline needs another heading level.
  • The header and footer are plain <div>s, so they add no landmarks.