<c-card>
A raised, bordered surface that groups one piece of content — its heading, body and actions — into a single box on the page.
Usage
Build the card from its sections, in this order: c-card-title for the heading, c-card-content for the body and c-card-actions for the row of actions. Each section is optional; the card spaces them evenly and pads them in from its edges.
<c-card>
<c-card-title>Project members</c-card-title>
<c-card-content>
<p>Manage who has access to this project and what they can do.</p>
</c-card-content>
<c-card-actions justify="end">
<c-button appearance="text">Cancel</c-button>
<c-button>Save</c-button>
</c-card-actions>
</c-card>
When to use
- To group a self-contained part of a page: a summary, a settings form, a list with its actions.
- As the content of a
c-modal, where the card's heading, body and actions become the dialog's. - For a sign-in page, use
c-login-card, with its larger heading and background image. - For a status message, use
c-alert, which carries the status colours and announces itself.
Sections
c-card-titlesets the heading in small uppercase type above a short primary accent bar. Controls in itsactionsslot sit at the right of the heading, and move onto their own line under it, starting at the left, once the two no longer fit side by side.c-card-contentstacks its children in a column, spaced like the sections themselves.c-card-actionslays its children out in a row that wraps onto further rows instead of overflowing the card.justifydistributes them along the row —start(the default),center,end,space-between,space-around, orstretch, which grows every action to share the row — andalignplaces them across it:center(the default),startorend. Ac-buttonwithfitgrows whateverjustifyis.
Content slotted straight into the card, outside a section, keeps the vertical spacing but gets no inline padding: it runs edge to edge between the card's borders.
Fullscreen
show-fullscreen (the 3.x fullscreen, which still works until 5.0) adds a round toggle button in the card's top-right corner. Pressing it shows the card in the browser's fullscreen mode; pressing it again, or Escape, returns the card to the page. In fullscreen the card fills the screen with square corners and scrolls its own content. The toggle sits at the end of the heading row, and a c-card-title keeps its text and actions clear of it.
enterFullscreen() and exitFullscreen() do the same from code, with or without the toggle; exitFullscreen() ends only the card's own fullscreen, never another element's. A browser grants fullscreen only in response to a user action, so call enterFullscreen() from a click handler; a refused request logs a console warning and the card stays on the page.
Accessibility
The card is an <article>. c-card-title is a heading, level 2 unless its heading-level says otherwise, so cards appear in the page's heading outline; set the level that fits where the cards sit. The fullscreen toggle is a native button whose name and tooltip, "Enter fullscreen" or "Exit fullscreen", follow its state; the text is fixed English.
Customization
::part(root) is the card's visible box: the background and its ink, the border, corner radius, shadow and the spacing between sections all live on it. ::part(fullscreen-toggle) is the toggle button. Each section has parts of its own, listed with it below.
c-card::part(root) {
box-shadow: none;
}
A card that pins its own theme mode with data-theme="light" or data-theme="dark" repaints its surface and the ink of everything slotted into it.
<c-card-title>
The heading section of a c-card, set in small uppercase type above a primary accent bar; place it first in the card. Controls in its actions slot sit at the right of the heading and move onto their own line under it when the two do not fit side by side.
The title is a heading, level 2 unless heading-level says otherwise: set the level that fits the card's place in the page's outline, such as 3 for cards inside a section headed by an h2.
Examples
<template>
<div>
<c-card>
<c-card-title>Project members</c-card-title>
<c-card-content>
<p>Manage who has access to this project and what they can do.</p>
</c-card-content>
<c-card-actions justify="end">
<c-button appearance="text">Cancel</c-button>
<c-button>Save</c-button>
</c-card-actions>
</c-card>
</div>
</template>
<template>
<div>
<c-card>
<c-card-title>
Notifications
<c-button slot="actions" appearance="ghost" size="small">
Mark all read
</c-button>
</c-card-title>
<c-card-content>
<p>You have 3 unread notifications.</p>
</c-card-content>
</c-card>
</div>
</template>
API reference
<c-card>
A raised, bordered surface that groups one piece of content — its heading, body and actions — into a single box on the page.
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
showFullscreen | show-fullscreen | boolean | — | Show a toggle button in the card's top-right corner that puts the card in the browser's fullscreen mode and back. |
fullscreen deprecated | fullscreen | boolean | false | Deprecated. Use `show-fullscreen`. Shows a toggle button in the card's top-right corner that puts the card in the browser's fullscreen mode and back. |
Methods
| Method | Signature | Description |
|---|---|---|
enterFullscreen | () | Shows the card in the browser's fullscreen mode; does nothing while any element is already fullscreen. Browsers grant it only in response to a user action, so call it from a click handler. |
exitFullscreen | () | Returns the card from fullscreen to the page. Ends only the card's own fullscreen, never another element's. |
Slots
| Slot | Description |
|---|---|
default | The card's sections: `c-card-title`, `c-card-content` and `c-card-actions`, in that order |
CSS parts
Style from outside with c-card::part(name) — parts are the library's only styling customization API.
| Part | Description |
|---|---|
root | The card's visible surface, carries the background and its ink, border, radius, shadow and section spacing |
fullscreen-toggle | The round fullscreen toggle button, shown when `show-fullscreen` is set |
<c-card-title>
The heading section of a `c-card`, set in small uppercase type above a primary accent bar; place it first in the card. Controls in its `actions` slot sit at the right of the heading and move onto their own line under it when the two do not fit side by side.
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
headingLevel | heading-level | 1 | 2 | 3 | 4 | 5 | 6 | 2 | The title's heading level, 1 to 6: pick the one that fits the card's place in the page's outline (2 under the page's `h1`, 3 inside a section with an `h2`). |
Slots
| Slot | Description |
|---|---|
default | The title text |
actions | Action controls shown to the right of the title, or under it when the two do not fit side by side |
CSS parts
Style from outside with c-card-title::part(name) — parts are the library's only styling customization API.
| Part | Description |
|---|---|
root | The outer header element carrying the title typography and padding |
header | The wrapper around the heading and its underline |
heading | The heading (`role="heading"`, at `heading-level`) holding the slotted title text |
underline | The decorative accent bar under the heading |
actions | The wrapper around the slotted action controls |
<c-card-content>
The body section of a `c-card`: it pads its content in from the card's edges and stacks the children in a column with the card's section spacing. Place it after `c-card-title` and before `c-card-actions`.
Slots
| Slot | Description |
|---|---|
default | The card's body content |
CSS parts
Style from outside with c-card-content::part(name) — parts are the library's only styling customization API.
| Part | Description |
|---|---|
root | The padded column stacking the slotted content with the card's section spacing |
<c-card-actions>
The row of actions at the bottom of a `c-card`, typically `c-button`s, which wraps onto further rows instead of overflowing the card. `justify` distributes the actions along the row (`start` by default, `stretch` to grow them all) and `align` places them across it.
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
align | align | CCardActionsAlign | 'center' | Aligns the actions across the row: to its top (`start`), centre or bottom (`end`). |
justify | justify | CCardActionsJustify | 'start' | Distributes the actions along the row; `stretch` grows every action to share it. |
Slots
| Slot | Description |
|---|---|
default | The actions, typically `c-button`s |
CSS parts
Style from outside with c-card-actions::part(name) — parts are the library's only styling customization API.
| Part | Description |
|---|---|
root | The padded footer wrapping the actions row |
actions | The wrapping flex row laying out the slotted actions |
Types
Importable from the package root: import type { … } from '@cscfi/csc-ui'
CCardActionsAlign
Cross-axis alignment of the slotted actions within the row.
export type CCardActionsAlign = 'center' | 'end' | 'start';CCardActionsJustify
Main-axis distribution of the slotted actions. `stretch` makes every action grow to fill the row.
export type CCardActionsJustify =
| 'center'
| 'end'
| 'space-around'
| 'space-between'
| 'start'
| 'stretch';