Card
Description
A card component with optional headers and footers
Cards are surfaces that display content and actions on a single topic.
They should be easy to scan for relevant and actionable information. Elements, like text and images, should be placed on them in a way that clearly indicates hierarchy.
Cards can contain different types of components. They can be used to show a list of items, a single item, or a mix of both.
Samples
Basic Card
Card with Header
Card with Header and Footer
Compact Card
Hover Card
Custom Background
API reference
public sealed class Card : ComponentBase<Card, HTMLElement>, IHasBackgroundColor, IRoundedStyleA bordered, shadowed surface used to group related content into a self-contained block.
- Namespace
- Tesserae
- Inheritance
- ComponentBase<Card, HTMLElement> → Card
- Implements
- IHasBackgroundColor, IRoundedStyle
Constructors
| Name | Description |
|---|---|
| Card | Initializes a new instance of this class. |
Properties
| Name | Description |
|---|---|
| IsCompact | Gets or set whenever the card is rendered in a compact form |
| Background | Gets or sets the CSS background of the component. |
public bool IsCompact { get ; set ; }Gets or set whenever the card is rendered in a compact form
Methods
| Name | Description |
|---|---|
| EnsureLayout | Gets or set whenever the card is rendered in a compact form |
| OnClick | Registers a callback invoked when the click event fires. |
| SetTitle | Sets the title of the component, optionally with an icon drawn just before it - what the card is about, said in a glyph as well as in words. Pass iconColor to give the icon a color of its own; without one it takes the title's. |
| SetContent | Sets the content of the component. |
| SetFooter | Sets the footer of the component. |
| Compact | Renders the component in a compact form. |
| BackgroundColor | Sets the background colour of the card. |
| Border | Configures the component to border. |
| NoPadding | Removes / disables the padding on the component. |
| HoverColor | Enables or disables the hover colour overlay on the card. |
| AI | Marks the card as AI output: a purple-to-blue tint over whatever background it had, an accent border, and a soft shadow in the same hue. The tint is deliberately light - a card is a large surface, and the point is to say where the content came from, not to colour the page. The class goes on the card's outer container, because which element paints the background depends on whether the card has a header or a footer - see tss.ai.css. |
| Render | Renders the component's root HTML element. |
private void EnsureLayout()Gets or set whenever the card is rendered in a compact form
| Overload | |
|---|---|
| OnClick(ComponentEventHandler<Card, MouseEvent>, bool) | Registers a callback invoked when the click event fires. |
| OnClick(Action) | Registers a callback invoked when the click event fires. |
| Overload | |
|---|---|
| SetTitle(string, UIcons?, string, UIconsWeight) | Sets the title of the component, optionally with an icon drawn just before it - what the card is about, said in a glyph as well as in words. Pass iconColor to give the icon a color of its own; without one it takes the title's. |
| SetTitle(IComponent) | Sets the title of the component. |
SetTitle(string, UIcons?, string, UIconsWeight)
public Card SetTitle(string title, UIcons? icon = null, string iconColor = null, UIconsWeight iconWeight = UIconsWeight.Regular)Sets the title of the component, optionally with an icon drawn just before it - what the card is about, said in a glyph as well as in words. Pass iconColor to give the icon a color of its own; without one it takes the title's.
Parameters
- title string
- icon UIcons?
- iconColor string
- iconWeight UIconsWeight
public Card BackgroundColor(string color)Sets the background colour of the card.
public Card Border(string color, UnitSize size = null)Configures the component to border.
public Card HoverColor(bool enabled = true)Enables or disables the hover colour overlay on the card.
public Card AI(bool value = true)Marks the card as AI output: a purple-to-blue tint over whatever background it had, an accent border, and a soft shadow in the same hue. The tint is deliberately light - a card is a large surface, and the point is to say where the content came from, not to colour the page. The class goes on the card's outer container, because which element paints the background depends on whether the card has a header or a footer - see tss.ai.css.