Layout
Layout components provide a flexible system for page-level layout.
Usage
Import the component:
import 'mdui/components/layout.js';
import 'mdui/components/layout-item.js';
import 'mdui/components/layout-main.js';
Import the TypeScript type:
import type { Layout } from 'mdui/components/layout.js';
import type { LayoutItem } from 'mdui/components/layout-item.js';
import type { LayoutMain } from 'mdui/components/layout-main.js';
Introduction:
The layout system is designed to be built from the outside in. Each layout component (<mdui-layout-item>) occupies space on one of the four sides (top, bottom, left, right). Subsequent layout components fill the remaining space.
The following components inherit from <mdui-layout-item> and can also be used as layout components:
<mdui-navigation-bar><mdui-navigation-drawer><mdui-navigation-rail><mdui-bottom-app-bar><mdui-top-app-bar>
The <mdui-layout-main> component occupies the remaining space, where you can place page content.
Examples
Layout Component Order
By default, layout components take up space in the order they appear in the code. The following examples show how order affects <mdui-top-app-bar> and <mdui-navigation-drawer>.
View this example on a large screen.
When <mdui-top-app-bar> appears before <mdui-navigation-drawer>, it takes the full screen width, leaving only the remaining height for <mdui-navigation-drawer>. If you swap the order, <mdui-navigation-drawer> takes the full screen height first, leaving only the remaining width for <mdui-top-app-bar>.
Layout Component Placement
Use the placement attribute to specify the position (top, bottom, left, or right) of the <mdui-layout-item> component in the layout. For <mdui-navigation-drawer> and <mdui-navigation-rail>, the placement attribute specifies their left or right position.
In the following example, two <mdui-layout-item> components are placed on both sides of the application.
Custom Layout Component Order
In most cases, the order of layout components in the code will achieve the desired layout.
However, you can use the order attribute to specify the layout order. Layout components are ordered by ascending order value. When order values are the same, source order is used. The default order for all layout components is 0.
mdui-layout-item API
Properties
| Attribute | Property | Reflect | Type | Default |
|---|---|---|---|---|
placement | placement | 'top' | 'bottom' | 'left' | 'right' | 'top' | |
Determines where the component is placed. Possible values:
| ||||
order | order | number | - | |
Specifies the layout order within the | ||||
mdui-layout-main API
mdui-layout API
Properties
| Attribute | Property | Reflect | Type | Default |
|---|---|---|---|---|
full-height | fullHeight | boolean | false | |
Sets the layout height to 100%. | ||||
Slots
| Name |
|---|
| (default) |
Can contain elements such as |