Skip to content
0

Card ​

useCard(options) creates an <article class="card"> with optional header, body and footer. cardClass(options) returns the classes for SSR markup.

Demo ​

ts
import { useCard } from "@katanakit/ui";

grid.append(
  useCard({ title: "Revenue", children: ["$12,400"], footer: "Updated 5 min ago" }),
  useCard({ title: "Churn", children: ["2.1%"], elevated: true }),
);

Contract

Every component in the kit follows one shape. Pure builders return a class string and touch nothing; factories build a DOM element and need a browser.

SurfaceImportNeeds a DOM
Pure class buildercardClassNo — safe during SSR
Element factoryuseCardYes — throws with a pointer to the pure surface
// Server and templates — pure
<div class={ cardClass({ /* … */ }) }></div>

// Browser — imperative
document.body.append(useCard({ /* … */ }));

Class names are unprefixed. The root class is card, not kk-card, and every component rule is wrapped in @layer katana.

That matters because these names collide 1:1 with daisyUI. Unlayered CSS always beats layered CSS regardless of specificity or import order, so loading both is deterministic instead of "whoever came last". See why.

Options ​

OptionTypeDefaultNotes
titlestring—Renders .card__header + title.
childrenArray<Node | string>[]Appended to .card__body.
footerstring—Renders .card__footer.
elevatedbooleanfalseReplaces the border with a shadow.

Composition

Cards are plain containers: put any node (table, form, chart) in children. The kit never owns the data — bind it to Safe Results from katanakit-js.

Released under the MIT License.