Inline Label
Description
One small fact on a line of them: an optional mark, followed by optional text
InlineLabel is a mark (a glyph, an image, or a rounded square of colour) followed by text. It is what an OmniResult footer is made of ("Box · 2.4 MB · Marie Lang · Apr 11, 2024"), and it reads the same wherever else a row of small facts is drawn.
Every combination is allowed: text alone, a mark alone, or both. Whatever the mark is, it is drawn at one size, so a line of labels stays on one baseline however each was built. A label sizes itself from where it is: a compact button on its own, small plain type inside a footer.
A label renders as an anchor, so SetHref produces a real link (middle-clickable, address in the status bar) and OnClick makes it pressable with its own tab stop, answering Enter and Space. A click stops at the label, so pressing it never also counts as a click on the row it sits in.
Self-removing labels
Built from a task, InlineLabel(async label => …) draws as a skeleton rectangle while the task runs. If the task ends without setting any text or mark, the label takes itself out of the document, along with the slot it was standing in: the stack item, the footer entry (separator dot included), or the whole DetailsGrid row when it was that row's only value. A line of facts therefore never keeps a gap for a lookup that came back empty.
Samples
Marks and text
A pressable label
API reference
public sealed class InlineLabel : ComponentBase<InlineLabel, HTMLAnchorElement>One small piece of metadata on a line of them: an optional mark - a glyph, an image, or a rounded square of colour - followed by optional text. It is what an OmniResult{T} footer is made of ("Box · 2.4 MB · Marie Lang · Apr 11, 2024"), and it reads the same wherever else a row of small facts is drawn. Every combination is allowed: text alone, a mark alone, or a mark and text together. Whatever the mark is, it is drawn at one size, so a line of them stays on one baseline however they were built. A label can be pressed (OnClick) or be a real link (SetHref) - it is an anchor either way, so a link is middle-clickable and shows its address in the status bar rather than being a div pretending. A label can also be built from a task (InlineLabel) for a fact that has to be looked up. It draws as a skeleton rectangle while the task runs, and if the task ends without giving it anything to say it takes itself out of the document - along with the slot it was standing in, so a line of facts doesn't keep a gap for something that turned out not to exist.
- Namespace
- Tesserae
- Inheritance
- ComponentBase<InlineLabel, HTMLAnchorElement> → InlineLabel
Constructors
| Name | Description |
|---|---|
| InlineLabel | Initializes a new instance of this class showing the given text, with no mark before it. |
| Overload | |
|---|---|
| InlineLabel(string) | Initializes a new instance of this class showing the given text, with no mark before it. |
| InlineLabel(Func<InlineLabel, Task>) | Initializes a new instance of this class that looks up what it says. It draws as a skeleton rectangle while load runs, and takes itself - and the slot it stands in - out of the document if the task ends without setting any text or mark on it. |
InlineLabel(string)
public InlineLabel(string text = null)Initializes a new instance of this class showing the given text, with no mark before it.
Parameters
- text string
InlineLabel(Func<InlineLabel, Task>)
public InlineLabel(Func<InlineLabel, Task> load) : this((string)null)Initializes a new instance of this class that looks up what it says. It draws as a skeleton rectangle while load runs, and takes itself - and the slot it stands in - out of the document if the task ends without setting any text or mark on it.
Parameters
- load Func<InlineLabel, Task>
Properties
| Name | Description |
|---|---|
| Text | Gets the text the label shows, or null when it is a mark on its own. |
| IsEmpty | Whether the label has nothing to show - no text, and no mark. |
public string Text { get; private set; }Gets the text the label shows, or null when it is a mark on its own.
Methods
| Name | Description |
|---|---|
| Render | Renders the component's root HTML element. |
| SetText | Sets the text the label shows. A null or empty value leaves the label as its mark alone. |
| SetIcon | Puts a glyph before the text, in a colour of its own when one is given - the accent a node type, a source or a status is known by - and in the label's own colour otherwise. |
| SetImage | Puts an image before the text - a source's logo, a favicon, a thumbnail - fitted into the mark rather than cropped. |
| SetColor | Puts a small rounded square of the given colour before the text - the quiet way a source, a status or a category is named. |
| NoMark | Takes the mark away, leaving the text alone. |
| SetHref | Makes the label a real link to the given address, opened in a new tab when asked. Pass null to make it plain text again. |
| OnClick | Registers what pressing the label does. It takes a tab stop of its own and answers Enter and Space; the click stops at the label, so pressing it never also counts as a click on the row it sits in. Pass null to make it plain text again. |
| RemoveWithItsSlot | Takes the label out of the document along with whatever is standing in for it in its container: a stack's item wrapper, a footer's entry, or - when the label is all a details row has to show - the whole row, label cell included. Anywhere else, just the label goes. |
public override HTMLElement Render()Renders the component's root HTML element.
public InlineLabel SetText(string text)Sets the text the label shows. A null or empty value leaves the label as its mark alone.
| Overload | |
|---|---|
| SetIcon(UIcons, UIconsWeight, string) | Puts a glyph before the text, in a colour of its own when one is given - the accent a node type, a source or a status is known by - and in the label's own colour otherwise. |
| SetIcon(IComponent) | Puts a component of the host's own before the text - an Avatar, an emoji, a Spinner. It is drawn at the same size as any other mark. |
SetIcon(UIcons, UIconsWeight, string)
public InlineLabel SetIcon(UIcons icon, UIconsWeight weight = UIconsWeight.Regular, string color = null)Puts a glyph before the text, in a colour of its own when one is given - the accent a node type, a source or a status is known by - and in the label's own colour otherwise.
Parameters
- icon UIcons
- weight UIconsWeight
- color string
public InlineLabel SetImage(string url)Puts an image before the text - a source's logo, a favicon, a thumbnail - fitted into the mark rather than cropped.
public InlineLabel SetColor(string color)Puts a small rounded square of the given colour before the text - the quiet way a source, a status or a category is named.
public InlineLabel SetHref(string href, bool openInNewTab = false)Makes the label a real link to the given address, opened in a new tab when asked. Pass null to make it plain text again.
| Overload | |
|---|---|
| OnClick(Action<InlineLabel>) | Registers what pressing the label does. It takes a tab stop of its own and answers Enter and Space; the click stops at the label, so pressing it never also counts as a click on the row it sits in. Pass null to make it plain text again. |
| OnClick(ComponentEventHandler<InlineLabel, MouseEvent>, bool) | Registers a click handler in the shape every other component takes. The label becomes pressable the same way OnClick makes it. |
OnClick(Action<InlineLabel>)
public InlineLabel OnClick(Action<InlineLabel> onClick)Registers what pressing the label does. It takes a tab stop of its own and answers Enter and Space; the click stops at the label, so pressing it never also counts as a click on the row it sits in. Pass null to make it plain text again.
Parameters
- onClick Action<InlineLabel>
OnClick(ComponentEventHandler<InlineLabel, MouseEvent>, bool)
public override InlineLabel OnClick(ComponentEventHandler<InlineLabel, MouseEvent> onClick, bool clearPrevious = true)Registers a click handler in the shape every other component takes. The label becomes pressable the same way OnClick makes it.
Parameters
- onClick ComponentEventHandler<InlineLabel, MouseEvent>
- clearPrevious bool
private void RemoveWithItsSlot()Takes the label out of the document along with whatever is standing in for it in its container: a stack's item wrapper, a footer's entry, or - when the label is all a details row has to show - the whole row, label cell included. Anywhere else, just the label goes.
See also
- Omni Result — the row whose footer is a line of these.
- Details Grid — label/value rows that take these as values.
- Badge — a filled pill, when the fact needs more weight than a footer entry.
- Components overview