Class TwLayoutComponentBase
- Namespace
- TwBlazor
- Assembly
- TwBlazor.dll
The base for the layout components (TwContainer, TwFlex, TwFlexItem, TwGrid and TwGridItem): renders a single element of the chosen Element type around the child content.
public abstract class TwLayoutComponentBase : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent
- Inheritance
-
TwLayoutComponentBase
- Implements
- Derived
- Inherited Members
Remarks
A layout component adds no keyboard behaviour and no ARIA role of its own, except role="list" on a
ul or ol: Safari stops announcing a list once its bullets are removed, which Tailwind's base
styles always do. Shadow and Rounded
apply only when set, so a plain layout never picks up the theme's default card shadow or corners.
Constructors
TwLayoutComponentBase()
protected TwLayoutComponentBase()
Properties
ChildContent
Gets or sets the content laid out inside the element.
[Parameter]
public RenderFragment? ChildContent { get; set; }
Property Value
Element
Gets or sets the HTML element to render. Defaults to Div.
[Parameter]
public LayoutElement Element { get; set; }
Property Value
Remarks
Pick the element that says what the content is, such as Ul for a list of products or Section for a band of the page, so screen readers can describe it.
decorationClasses
protected string decorationClasses { get; }
Property Value
flexbox
Gets the shared flexbox utilities from the theme.
protected TwBlazorFlexbox flexbox { get; }
Property Value
grid
Gets the shared grid utilities from the theme.
protected TwBlazorGrid grid { get; }
Property Value
rootClasses
Gets the classes for the rendered element, with Class merged last.
protected abstract string rootClasses { get; }
Property Value
rootStyle
Gets the inline style for the rendered element. Defaults to Style.
protected virtual string? rootStyle { get; }
Property Value
spacing
Gets the shared spacing scales from the theme.
protected TwBlazorSpacing spacing { get; }
Property Value
Methods
AlignContentClass(AlignContent?)
Gets the class for a distribution of lines or tracks on the cross axis.
protected string AlignContentClass(AlignContent? value)
Parameters
valueAlignContent?The distribution, or null for none.
Returns
- string
The class, or an empty string.
AlignItemsClass(AlignItems?)
Gets the class for a cross-axis alignment.
protected string AlignItemsClass(AlignItems? value)
Parameters
valueAlignItems?The alignment, or null for none.
Returns
- string
The class, or an empty string.
AlignSelfClass(AlignSelf?)
Gets the class for one item's cross-axis alignment.
protected string AlignSelfClass(AlignSelf? value)
Parameters
Returns
- string
The class, or an empty string.
BuildContent(RenderTreeBuilder)
Renders the content inside the element. Override it to wrap ChildContent, for example in a cascading value; sequence numbers from 8 upwards are free.
protected virtual void BuildContent(RenderTreeBuilder builder)
Parameters
builderRenderTreeBuilderThe render tree builder, positioned inside the element.
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder builder)
Parameters
builderRenderTreeBuilderA RenderTreeBuilder that will receive the render output.
CssValue(string)
Removes the characters that could end a CSS declaration early, so a value passed by a parameter stays inside its own declaration.
protected static string CssValue(string value)
Parameters
valuestringThe value.
Returns
- string
The value without semicolons, braces or quotes, trimmed.
JoinClasses(params string?[])
Joins classes with single spaces, leaving out empty ones.
protected static string JoinClasses(params string?[] classes)
Parameters
classesstring[]The classes to join.
Returns
- string
The joined classes.
JoinStyles(params string?[])
Joins CSS declarations with semicolons, leaving out empty ones.
protected static string? JoinStyles(params string?[] declarations)
Parameters
declarationsstring[]The declarations to join, such as
grid-area: main.
Returns
JustifyContentClass(JustifyContent?)
Gets the class for a main-axis distribution.
protected string JustifyContentClass(JustifyContent? value)
Parameters
valueJustifyContent?The distribution, or null for none.
Returns
- string
The class, or an empty string.
OrderClass(int?)
Gets the class for an item's visual order.
protected string OrderClass(int? order)
Parameters
Returns
- string
The class, or an empty string when the position is not on the theme's scale.
ResponsiveClasses(TwResponsiveScale, int?, int?, int?, int?, int?, int?)
Gets the classes of a numbered responsive scale for each breakpoint that has a value.
protected static string ResponsiveClasses(TwResponsiveScale scale, int? baseValue, int? sm, int? md, int? lg, int? xl, int? xl2)
Parameters
scaleTwResponsiveScaleThe scale.
baseValueint?The value at every width.
smint?The value from the
smbreakpoint.mdint?The value from the
mdbreakpoint.lgint?The value from the
lgbreakpoint.xlint?The value from the
xlbreakpoint.xl2int?The value from the
2xlbreakpoint.
Returns
- string
The joined classes.