Enterprise-level component library based on Bootstrap and Blazor

star nuget master download license repo commit

Layout

The container component used for layout, which is convenient to quickly build the basic structure of the page:

Container:Outer container. When the child element contains Header or Footer, all child elements will be arranged vertically up and down, otherwise they will be arranged horizontally.
Header:Top bar container
Side:Sidebar container
Main:Main area container
Footer:Bottom bar container

Component overview

Layout:Layout container, Header Sider Main Footer or Layout itself can be nested under it , Can be placed in any parent container
Header:Top layout, with default style, any elements can be nested under it
Sider:Sidebar, with default style and basic functions, any elements can be nested under it
Main:The content part, with its own default style, any element can be nested under it
Footer:Bottom layout, with default style, any element can be nested under it

Common page layout

Commonly found in Internet website layout

Demo
Header
Main

The middle part adopts the left and right structure, which is mostly used for back-end management website layout. When the Side component is added to the layout template, the upper middle and lower parts are used by default, and the middle part adopts the left and right structure layout.

Demo
Header
Main

The right side adopts an upper, middle and lower structure, which is mostly used for back-end management of the website layout, and the layout is controlled to the left and right structure by setting the IsFullSide attribute value

Demo
Header
Main

The width of the sidebar is controlled by setting the SideWidth property, which supports percentage writing. When setting 0, the width setting function is turned off, and the internal sub-controls are used to fill the width feature

Demo
Header
Main

未设置

Demo
In actual use, the sidebar generally has two uses
  • The sidebar fills the entire screen, and scroll bars appear when the overall height of the menu exceeds the screen
  • The sidebar is not processed and the height is automatically opened by the content
Because there are many ways to use it, this component is not packaged, and it is up to you to decide how to carry out the layout. The following is a practical example in actual use

In order to facilitate your study and comparison, try to use the style inline style in the following practical examples

In this example, a scroll bar appears after clicking the menu on the left to expand

In this example, if the scroll bar does not appear after clicking the left menu to expand, the height of the parent container will be expanded

Please refer to Tab component for practical examples of using Layout component and Tab component together

Demo

Attributes

Loading...
@page "/layouts"

<h3>@LayoutsLocalizer["Title"]</h3>

<h4>@LayoutsLocalizer["H1"]</h4>

<p>
    <code>Container</code>:@((MarkupString)LayoutsLocalizer["Code1"].Value)<br />
    <code>Header</code>:@LayoutsLocalizer["Code2"]<br />
    <code>Side</code>:@LayoutsLocalizer["Code3"]<br />
    <code>Main</code>:@LayoutsLocalizer["Code4"]<br />
    <code>Footer</code>:@LayoutsLocalizer["Code5"]
</p>

<h4>@LayoutsLocalizer["H2"]</h4>
<p>
    <code>Layout</code>:@((MarkupString)LayoutsLocalizer["Code6"].Value)<br />
    <code>Header</code>:@LayoutsLocalizer["Code7"]<br />
    <code>Sider</code>:@LayoutsLocalizer["Code8"]<br />
    <code>Main</code>:@LayoutsLocalizer["Code9"]<br />
    <code>Footer</code>:@LayoutsLocalizer["Code10"]
</p>

<Tips>
    <p>
       @((MarkupString)LayoutsLocalizer["P1"].Value)
    </p>

    <b>@LayoutsLocalizer["b1"]</b>

    <p>@((MarkupString)LayoutsLocalizer["P2"].Value)</p>
</Tips>

<h4>@LayoutsLocalizer["H3"]</h4>

<Block Title="@LayoutsLocalizer["Block1Title"]" Introduction="@LayoutsLocalizer["Block1Intro"]">
    <Layout ShowFooter="true">
        <Header>
            <div class="text-center header">Header</div>
        </Header>
        <Main>
            <div class="text-center main">Main</div>
        </Main>
        <Footer>
            <div class="text-center footer">Footer</div>
        </Footer>
    </Layout>
</Block>

<Block Title="@LayoutsLocalizer["Block2Title"]" Introduction="@LayoutsLocalizer["Block2Intro"]">
    <Layout ShowFooter="true">
        <Header>
            <div class="text-center header">Header</div>
        </Header>
        <Side>
            <div class="text-center side">Side</div>
        </Side>
        <Main>
            <div class="text-center main">Main</div>
        </Main>
        <Footer>
            <div class="text-center footer">Footer</div>
        </Footer>
    </Layout>
</Block>

