Clawscale

Card

A Card is a bounded surface that groups related content. Card list, Control card and Section build on it.

Usage#

import { Card } from "@clawscale/react";
<Card>1,204,331 rows loaded</Card>

Examples#

Basic#

A card adds padding and a surface color around any content.

orders_daily

Daily order snapshot from the sales warehouse. 1,204,331 rows, refreshed at 02:00 UTC.

import { Button, Card, H5 } from "@clawscale/react";

export default function CardBasic() {
  return (
    <Card style={{ maxWidth: 360 }}>
      <H5>orders_daily</H5>
      <p>Daily order snapshot from the sales warehouse. 1,204,331 rows, refreshed at 02:00 UTC.</p>
      <Button icon="th" text="Open table" />
    </Card>
  );
}

Interactive#

interactive adds hover styles and a pointer cursor. Pair it with onClick, and set selected on the chosen card.

orders_daily
1,204,331 rows
customers
88,412 rows
ledger_entries
14,602,118 rows
import { Card, H5 } from "@clawscale/react";
import { useState } from "react";

const DATASETS = [
  { name: "orders_daily", rows: "1,204,331 rows" },
  { name: "customers", rows: "88,412 rows" },
  { name: "ledger_entries", rows: "14,602,118 rows" },
];

export default function CardInteractive() {
  const [selected, setSelected] = useState("orders_daily");
  return (
    <>
      {DATASETS.map((dataset) => (
        <Card
          key={dataset.name}
          interactive
          selected={dataset.name === selected}
          onClick={() => setSelected(dataset.name)}
          style={{ width: 200 }}
        >
          <H5>{dataset.name}</H5>
          <span className="cs-numeric">{dataset.rows}</span>
        </Card>
      ))}
    </>
  );
}

Elevation#

elevation sets the shadow depth from 0 to 4. Keep cards that sit on the page at 0 or 1. Classes.ELEVATION_0 to Classes.ELEVATION_4 apply the same shadows to any element.

Elevation 0
Elevation 1
Elevation 2
Elevation 3
Elevation 4
import { Card } from "@clawscale/react";

export default function CardElevation() {
  return (
    <>
      <Card elevation={0}>Elevation 0</Card>
      <Card elevation={1}>Elevation 1</Card>
      <Card elevation={2}>Elevation 2</Card>
      <Card elevation={3}>Elevation 3</Card>
      <Card elevation={4}>Elevation 4</Card>
    </>
  );
}

Compact#

compact reduces the padding.

ingest-ordersHealthy
ingest-ordersHealthy
import { Card, Tag } from "@clawscale/react";

export default function CardCompact() {
  return (
    <>
      <Card style={{ display: "flex", justifyContent: "space-between", width: 260 }}>
        ingest-orders
        <Tag minimal intent="success">
          Healthy
        </Tag>
      </Card>
      <Card compact style={{ display: "flex", justifyContent: "space-between", width: 260 }}>
        ingest-orders
        <Tag minimal intent="success">
          Healthy
        </Tag>
      </Card>
    </>
  );
}

Interactive playground#

orders_daily
1,204,331 rows. Refreshed 12 minutes ago.
Props
View source on GitHub

Props interface#

Card also accepts the HTML attributes of a div.

interface CardProps extends Props, HTMLDivProps, React.RefAttributes<HTMLDivElement>@clawscale/react
PropsDescription
className
string
A space-delimited list of class names to pass along to a child element.
Inherited from Props
compact
boolean = false
Whether this component should use compact styles with reduced visual padding.
elevation
Elevation = 0
Controls the intensity of the drop shadow beneath the card: the higher the elevation, the higher the drop shadow. At elevation 0, no drop shadow is applied.
interactive
boolean = false
Whether the card should respond to user interactions. If set to true, hovering over the card will increase the card's elevation and change the mouse cursor to a pointer.
onClick
(e: React.MouseEvent<HTMLDivElement>) => void
Callback invoked when the card is clicked. Recommended when interactive is true.
selected
boolean = undefined
Whether this card should appear selected.