DeepWorks Studios Blazor Component Library

Demo user Administrator ยท Blazor Server Library 20261206222504-6e8ff32.dirty

DwsVertical

Stacks its child items in a column. Spacing and alignment are parameters, can change per screen size, and the container can render as any layout element.

API Reference

Basic

Space is the gap between the items, Padding and Margin the space inside and around the container, all in pixels.

A B C
A B C
Show Code
Vertical.razor

<DwsHorizontal Name='VerticalDemo_Basic_Row' Space='24' VerticalAlignment='DwsVerticalAlignment.Top'>
    <DwsVertical Name='VerticalDemo_Basic_Plain'>
        <span class='border rounded px-2'>A</span>
        <span class='border rounded px-2'>B</span>
        <span class='border rounded px-2'>C</span>
    </DwsVertical>
    <DwsVertical Name='VerticalDemo_Basic_Spaced' Space='12' Padding='12' Margin='8' BorderColor='DwsColor.Secondary'>
        <span class='border rounded px-2'>A</span>
        <span class='border rounded px-2'>B</span>
        <span class='border rounded px-2'>C</span>
    </DwsVertical>
</DwsHorizontal>

Vertical alignment

Alignment places the items along the column (justify-content): Top, Center or Bottom. It needs free height to work with, here a Height of 180px.

Top
A B C
Center
A B C
Bottom
A B C
Show Code
Vertical.razor

<DwsHorizontal Name='VerticalDemo_Alignment_Row' Space='16'>
    <div>
        <small class='d-block'>Top</small>
        <DwsVertical Name='VerticalDemo_Alignment_Top' Alignment='DwsVerticalAlignment.Top' Height='180' Width='100' Space='6' Padding='6' BorderColor='DwsColor.Secondary'>
            <span class='border rounded px-2'>A</span>
            <span class='border rounded px-2'>B</span>
            <span class='border rounded px-2'>C</span>
        </DwsVertical>
    </div>
    <div>
        <small class='d-block'>Center</small>
        <DwsVertical Name='VerticalDemo_Alignment_Center' Alignment='DwsVerticalAlignment.Center' Height='180' Width='100' Space='6' Padding='6' BorderColor='DwsColor.Secondary'>
            <span class='border rounded px-2'>A</span>
            <span class='border rounded px-2'>B</span>
            <span class='border rounded px-2'>C</span>
        </DwsVertical>
    </div>
    <div>
        <small class='d-block'>Bottom</small>
        <DwsVertical Name='VerticalDemo_Alignment_Bottom' Alignment='DwsVerticalAlignment.Bottom' Height='180' Width='100' Space='6' Padding='6' BorderColor='DwsColor.Secondary'>
            <span class='border rounded px-2'>A</span>
            <span class='border rounded px-2'>B</span>
            <span class='border rounded px-2'>C</span>
        </DwsVertical>
    </div>
</DwsHorizontal>

Distributing free space

JustifyContent adds SpaceBetween, SpaceAround and SpaceEvenly (also FlexStart, Center and FlexEnd) and wins over Alignment. It needs free height to work with, here a Height of 180px.

SpaceBetween
A B C
SpaceAround
A B C
SpaceEvenly
A B C
Show Code
Vertical.razor

