Variants
import { html, renderApp } from 'mates';
import { Card, Text } from 'mates-ui';
const App = () => () => html`
<x-row gap="var(--md-space-4)" wrap align="stretch">
${Card({ variant: "elevated", body: html`<x-col gap="var(--md-space-2)">${Text("Elevated", { type: "title-sm" })}${Text("Drop shadow, no border.", { type: "body-sm", color: "muted" })}</x-col>` })}
${Card({ variant: "filled", body: html`<x-col gap="var(--md-space-2)">${Text("Filled", { type: "title-sm" })}${Text("Tonal background, no shadow.", { type: "body-sm", color: "muted" })}</x-col>` })}
${Card({ variant: "outlined", body: html`<x-col gap="var(--md-space-2)">${Text("Outlined", { type: "title-sm" })}${Text("Border stroke, no fill.", { type: "body-sm", color: "muted" })}</x-col>` })}
</x-row>
`;
renderApp(App, document.getElementById('app'));
With header
import { html, renderApp } from 'mates';
import { Card } from 'mates-ui';
import { FolderIcon } from 'mates-icons';
const App = () => () => html`
<div style="max-width:22rem;width:100%;">
${Card({
variant: "elevated",
header: {
icon: FolderIcon,
title: "Project Assets",
subtitle: "Last modified 2 hours ago",
},
body: "Store and organise all media, documents and exports for this project in one place.",
})}
</div>
`;
renderApp(App, document.getElementById('app'));
With media
import { html, renderApp } from 'mates';
import { Card, FilledButton, OutlinedButton } from 'mates-ui';
const App = () => () => html`
<div style="max-width:24rem;width:100%;">
${Card({
variant: "elevated",
media: { src: "https://picsum.photos/seed/card/400/200", alt: "Scenic landscape", height: "12rem", position: "top", fit: "cover" },
header: { title: "Mountain Escape", subtitle: "Nature · Photography" },
body: "Breathtaking views from 3 000 m above sea level. Pack light and leave early.",
actions: html`
<x-row gap="var(--md-space-2)">
${FilledButton("Book now")}
${OutlinedButton("Save")}
</x-row>
`,
})}
</div>
`;
renderApp(App, document.getElementById('app'));
Interactive
import { html, atom, renderApp } from 'mates';
import { Card, Text } from 'mates-ui';
const App = () => {
const clicks = atom(0);
return () => html`
<x-row gap="var(--md-space-4)" wrap align="stretch">
${Card({
variant: "elevated", interactive: true, enableRipple: true, enableBloom: false,
ariaLabel: "Ripple card",
on: { click: () => clicks.set((n) => n + 1) },
body: html`<x-col gap="var(--md-space-2)">
${Text("Ripple press", { type: "title-sm" })}
${Text("Clicked " + clicks() + " time" + (clicks() === 1 ? "" : "s"), { type: "body-sm", color: "muted" })}
</x-col>`,
})}
${Card({
variant: "outlined", interactive: true, enableRipple: false, enableBloom: true,
ariaLabel: "Bloom card",
on: { click: () => clicks.set((n) => n + 1) },
body: html`<x-col gap="var(--md-space-2)">
${Text("Bloom press", { type: "title-sm" })}
${Text("Clicked " + clicks() + " time" + (clicks() === 1 ? "" : "s"), { type: "body-sm", color: "muted" })}
</x-col>`,
})}
</x-row>
`;
};
renderApp(App, document.getElementById('app'));
Full composition
import { html, renderApp } from 'mates';
import { Card, FilledButton, IconButton, TextButton } from 'mates-ui';
import { FolderIcon, MoreVertIcon } from 'mates-icons';
const App = () => () => html`
<div style="max-width:24rem;width:100%;">
${Card({
variant: "elevated",
header: {
icon: FolderIcon,
title: "Design System",
subtitle: "Mates UI · v2.0",
action: html`${IconButton(MoreVertIcon, { ariaLabel: "More options", variant: "ghost" })}`,
},
media: { src: "https://picsum.photos/seed/card/400/200", alt: "Cover", height: "11rem", position: "middle", fit: "cover" },
body: "A comprehensive component library built on Mates. Consistent tokens, accessible markup, and zero runtime overhead.",
actions: html`
<x-row gap="var(--md-space-2)">
${FilledButton("Get started")}
${TextButton("View source")}
</x-row>
`,
})}
</div>
`;
renderApp(App, document.getElementById('app'));