ContextCards
Description
ContextCards holds a set of ContextCards and shows them as one element, to say what a chat, a search or an answer is scoped to. By default it is a summary pill ("Added 3 items to context") that expands into a bordered list of full-width rows and collapses back, with the same pill shape and chevron as ToolsUsed. Compact() drops the header and draws a wrapping row of pills, showing the first MaxVisible (5 by default) and collapsing the rest behind a "+N more" pill.
Adding a card wires its remove button to the group, so the (x) takes it out; a handler registered with ContextCard.OnRemove still runs. An empty group renders nothing and takes no space.
Usage
Pass the cards to ContextCards(...), or add them later with Add. SetSummary replaces the default header text.
In compact form the group is a row of pills. MoreText changes the wording of the "+N more" pill, and OnShowAll hands the pill to the host instead of revealing the hidden cards in place.
API reference
public sealed class ContextCards : ComponentBase<ContextCards, HTMLElement>A group of ContextCards behind one summary pill ("Added 5 items to context") that expands to list them and collapses back, styled like ToolCall / ToolsUsed so a transcript reads as one family of disclosures. Expanded, the cards render as rows of a bordered list - full width, one divider between each, the remove button in the row rather than hovering over a corner. Compact switches the whole group to a wrapping row of pills instead, truncated to MaxVisible with a "+N more" pill that reveals the rest.
- Namespace
- Tesserae
- Inheritance
- ComponentBase<ContextCards, HTMLElement> → ContextCards
Constructors
| Name | Description |
|---|---|
| ContextCards | Initializes a new instance of this class. |
| Overload | |
|---|---|
| ContextCards(ContextCard[]) | Initializes a new instance of this class. |
| ContextCards(IEnumerable<ContextCard>) | Initializes a new instance of this class. |
Properties
| Name | Description |
|---|---|
| Cards | Gets the cards in this group, in the order they were added. |
| Count | Gets the number of cards in this group. |
| IsExpanded | Returns a value indicating whether the group is expanded (in compact mode: whether the cards beyond MaxVisible are shown). |
public IReadOnlyList<ContextCard> CardsGets the cards in this group, in the order they were added.
Methods
| Name | Description |
|---|---|
| Add | Adds a card to the group. Its remove button is wired to the group, so the (x) takes the card out of the list - a handler the caller registered on the card still runs. |
| AddRange | Adds the given cards to the group. |
| Remove | Removes a card from the group. Does nothing if the card isn't in it. |
| Clear | Removes every card from the group. |
| SetSummary | Sets the summary shown on the header pill. Without one, the group summarises itself as "Added N items to context", updated as cards come and go. |
| SetIcon | Sets the icon shown on the header pill (a stack of layers by default). |
| IconBackground | Sets the background color of the header's icon tile (any CSS color). |
| IconForeground | Sets the color of the glyph on the header's icon tile. |
| Compact | Renders the group as a wrapping row of pills with no header, showing the first MaxVisible cards and a "+N more" pill for the rest. For a dense line of attachments where the list view would be too much. |
| MaxVisible | Sets how many pills the compact row shows before the "+N more" pill takes over (5 by default). Ignored while the group isn't compact, where the list shows every card. |
| MoreText | Sets the wording of the pill standing in for the cards the compact row is hiding, as a format string whose {0} is how many that is ("+{0} more" by default), and the wording it takes once they are all shown ("Show less"). |
| OnShowAll | Hands the "+N more" pill over to the given handler instead of revealing the hidden cards in place - for a host that would rather open the full list somewhere else (a panel, a search scoped to the context). Passing null restores the reveal-in-place behaviour. |
| Expanded | Expands or collapses the group. |
| Expand | Expands the group. |
| Collapse | Collapses the group. |
| Toggle | Toggles the group between expanded and collapsed. |
| OnToggle | Registers a callback invoked whenever the group is expanded or collapsed. |
| Render | Renders the component's root HTML element. |
public ContextCards Add(ContextCard card)Adds a card to the group. Its remove button is wired to the group, so the (x) takes the card out of the list - a handler the caller registered on the card still runs.
public ContextCards AddRange(IEnumerable<ContextCard> cards)Adds the given cards to the group.
public ContextCards Remove(ContextCard card)Removes a card from the group. Does nothing if the card isn't in it.
public ContextCards SetSummary(string summary)Sets the summary shown on the header pill. Without one, the group summarises itself as "Added N items to context", updated as cards come and go.
public ContextCards SetIcon(UIcons icon)Sets the icon shown on the header pill (a stack of layers by default).
public ContextCards IconBackground(string color)Sets the background color of the header's icon tile (any CSS color).
public ContextCards IconForeground(string color)Sets the color of the glyph on the header's icon tile.
public ContextCards Compact(bool value = true)Renders the group as a wrapping row of pills with no header, showing the first MaxVisible cards and a "+N more" pill for the rest. For a dense line of attachments where the list view would be too much.
public ContextCards MaxVisible(int count)Sets how many pills the compact row shows before the "+N more" pill takes over (5 by default). Ignored while the group isn't compact, where the list shows every card.
public ContextCards MoreText(string moreFormat, string lessText = null)Sets the wording of the pill standing in for the cards the compact row is hiding, as a format string whose {0} is how many that is ("+{0} more" by default), and the wording it takes once they are all shown ("Show less").
public ContextCards OnShowAll(Action handler)Hands the "+N more" pill over to the given handler instead of revealing the hidden cards in place - for a host that would rather open the full list somewhere else (a panel, a search scoped to the context). Passing null restores the reveal-in-place behaviour.
public ContextCards Expanded(bool value = true)Expands or collapses the group.
public ContextCards Toggle()Toggles the group between expanded and collapsed.
public ContextCards OnToggle(Action<ContextCards> onToggle)Registers a callback invoked whenever the group is expanded or collapsed.