<!-- JustifyContent: SpaceBetween, SpaceAround or SpaceEvenly (also FlexStart, Center, FlexEnd); it wins over Alignment -->
<DwsHorizontal Name='VerticalDemo_Justify_Row' Space='16'>
    <div>
        <small class='d-block'>SpaceBetween</small>
        <DwsVertical Name='VerticalDemo_Alignment_SpaceBetween' JustifyContent='DwsJustifyContent.SpaceBetween' Height='180' Width='100' Space='6' Padding='6' BorderColor='DwsColor.Secondary'>
            <span class='border rounded px-2'>A</span>
            <span class='border rounded px-2'>B</span>
            <span class='border rounded px-2'>C</span>
        </DwsVertical>
    </div>
    <div>
        <small class='d-block'>SpaceAround</small>
        <DwsVertical Name='VerticalDemo_Alignment_SpaceAround' JustifyContent='DwsJustifyContent.SpaceAround' Height='180' Width='100' Space='6' Padding='6' BorderColor='DwsColor.Secondary'>
            <span class='border rounded px-2'>A</span>
            <span class='border rounded px-2'>B</span>
            <span class='border rounded px-2'>C</span>
        </DwsVertical>
    </div>
    <div>
        <small class='d-block'>SpaceEvenly</small>
        <DwsVertical Name='VerticalDemo_Alignment_SpaceEvenly' JustifyContent='DwsJustifyContent.SpaceEvenly' Height='180' Width='100' Space='6' Padding='6' BorderColor='DwsColor.Secondary'>
            <span class='border rounded px-2'>A</span>
            <span class='border rounded px-2'>B</span>
            <span class='border rounded px-2'>C</span>
        </DwsVertical>
    </div>
</DwsHorizontal>

Horizontal alignment

HorizontalAlignment places items of different widths across the column (align-items): Left, Center or Right. None stretches them to the column's width.

None
Short A longer item Middle
Left
Short A longer item Middle
Center
Short A longer item Middle
Right
Short A longer item Middle
Show Code
Vertical.razor

<DwsHorizontal Name='VerticalDemo_Horizontal_Row' Space='16'>
@foreach (DwsHorizontalAlignment horizontalAlignment in _horizontalAlignments)
{
    <div>
        <small class='d-block'>@horizontalAlignment</small>
        <DwsVertical Name='@($"VerticalDemo_Horizontal_{horizontalAlignment}")' HorizontalAlignment='horizontalAlignment' Width='150' Space='6' Padding='6' BorderColor='DwsColor.Secondary'>
            <span class='border rounded px-2'>Short</span>
            <span class='border rounded px-2'>A longer item</span>
            <span class='border rounded px-2'>Middle</span>
        </DwsVertical>
    </div>
}
</DwsHorizontal>
Vertical.razor.cs

private static readonly DwsHorizontalAlignment[] _horizontalAlignments =
[
    DwsHorizontalAlignment.None,
    DwsHorizontalAlignment.Left,
    DwsHorizontalAlignment.Center,
    DwsHorizontalAlignment.Right,
];

Overflow

Overflow decides what happens when the items are taller than the column: Auto scrolls once the content passes MaxHeight, Hidden cuts it off at Height. Items with a fixed height of their own shrink before they overflow; give them the flex-shrink-0 class to keep it.

Overflow.Auto + MaxHeight
Item 1Item 2Item 3Item 4Item 5Item 6Item 7Item 8Item 9Item 10
Overflow.Hidden + Height
Item 1Item 2Item 3Item 4Item 5Item 6Item 7Item 8Item 9Item 10
Show Code
Vertical.razor

<DwsHorizontal Name='VerticalDemo_Overflow_Row' Space='24' VerticalAlignment='DwsVerticalAlignment.Top'>
    <div>
        <small class='d-block'><code>Overflow.Auto</code> + MaxHeight</small>
        <!-- Scrolls once the items pass 150px -->
        <DwsVertical Name='VerticalDemo_Overflow_Auto' Width='220' MaxHeight='150' Overflow='DwsOverflow.Auto' Space='6' Padding='6' BorderColor='DwsColor.Secondary'>
            @for (int i = 1; i <= 10; i++)
            {
                <span class='border rounded px-2'>Item @i</span>
            }
        </DwsVertical>
    </div>
    <div>
        <small class='d-block'><code>Overflow.Hidden</code> + Height</small>
        <!-- Cut off at 150px -->
        <DwsVertical Name='VerticalDemo_Overflow_Hidden' Width='220' Height='150' Overflow='DwsOverflow.Hidden' Space='6' Padding='6' BorderColor='DwsColor.Secondary'>
            @for (int i = 1; i <= 10; i++)
            {
                <span class='border rounded px-2'>Item @i</span>
            }
        </DwsVertical>
    </div>
