Card

Card

HkCard is the canonical surface: a bordered, blur-backed panel that groups related content under an optional header and an optional footer. It owns the library's container-padding token, and with scrollable its body becomes the one scroll region of the card, so a host never nests its own scroll layer.

  • A short status line or a count that labels a row is a Badge, not a card.
  • An empty surface that invites the first item — a dashed "add one more" — is a tile rather than a card.
  • The card is presentation only; a click handler on the whole surface is the host's, see the interaction note on this page.

Import

tsx
1
import { HkCard } from "@celestia-island/hikari";
rust
1
2
use hikari_components::*;          // Card, HkPad
use hikari_components::prelude::*; // rsx!, VNode, EventHandler, MouseEvent

The Rust form is a plain function, Card(CardProps { … }). Inside rsx! every prop may be omitted, an omitted prop takes its default, and the component's children fill the body slot.

Header, body and footer

title renders an h3.hk-card-title inside the header; the #header slot replaces that header content wholesale and wins over title. The default slot is the body. The #footer slot renders only when it is given, and it is separated by its own top border.

Deployment

The last release went out twelve minutes ago.

Custom header

The header slot replaces the title entirely.

Padding

The body's inset reads the shared --hk-pad token, defaulting to the card's historical 16px. The padding prop maps a named step onto that token — none, xs, sm, md, lg — and padded={false} drops the inset altogether (the hk-card-body-unpadded class). An explicit padding still applies when padded is false, because the unpadded rule reads the same token with 0 as its fallback.

The Rust mirror takes the same scale as Option<HkPad>; None keeps the historical look, exactly like Vue's unset prop. HkPad lives in the crate's utils module rather than the prelude, so the sample spells it out as hikari_components::utils::HkPad.

Default inset

The body sits on its own padding.

No inset

Content runs edge to edge.

Wide inset

Roomy content.

Scrollable body and hover

With scrollable the card becomes a column: header and footer keep their natural height, the body fills the rest and scrolls, and the content padding moves inside the scroll region so the scrollbar hugs the card edge. The card needs a height from its context — a grid stretch, a max-height, or a flex parent — otherwise there is nothing to scroll. In the Rust mirror that box has to be the wrapper: CardProps declares no style field, so the card renders no height of its own and the sample gives the height to the surrounding div.

hoverable adds the pointer cursor and the border emphasis: the border brightens, then lightens again while pressed, and the card takes a visible focus ring when it is focusable. No transform is involved, so a hover never displaces its neighbours.

Scrollable

Line one.

Line two.

Line three.

Line four.

Line five.

Line six.

Hoverable

Hover or focus it to see the border emphasis.

Interaction

The card emits click for a press anywhere on the surface, which is how a hoverable card is made to behave as a whole-surface target. The handler says nothing about focusability, and the component takes no tabindex prop — attributes fall through to the root <div>, but Vue's JSX typings only accept a prop that the component declares, so a wrapper element is the portable way to put the card in the tab order. The hoverable style is the visual half of that contract.

The Rust mirror reports the same press through onclick. Snapshots never run an event handler, so only the Vue sample below is interactive.

Open me

Opened 0 times.

API

Vue

Props

NameTypeDefaultRequired
titleStringundefined—
hoverableBooleanfalse—
paddedBooleantrue—
paddingString as PropType<HkPad>undefined—
scrollableBooleanfalse—
classString""—

Emits

EventPayload
clickMouseEvent

Rust

Props — Card

PropTypeDefaultDescription
titleOption<String>NoneHeader title (h3.hk-card-title).
hoverableboolfalseHover lift (hk-card-hoverable).
paddedbooltrueBody padding (Vue default true; false emits hk-card-body-unpadded).
paddingOption<HkPad>NoneShared container-padding override (--hk-pad; see utils::pad).
scrollableboolfalseTurn the body into a scroll region (hk-card-scrollable).
classString""—
headerOption<Element>NoneHeader slot content (wins over title).
footerOption<Element>NoneFooter slot content.
childrenElement(empty)—
onclickOption<EventHandler<MouseEvent>>NoneFired on a click anywhere on the card.

Accessibility

  • The card is a plain <div>: it has no landmark role and no accessible name. title is a real h3, so it does join the heading outline — keep the levels sensible relative to the page's own headings, and use the #header slot when the card's caption should not be a heading.
  • A hoverable card looks clickable, so it must be operable from the keyboard too. The card declares no tabindex prop, so the portable shape is a focusable wrapper (role="button" and tabindex="0" with Enter / Space handling) around the card, or a button inside the card for the real action. The component ships the focus ring on a card that is itself focusable, but no key handling.
  • The scrollable body is the scroll container; a keyboard user reaches it only when it is focusable, so give it tabindex="0" when its content must be scrollable without a pointer.

Related components

  • Badge — the small tone-coded label that usually sits in a card header.
  • Tag — a removable chip, for filters and selections inside a card.
  • HkAvatar — the identity chip for a card's owner row.