<Block Title="@LayoutsLocalizer["Block3title"]" Introduction="@LayoutsLocalizer["Block3Intro"]">
    <Layout ShowFooter="true" IsFullSide="true">
        <Header>
            <div class="text-center header">Header</div>
        </Header>
        <Side>
            <div class="text-center side">Side</div>
        </Side>
        <Main>
            <div class="text-center main">Main</div>
        </Main>
        <Footer>
            <div class="text-center footer">Footer</div>
        </Footer>
    </Layout>
</Block>

<Block Title="@LayoutsLocalizer["Block4Title"]" Introduction="@LayoutsLocalizer["Block4Intro"]">
    <Layout ShowFooter="true" SideWidth="200">
        <Header>
            <div class="text-center header">Header</div>
        </Header>
        <Side>
            <div class="text-center side">Side</div>
        </Side>
        <Main>
            <div class="text-center main">Main</div>
        </Main>
        <Footer>
            <div class="text-center footer">Footer</div>
        </Footer>
    </Layout>
</Block>

<Block Title="@LayoutsLocalizer["Block5Title"]">
    <div>@LayoutsLocalizer["D1"]</div>
    <ul class="mt-2">
        <li>
            <div>@LayoutsLocalizer["D2"]</div>
        </li>
        <li>
            <div>@LayoutsLocalizer["D3"]</div>
        </li>
    </ul>
    <div>@LayoutsLocalizer["D4"]</div>
    <p>
       @((MarkupString)LayoutsLocalizer["P3"].Value) 
    </p>
    <p>
        @LayoutsLocalizer["P4"]
    </p>
    <Tips>
        @((MarkupString)LayoutsLocalizer["Tips1"].Value)
    </Tips>
    <div style="width: 100%; height: 300px; border: 1px solid rgba(0,0,0,.125);">
        <Layout ShowFooter="true" SideWidth="160px">
            <Header>
                <div class="d-flex justify-content-center align-items-center" style="height: 50px; color: #fff; margin: 0 -1px;">Header</div>
            </Header>
            <Side>
                <div style="position: absolute; top: 0; left:0; right: 0; bottom: 0; overflow: auto; border-right: 1px solid rgba(0,0,0,.125); padding: 6px 0;">
                    <Menu Items="@IconSideMenuItems" DisableNavigation="true" IsVertical="true"></Menu>
                </div>
            </Side>
            <Main>
                <div style="padding: 1rem;">Main</div>
            </Main>
            <Footer>
                <div class="d-flex justify-content-center align-items-center" style="height: 30px; color: #fff; background-color: #5b6e84; margin: 0 -1px;">Footer</div>
            </Footer>
        </Layout>
    </div>
    <p class="mt-3">
        @LayoutsLocalizer["P5"]
    </p>
    <div style="width: 100%; border: 1px solid rgba(0,0,0,.125);">
        <Layout ShowFooter="true" SideWidth="160px">
            <Header>
                <div class="d-flex justify-content-center align-items-center" style="height: 50px; color: #fff; margin: 0 -1px;">Header</div>
            </Header>
            <Side>
                <div style="border-right: 1px solid rgba(0,0,0,.125); padding: 6px 0;">
                    <Menu Items="@IconSideMenuItems" DisableNavigation="true" IsVertical="true"></Menu>
                </div>
            </Side>
            <Main>
                <div style="padding: 1rem;">Main</div>
            </Main>
            <Footer>
                <div class="d-flex justify-content-center align-items-center" style="height: 30px; color: #fff; background-color: #5b6e84; margin: 0 -1px;">Footer</div>
            </Footer>
        </Layout>
    </div>
    <p class="mt-3">
       @((MarkupString)LayoutsLocalizer["P6"].Value)
    </p>
</Block>

<Block Title="@LayoutsLocalizer["Block6Title"]" Introduction="">
    <Tips>@((MarkupString)LayoutsLocalizer["Tips2"].Value)</Tips>

    <ul class="page-layout-demo-list">
        <li><a href="layout-page" target="_blank">@LayoutsLocalizer["Li"]</a></li>
    </ul>
</Block>

<AttributeTable Items="@GetAttributes()" />
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

using BootstrapBlazor.Components;
using BootstrapBlazor.Shared.Common;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using static BootstrapBlazor.Shared.Pages.Menus;

namespace BootstrapBlazor.Shared.Pages
{
    /// <summary>
    /// 
    /// </summary>
    public sealed partial class Layouts
    {
        [Inject]
        [NotNull]
        private IStringLocalizer<Menus>? Localizer { get; set; }

