Content
Card
A card lifts one object off the paper, such as today's focus, a project's payments or a single payment, so the person reads it as one thing.
In kanso-ui as Card
Web and native
Web
Native
Card in kanso-ui 0.59.0, for React.
import { Card } from '@kanso-labs/kanso-ui'A surface that holds related content, separated from the page by a shadow, a darker fill or a border.
It follows the Material Design cards page: a 12dp corner, 16dp of padding, and the page's disabled state for each variant. interactive and render are separate choices — one makes the card pressable, the other decides which element it is.
What you provide
children: whatever the card shows. The card has no slots of its own.- A container with a width: the card fills whatever it is given.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
interactive | boolean | false | Makes the card the thing you press: it takes Kanso's hover and focus layers, ripples at its pressed layer, and takes a focus ring. Kanso's page draws a card that is not a control, so prefer a card whose title is a link and whose actions are buttons of their own. Renders a `<button>` unless `render` says otherwise. A button holds phrasing content only, so its children are spans, which a `Text` is, laid out through StyleX; for block content, `render` gives it an anchor or another element. Leave it off for a card that merely holds content, including one containing its own buttons. |
isDisabled | boolean | false | Turns an interactive card off: its fill turns to Kanso's disabled container and its content fades to 38%, it stops rippling, and it takes no press. The default `<button>` is disabled outright. An element of the call site's own through `render` is marked `aria-disabled`, and an element handed in directly loses its `href`, `tabIndex` and `onClick`, so a link card can neither be followed nor focused. Has no effect on a card that is not `interactive`, which cannot be pressed to begin with. |
padding | 'default' | 'none' | 'default' | `none` removes the card's own padding, for a card whose children run to its edges: Kanso's flush card, holding a short list of rows that draw their own hairlines. |
variant | 'elevated' | 'filled' | 'outlined' | 'elevated' | How the card separates itself from the page: `elevated` is Kanso's default card, lifted by `shadow-1`, and `outlined` its flat card, with a 1px hairline in place of the shadow, for a card on `surface` inside a sheet or a dialog. `filled` is deprecated: Kanso has no filled card. It draws on Kanso's recessed `surface-sunken`, and warns once in development. |
Also takes the props of RenderComponentProps<'div'>.
Example
import { Card, Stack, Text } from '@kanso-labs/kanso-ui'
<Card variant="outlined">
<Stack gap="xs">
<Text variant="titleMedium">Headline</Text>
<Text tone="muted" variant="bodySmall">Supporting line</Text>
</Stack>
</Card>
<Card interactive render={<a href="/details" />}>
<Text variant="titleMedium">Headline</Text>
</Card>The design’s classes
k-card, k-card--web, k-card--flush, k-card--flat, k-card__head, k-card__title, k-card__count. Maps to Card in kanso-ui and react-native-kanso-ui.