Class Card
A raised surface that groups a piece of content into a single, self-contained tile.
Inheritance
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class Card : ExVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder, IPressable
Remarks
Card is a compound component. It is a plain surface on its own and gets its structure from the sub-elements you compose into it, in this order: CardMedia, CardHeader (holding a CardTitle and a CardDescription), CardContent and CardFooter. Every part is optional.
Two state flags drive its appearance: interactive turns the whole card into a focusable, clickable target — the pointer becomes a hand, hover tints the surface and a submit key press fires clicked. selected outlines the card with the accent colour, for single- or multi-select tile pickers. The two are usually paired.
elevation is off by default so the card reads as a flat raised surface. Raising it
applies the shared App UI elevation ramp (the same appui-elevation-* classes and
--appui-elevations-* tokens the Drawer and the FAB use) and enables the outset shadow pass.
Tip: to lay several cards out as a responsive gallery, drop them into a CardGrid rather than positioning them by hand.
Examples
A static content card composed in UXML.
<appui:Card>
<appui:CardHeader>
<appui:CardTitle text="Third Person Template" />
<appui:CardDescription text="A ready-made character controller." />
</appui:CardHeader>
<appui:CardContent>
<appui:Text text="Universal Render Pipeline - 2.4 GB" />
</appui:CardContent>
<appui:CardFooter>
<appui:Button title="Open" />
</appui:CardFooter>
</appui:Card>
A selectable template tile, built in C#.
var card = new Card { interactive = true };
card.Add(new CardMedia { image = thumbnail });
var header = new CardHeader();
header.Add(new CardTitle );
header.Add(new CardDescription );
card.Add(header);
card.clicked += () => card.selected = !card.selected;
A raised, media-topped card.
<appui:Card interactive="true" elevation="2">
<appui:CardMedia style="height: 120px;" />
<appui:CardHeader>
<appui:CardTitle text="Asset Pack" />
</appui:CardHeader>
</appui:Card>
Constructors
Card()
Default constructor.
Declaration
public Card()
Fields
elevationUssClassName
The elevation styling class prefix. This is the shared App UI elevation ramp.
Declaration
public const string elevationUssClassName = "appui-elevation-"
Field Value
| Type | Description |
|---|---|
| string |
interactiveUssClassName
The styling class applied to a Card that is interactive.
Declaration
public const string interactiveUssClassName = "appui-card--interactive"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The Card main styling class.
Declaration
public const string ussClassName = "appui-card"
Field Value
| Type | Description |
|---|---|
| string |
Properties
clickable
Clickable Manipulator for this Card.
Declaration
[CreateProperty]
public Pressable clickable { get; set; }
Property Value
| Type | Description |
|---|---|
| Pressable |
elevation
The elevation level of the Card, from the shared App UI elevation ramp. 0 (the default)
draws no shadow.
Declaration
[Tooltip("The elevation level of the Card. 0 draws no shadow.")]
[CreateProperty]
[UxmlAttribute]
public float elevation { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
interactive
Whether the Card behaves as a single activatable target.
Declaration
[Tooltip("Whether the Card behaves as a single activatable target.")]
[CreateProperty]
[UxmlAttribute]
public bool interactive { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
An interactive Card is focusable, shows the pointer cursor, tints on hover and fires clicked on a click or on a submit key press. A non-interactive Card is inert chrome and is skipped by keyboard navigation.
selected
Whether the Card is currently selected.
Declaration
[Tooltip("Whether the Card is currently selected.")]
[CreateProperty]
[UxmlAttribute]
public bool selected { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Selection is purely visual here — the Card outlines itself with the accent colour and does not manage a selection group. Drive it from whatever owns the selection.
Events
clicked
Raised when an interactive Card is activated, by click or by submit key.
Declaration
public event Action clicked
Event Type
| Type | Description |
|---|---|
| Action |