        [Inject]
        [NotNull]
        private IStringLocalizer<Layouts>? LayoutsLocalizer { get; set; }

        private IEnumerable<MenuItem>? IconSideMenuItems { get; set; }

        /// <summary>
        /// OnInitializedAsync 方法
        /// </summary>
        /// <returns></returns>
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            IconSideMenuItems = await MenusDataGerator.GetIconSideMenuItemsAsync(Localizer);
        }

        private IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
        {
            // TODO: 移动到数据库中
            new AttributeItem() {
                Name = "Header",
                Description = LayoutsLocalizer["Desc1"]!,
                Type = "RenderFragment",
                ValueList = " — ",
                DefaultValue = " — "
            },
            new AttributeItem() {
                Name = "Side",
                Description = LayoutsLocalizer["Desc2"]!,
                Type = "RenderFragment",
                ValueList = " — ",
                DefaultValue = " — "
            },
            new AttributeItem() {
                Name = "SideWidth",
                Description = LayoutsLocalizer["Desc3"]!,
                Type = "string",
                ValueList = " — ",
                DefaultValue = "300px"
            },
            new AttributeItem() {
                Name = "Main",
                Description = LayoutsLocalizer["Desc4"]!,
                Type = "RenderFragment",
                ValueList = " — ",
                DefaultValue = " — "
            },
            new AttributeItem() {
                Name = "Footer",
                Description = LayoutsLocalizer["Desc2"]!,
                Type = "RenderFragment",
                ValueList = " — ",
                DefaultValue = " — "
            },
            new AttributeItem() {
                Name = "Menus",
                Description = LayoutsLocalizer["Desc6"]!,
                Type = "IEnumerable<MenuItem>",
                ValueList = " — ",
                DefaultValue = " — "
            },
            new AttributeItem() {
                Name = "IsFullSide",
                Description = LayoutsLocalizer["Desc7"]!,
                Type = "bool",
                ValueList = "true|false",
                DefaultValue = "false"
            },
            new AttributeItem() {
                Name = "IsPage",
                Description = LayoutsLocalizer["Desc8"]!,
                Type = "bool",
                ValueList = "true|false",
                DefaultValue = "false"
            },
            new AttributeItem() {
                Name = "IsFixedFooter",
                Description = LayoutsLocalizer["Desc9"]!,
                Type = "bool",
                ValueList = "true|false",
                DefaultValue = "false"
            },
            new AttributeItem() {
                Name = "IsFixedHeader",
                Description = LayoutsLocalizer["Desc10"]!,
                Type = "bool",
                ValueList = "true|false",
                DefaultValue = "false"
            },
            new AttributeItem() {
                Name = "ShowCollapseBar",
                Description =  LayoutsLocalizer["Desc11"]!,
                Type = "bool",
                ValueList = "true|false",
                DefaultValue = "false"
            },
            new AttributeItem() {
                Name = "ShowFooter",
                Description =  LayoutsLocalizer["Desc12"]!,
                Type = "bool",
                ValueList = "true|false",
                DefaultValue = "false"
            },
            new AttributeItem() {
                Name = "ShowGotoTop",
                Description =  LayoutsLocalizer["Desc13"]!,
                Type = "bool",
                ValueList = "true|false",
                DefaultValue = "false"
            },
            new AttributeItem() {
                Name = "UseTabSet",
                Description =  LayoutsLocalizer["Desc14"]!,
                Type = "bool",
                ValueList = "true|false",
                DefaultValue = "false"
            },
            new AttributeItem() {
                Name = "AdditionalAssemblies",
                Description =  LayoutsLocalizer["Desc15"]!,
                Type = "IEnumerable<Assembly>",
                ValueList = " — ",
                DefaultValue = " — "
            },
            new AttributeItem() {
                Name = "OnCollapsed",
                Description =  LayoutsLocalizer["Desc16"]!,
                Type = "Func<bool, Task>",
                ValueList = " — ",
                DefaultValue = " — "
            },
            new AttributeItem() {
                Name = "OnClickMenu",
                Description =  LayoutsLocalizer["Desc17"]!,
                Type = "Func<bool, MenuItem>",
                ValueList = " — ",
                DefaultValue = " — "
            }
        };
    }
}

B 站相关视频链接

暂无

交流群

QQ Group:BootstrapAdmin & Blazor 795206915( Full) 675147445 Welcome to join the group discussion
Themes
Bootstrap
Ant Design (完善中)
Bluma (完善中)
LayUI (完善中)
Motronic (已集成)
An error has occurred. This application may no longer respond until reloaded. Reload