</DwsHorizontal>

Background and border

BackgroundColor and BorderColor take theme colors, so they follow the active theme. A BorderColor or BorderWidth alone draws a solid border; BorderStyle picks another style.

Primary background rounded corners
Dashed success border 2px wide
Show Code
Vertical.razor

<DwsVertical Name='VerticalDemo_Appearance_Primary' BackgroundColor='DwsColor.Primary' Space='4' Padding='12' BorderRadius='8'>
    <strong>Primary background</strong>
    <span>rounded corners</span>
</DwsVertical>

<DwsVertical Name='VerticalDemo_Appearance_Border' BorderColor='DwsColor.Success' BorderWidth='2' BorderStyle='DwsBorderStyle.Dashed' BorderRadius='8' Space='4' Padding='12'>
    <strong>Dashed success border</strong>
    <span>2px wide</span>
</DwsVertical>

Responsive layout

Breakpoints switch spacing and alignment from a screen width up (mobile first); values an entry leaves out are kept from the smaller breakpoint. Resize the window: compact and stretched on phones, a 16px gap with centred items from 768px, more room from 1200px.

Name E-mail address Send
Show Code
Vertical.razor

<DwsVertical Name='VerticalDemo_Responsive_Column' Class='w-100' Space='6' Padding='6' BorderColor='DwsColor.Secondary' Breakpoints='_responsiveBreakpoints'>
    <span class='border rounded px-3 py-2'>Name</span>
    <span class='border rounded px-3 py-2'>E-mail address</span>
    <span class='border rounded px-3 py-2'>Send</span>
</DwsVertical>
Vertical.razor.cs

// From 768px: a 16px gap and padding, centred items. From 1200px: more room, still centred
// (values an entry leaves null keep the smaller breakpoint's value).
private static readonly IReadOnlyList<DwsVerticalBreakpoint> _responsiveBreakpoints =
[
    new DwsVerticalBreakpoint { Breakpoint = DwsVisibilityBreakpoint.MD, Space = 16, Padding = 16, HorizontalAlignment = DwsHorizontalAlignment.Center },
    new DwsVerticalBreakpoint { Breakpoint = DwsVisibilityBreakpoint.XL, Space = 24, Padding = 32 },
];

Adaptive to the parent

With Adaptive the breakpoints follow the width of the parent instead of the window. Both columns below are the same component with the same parameters: the one in the 280px wide sidebar stays compact and stretched, the one in the wider area centres its items with a larger gap (from 576px of parent width). The parent needs a width of its own (here a block element).

Sidebar (280px)
Card 1 Card 2 with more text Card 3
Main area
Card 1 Card 2 with more text Card 3
Show Code
Vertical.razor

<div class='d-flex flex-wrap gap-3'>
    <div class='border rounded p-2' style='width: 280px;'>
        <small class='d-block mb-1'>Sidebar (280px)</small>
        <div>
            <DwsVertical Name='VerticalDemo_Adaptive_Sidebar' Adaptive='true' Class='w-100' Space='6' Breakpoints='_adaptiveBreakpoints'>
                <span class='border rounded px-3 py-2'>Card 1</span>
                <span class='border rounded px-3 py-2'>Card 2 with more text</span>
                <span class='border rounded px-3 py-2'>Card 3</span>
            </DwsVertical>
        </div>
    </div>
    <div class='border rounded p-2 flex-grow-1' style='min-width: min(320px, 100%);'>
        <small class='d-block mb-1'>Main area</small>
        <div>
            <DwsVertical Name='VerticalDemo_Adaptive_Main' Adaptive='true' Class='w-100' Space='6' Breakpoints='_adaptiveBreakpoints'>
                <span class='border rounded px-3 py-2'>Card 1</span>
                <span class='border rounded px-3 py-2'>Card 2 with more text</span>
                <span class='border rounded px-3 py-2'>Card 3</span>
            </DwsVertical>
        </div>
    </div>
