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
import { HkCard } from "@celestia-island/hikari";
use hikari_components::*; use hikari_components::prelude::*;
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.
The last release went out twelve minutes ago.
The header slot replaces the title entirely.
The last release went out twelve minutes ago.
The header slot replaces the title entirely.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { HkCard } from "@celestia-island/hikari";
import { HkButton } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const column: CSSProperties = { display: "grid", gap: "16px", maxWidth: "360px" };
export default () => (
<div style={column}>
<HkCard
title="Deployment"
v-slots={{
default: () => <p>The last release went out twelve minutes ago.</p>,
footer: () => <HkButton size="sm" variant="secondary">View log</HkButton>,
}}
/>
<HkCard
v-slots={{
header: () => <strong>Custom header</strong>,
default: () => <p>The header slot replaces the title entirely.</p>,
}}
/>
</div>
);
rsx! {
div { style: "display:grid;gap:16px;max-width:360px",
Card {
title: Some("Deployment".to_string()),
footer: Some(rsx! { p { "View log" } }),
p { "The last release went out twelve minutes ago." }
}
Card {
header: Some(rsx! { strong { "Custom header" } }),
p { "The header slot replaces the title entirely." }
}
}
}
import { HkCard } from "@celestia-island/hikari";
import { HkButton } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const column: CSSProperties = { display: "grid", gap: "16px", maxWidth: "360px" };
export default () => (
<div style={column}>
<HkCard
title="Deployment"
v-slots={{
default: () => <p>The last release went out twelve minutes ago.</p>,
footer: () => <HkButton size="sm" variant="secondary">View log</HkButton>,
}}
/>
<HkCard
v-slots={{
header: () => <strong>Custom header</strong>,
default: () => <p>The header slot replaces the title entirely.</p>,
}}
/>
</div>
);rsx! {
div { style: "display:grid;gap:16px;max-width:360px",
Card {
title: Some("Deployment".to_string()),
footer: Some(rsx! { p { "View log" } }),
p { "The last release went out twelve minutes ago." }
}
Card {
header: Some(rsx! { strong { "Custom header" } }),
p { "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.
The body sits on its own padding.
Content runs edge to edge.
The body sits on its own padding.
Content runs edge to edge.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { HkCard } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const column: CSSProperties = { display: "grid", gap: "16px", maxWidth: "360px" };
export default () => (
<div style={column}>
<HkCard title="Default inset">
<p>The body sits on its own padding.</p>
</HkCard>
<HkCard title="No inset" padded={false}>
<p>Content runs edge to edge.</p>
</HkCard>
<HkCard title="Wide inset" padding="lg">
<p>Roomy content.</p>
</HkCard>
</div>
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
rsx! {
div { style: "display:grid;gap:16px;max-width:360px",
Card { title: Some("Default inset".to_string()),
p { "The body sits on its own padding." }
}
Card {
title: Some("No inset".to_string()),
padded: false,
p { "Content runs edge to edge." }
}
Card {
title: Some("Wide inset".to_string()),
padding: Some(hikari_components::utils::HkPad::Lg),
p { "Roomy content." }
}
}
}
import { HkCard } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const column: CSSProperties = { display: "grid", gap: "16px", maxWidth: "360px" };
export default () => (
<div style={column}>
<HkCard title="Default inset">
<p>The body sits on its own padding.</p>
</HkCard>
<HkCard title="No inset" padded={false}>
<p>Content runs edge to edge.</p>
</HkCard>
<HkCard title="Wide inset" padding="lg">
<p>Roomy content.</p>
</HkCard>
</div>
);rsx! {
div { style: "display:grid;gap:16px;max-width:360px",
Card { title: Some("Default inset".to_string()),
p { "The body sits on its own padding." }
}
Card {
title: Some("No inset".to_string()),
padded: false,
p { "Content runs edge to edge." }
}
Card {
title: Some("Wide inset".to_string()),
padding: Some(hikari_components::utils::HkPad::Lg),
p { "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.
Hover or focus it to see the border emphasis.
Hover or focus it to see the border emphasis.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { HkCard } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const column: CSSProperties = { display: "grid", gap: "16px", maxWidth: "360px" };
const body: CSSProperties = { maxHeight: "120px" };
export default () => (
<div style={column}>
<HkCard title="Scrollable" scrollable style={body}>
<p>Line one.</p>
<p>Line two.</p>
<p>Line three.</p>
<p>Line four.</p>
<p>Line five.</p>
<p>Line six.</p>
</HkCard>
<HkCard title="Hoverable" hoverable>
<p>Hover or focus it to see the border emphasis.</p>
</HkCard>
</div>
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
rsx! {
div { style: "display:grid;gap:16px;max-width:360px",
div { style: "max-height:120px",
Card { title: Some("Scrollable".to_string()), scrollable: true,
p { "Line one." }
p { "Line two." }
p { "Line three." }
p { "Line four." }
p { "Line five." }
p { "Line six." }
}
}
Card { title: Some("Hoverable".to_string()), hoverable: true,
p { "Hover or focus it to see the border emphasis." }
}
}
}
import { HkCard } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const column: CSSProperties = { display: "grid", gap: "16px", maxWidth: "360px" };
const body: CSSProperties = { maxHeight: "120px" };
export default () => (
<div style={column}>
<HkCard title="Scrollable" scrollable style={body}>
<p>Line one.</p>
<p>Line two.</p>
<p>Line three.</p>
<p>Line four.</p>
<p>Line five.</p>
<p>Line six.</p>
</HkCard>
<HkCard title="Hoverable" hoverable>
<p>Hover or focus it to see the border emphasis.</p>
</HkCard>
</div>
);rsx! {
div { style: "display:grid;gap:16px;max-width:360px",
div { style: "max-height:120px",
Card { title: Some("Scrollable".to_string()), scrollable: true,
p { "Line one." }
p { "Line two." }
p { "Line three." }
p { "Line four." }
p { "Line five." }
p { "Line six." }
}
}
Card { title: Some("Hoverable".to_string()), hoverable: true,
p { "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.
A press on any part of the card reaches this handler.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { ref } from "vue";
import { HkCard } from "@celestia-island/hikari";
export default () => {
const opens = ref(0);
return (
<div
role="button"
tabindex="0"
onKeydown={(event: KeyboardEvent) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
opens.value += 1;
}
}}
>
<HkCard
title="Open me"
hoverable
onClick={() => {
opens.value += 1;
}}
>
<p>
Opened {opens.value} {opens.value === 1 ? "time" : "times"}.
</p>
</HkCard>
</div>
);
};
rsx! {
Card {
title: Some("Open me".to_string()),
hoverable: true,
onclick: Some(EventHandler::new(|_event: MouseEvent| {})),
p { "A press on any part of the card reaches this handler." }
}
}
import { ref } from "vue";
import { HkCard } from "@celestia-island/hikari";
export default () => {
const opens = ref(0);
return (
<div
role="button"
tabindex="0"
onKeydown={(event: KeyboardEvent) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
opens.value += 1;
}
}}
>
<HkCard
title="Open me"
hoverable
onClick={() => {
opens.value += 1;
}}
>
<p>
Opened {opens.value} {opens.value === 1 ? "time" : "times"}.
</p>
</HkCard>
</div>
);
};rsx! {
Card {
title: Some("Open me".to_string()),
hoverable: true,
onclick: Some(EventHandler::new(|_event: MouseEvent| {})),
p { "A press on any part of the card reaches this handler." }
}
}
API
Vue
Props
Emits
Rust
Props — 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.