</div>
Vertical.razor.cs

// From 576px of parent width up: a 16px gap and centred cards.
private static readonly IReadOnlyList<DwsVerticalBreakpoint> _adaptiveBreakpoints =
[
    new DwsVerticalBreakpoint { Breakpoint = DwsVisibilityBreakpoint.SM, Space = 16, HorizontalAlignment = DwsHorizontalAlignment.Center },
];

Custom element

HtmlTag renders the container as another layout element, e.g. nav for a column of links or ul for a list. The list's default indent is reset by the container; list-unstyled removes the bullets.

  • First
  • Second
  • Third
Show Code
Vertical.razor

<DwsVertical Name='VerticalDemo_Tag_Nav' HtmlTag='nav' Space='4'>
    <DwsAnchorLink Name='VerticalDemo_Tag_ApiLink' href='#apiReference' Color='DwsColor.Link'>API</DwsAnchorLink>
    <DwsLink Name='VerticalDemo_Tag_HorizontalLink' Href='horizontal' Color='DwsColor.Link'>DwsHorizontal</DwsLink>
    <DwsLink Name='VerticalDemo_Tag_SpacerLink' Href='spacer' Color='DwsColor.Link'>DwsSpacer</DwsLink>
</DwsVertical>

<DwsVertical Name='VerticalDemo_Tag_List' HtmlTag='ul' Space='6' Class='list-unstyled'>
    <li class='border rounded px-2'>First</li>
    <li class='border rounded px-2'>Second</li>
    <li class='border rounded px-2'>Third</li>
</DwsVertical>

Nested containers

DwsVertical and DwsHorizontal nest into each other, and a nested container never inherits its parent's spacing. Grow lets a nested container take the free space: the middle row fills the height between header and footer, and the content column fills the width next to the menu and scrolls with Overflow Auto instead of making the page taller. The middle row uses Wrap='DwsFlexWrap.NoWrap': a wrapping row is as tall as its tallest item, so the column inside could not scroll.

Header
Home Products About
Entry 1Entry 2Entry 3Entry 4Entry 5Entry 6Entry 7Entry 8Entry 9Entry 10
Footer
Show Code
Vertical.razor

<DwsVertical Name='VerticalDemo_Nested_Shell' Class='w-100' Height='260' BorderColor='DwsColor.Secondary' BorderRadius='6'>
    <DwsHorizontal Name='VerticalDemo_Nested_Header' Padding='8' Class='border-bottom'>
        <strong>Header</strong>
    </DwsHorizontal>
    <!-- NoWrap: a wrapping row is as tall as its tallest item, so the content column could not scroll -->
    <DwsHorizontal Name='VerticalDemo_Nested_Body' Grow='true' Wrap='DwsFlexWrap.NoWrap'>
        <DwsVertical Name='VerticalDemo_Nested_Menu' Width='120' Space='4' Padding='8' Class='border-end'>
            <span>Home</span>
            <span>Products</span>
            <span>About</span>
        </DwsVertical>
        <DwsVertical Name='VerticalDemo_Nested_Content' Grow='true' Overflow='DwsOverflow.Auto' Space='8' Padding='8'>
            @for (int i = 1; i <= 10; i++)
            {
                <span class='border rounded px-2 py-1'>Entry @i</span>
            }
        </DwsVertical>
    </DwsHorizontal>
    <DwsHorizontal Name='VerticalDemo_Nested_Footer' Padding='8' Class='border-top'>
        <small>Footer</small>
    </DwsHorizontal>
</DwsVertical>

Debug

Debug outlines the container and its direct children, tints the padding (darker) and the content box (lighter, the gaps show through), labels the container with its Name and tag and logs the resolved layout once. A DwsVertical debugs in green, a DwsHorizontal in orange. Use it while building a page and remove it afterwards.


Title
Line A Line B
OK Cancel
Show Code
Vertical.razor

<DwsButton Name='VerticalDemo_Debug_Toggle' Appearance='DwsAppearance.Outline' ButtonSize='DwsSize.Small' OnClick='() => _debug = !_debug'>Debug: @(_debug ? "on" : "off")</DwsButton>

<DwsVertical Name='VerticalDemo_Debug_Outer' Debug='_debug' Space='16' Padding='20'>
    <span class='px-2'>Title</span>
    <DwsVertical Name='VerticalDemo_Debug_Inner' HtmlTag='section' Debug='_debug' Space='8' Padding='16'>
        <span class='px-2'>Line A</span>
        <span class='px-2'>Line B</span>
    </DwsVertical>
    <DwsHorizontal Name='VerticalDemo_Debug_Actions' Debug='_debug' Space='8' Padding='12'>
        <span class='px-2'>OK</span>
        <span class='px-2'>Cancel</span>
    </DwsHorizontal>
</DwsVertical>
Vertical.razor.cs

private bool _debug = true;

Interface-Description

Name Typ Default Description
ChildContent RenderFragment? null The child items stacked in the column.
HtmlTag string "div" Element the container renders as: div, section, article, aside, nav, header, footer, main, form, fieldset, figure, ul, ol, li, menu, p, span, label or address. Anything else falls back to div and is logged as a warning.
Alignment DwsVerticalAlignment DwsVerticalAlignment.Top Vertical alignment of the items within the column (justify-content): Top, Center, Bottom. None leaves it to the stylesheet. JustifyContent wins over it.
JustifyContent DwsJustifyContent? null Vertical distribution of the items (justify-content): FlexStart, Center, FlexEnd, SpaceBetween, SpaceAround, SpaceEvenly. Wins over Alignment when set. Needs free height, e.g. a Height or Stretch.
HorizontalAlignment DwsHorizontalAlignment DwsHorizontalAlignment.None Horizontal alignment of the items within the column (align-items): Left, Center, Right. None stretches them to the column's width. SpaceBetween, SpaceAround and SpaceEvenly have no meaning across a column and are ignored with a warning.
Overflow DwsOverflow? null How content that does not fit is handled: Visible, Hidden, Clip, Scroll or Auto. Pair with Height or MaxHeight for a column that scrolls or clips. Items with a fixed height shrink before they overflow; give them flex-shrink: 0. Null keeps the CSS default (visible).
Space int? null Gap between the items in pixels. Negative values are ignored with a warning.
Padding int? null Inner padding in pixels. Negative values are ignored with a warning.
Margin int? null Outer margin in pixels.
Breakpoints IReadOnlyList<DwsVerticalBreakpoint>? null Layout values (Space, Padding, Margin, Alignment, JustifyContent, HorizontalAlignment) that apply from a viewport width up: SM 576px, MD 768px, LG 992px, XL 1200px, XXL 1400px. Mobile first; values left null are inherited from the smaller breakpoint. An XS entry replaces the component's own parameters; the last entry wins when a breakpoint is listed twice.
Adaptive bool false Applies Breakpoints at the width of the parent element instead of the viewport. The parent becomes a CSS size container, so it needs a width of its own (a block element, a stretched flex or grid item); a shrink-to-fit parent collapses. A parent that declares its own container-type keeps it.
Stretch bool false Takes the full height of the parent (height: 100%). Height is ignored while it is set.
Grow bool false Fills the free space along a flex parent's main axis (the free height in a DwsVertical, the free width in a DwsHorizontal) and may shrink below its content, e.g. a scrolling content area between a header and a footer.
Width int? null Width in pixels.
MinWidth int? null Minimum width in pixels.
MaxWidth int? null Maximum width in pixels.
Height int? null Height in pixels.
MinHeight int? null Minimum height in pixels.
MaxHeight int? null Maximum height in pixels.
BackgroundColor DwsColor DwsColor.Undefined Theme color of the background.
BorderColor DwsColor DwsColor.Undefined Theme color of the border. On its own it draws a solid 1px border.
BorderWidth int? null Border width in pixels. Draws a solid border when no BorderStyle is set.
BorderStyle DwsBorderStyle DwsBorderStyle.None Border style (Solid, Dashed, Dotted, ...). None with a BorderColor or BorderWidth means solid.
BorderRadius int? null Corner radius in pixels.
Debug bool false Outlines the container (in green) and its direct children, tints the padding and content box, labels the container with its Name and tag, and logs the resolved layout once.
OnClickPropagation bool true Whether a click bubbles on to the parent elements. Turn it off so a clickable nested DwsVertical does not click its parent as well.
Name Typ Description
OnClick EventCallback<MouseEventArgs> Raised on click. Not raised while disabled or in permission register mode, where a click selects the container instead.
OnDoubleClick EventCallback<MouseEventArgs> Raised on double click. Not raised while disabled or in permission register mode.
OnMouseEnter EventCallback<MouseEventArgs> Raised when the pointer enters the container. Not raised while disabled or in permission register mode.
OnMouseLeave EventCallback<MouseEventArgs> Raised when the pointer leaves the container. Not raised while disabled or in permission register mode.
Name Typ Default Description
Element ElementReference The associated web component. May be null if accessed before the component is rendered.
ComponentGuid Guid Unique identifier for the component.
TypeString string The name of the component type, obtained from reflection.
Authorized_RegisterEnabled bool false Indicates whether this component is enabled through a permission registry.
Authorized_RegisterSelected bool false Indicates whether this component is selected in permission selection mode.
GetInitializedState bool false Returns whether the component is initialized.
GetRenderModeState DwsRenderMode Returns the current render mode.
GetComponentState DwsComponentStateType Returns the current component state.
GetIsInteractiveState bool false Returns whether the component is interactive.
GetIsPrerenderingState bool false Returns whether the component is prerendering.
GetComponentLoadingState bool false Returns whether the component is loading.
IsFormBusy bool false Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState).
Name Typ Parameters Description
DebugInfo void Logs debug information about the component.
UpdateState void Updates the component's state and triggers StateHasChanged.
UpdateStateAsync Task Asynchronously updates the component's state and triggers StateHasChanged.
Dispose void Disposes the component and releases resources.
FocusAsync ValueTask bool containedInScrollableList Sets focus to the component's element.
Name Typ Default Description
Name string Required unique identifier for the component within its container.
Visible bool true Determines if the component is visible in the UI.
Disabled bool false Disables the form control, ensuring it doesn't participate in form submission.
ComponentNameSpace string The namespace for permission-based access control.
PermissionKey string? null A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins.
Class string Optional CSS class names.
Style string Optional in-line styles.
Tag object An optional user-defined object to store any additional data with the component.
BackReference DwsReference A reference to the enclosing component.
ID string The HTML ID attribute for the component.
AdditionalAttributes Dictionary<string, object> Additional HTML attributes for the component's root element.
IgnorePermissionChecks bool false Bypasses all permission checks for this component.
IgnorePermissionSelection bool false Ignore permission selection mode for this component.
IgnoreFormBusy bool false Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it.
Name Typ Description
OnInitializedCallbackStarted EventCallback Callback when OnInitialized starts.
OnInitializedCallback EventCallback Callback during OnInitialized.
OnInitializedCallbackCompleted EventCallback Callback when OnInitialized completes.
OnInitializedAsyncCallbackStarted EventCallback Callback when OnInitializedAsync starts.
OnInitializedAsyncCallback EventCallback Callback during OnInitializedAsync.
OnInitializedAsyncCallbackCompleted EventCallback Callback when OnInitializedAsync completes.
OnIsComponentLoadingChanged EventCallback<bool> Callback when IsComponentLoading changes.
OnCurrentRenderModeChanged EventCallback<DwsRenderMode> Callback when CurrentRenderMode changes.
OnComponentStateChanged EventCallback<DwsComponentStateType> Callback when ComponentState changes.
An error has occurred. This app may no longer respond until reloaded.