MDUIDocs
Copy llms.txt linkCopy llms-full.txt linkView this page in MarkdownDiscuss this page with ChatGPTDiscuss full project docs with ChatGPT
Preset Colors
Custom Color
Extract from Wallpaper
Please select a wallpaper
Getting Started
AI-Assisted Development
Styles
Integration with Frameworks
Components
Avatar Badge BottomAppBar Button ButtonIcon Card Checkbox Chip CircularProgress Collapse Dialog Divider Dropdown Fab Icon Layout LinearProgress List Menu NavigationBar NavigationDrawer NavigationRail Radio RangeSlider Select SegmentedButton Slider Snackbar Switch Tabs TextField Tooltip TopAppBar
Functions
Libraries

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:

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

AttributePropertyReflectTypeDefault
placementplacement'top' | 'bottom' | 'left' | 'right''top'

Determines where the component is placed. Possible values:

  • top: Places the component at the top.
  • bottom: Places the component at the bottom.
  • left: Places the component on the left.
  • right: Places the component on the right.
orderordernumber-

Specifies the layout order within the <mdui-layout> component. Items are sorted in ascending order. The default value is 0.

Slots

Name
(default)

Can contain any content.

mdui-layout-main API

Slots

Name
(default)

Can contain any content.

mdui-layout API

Properties

AttributePropertyReflectTypeDefault
full-heightfullHeightbooleanfalse

Sets the layout height to 100%.

Slots

Name
(default)

Can contain elements such as <mdui-top-app-bar>, <mdui-bottom-app-bar>, <mdui-navigation-bar>, <mdui-navigation-drawer>, <mdui-navigation-rail>, <mdui-layout-item>, and <mdui-layout-main>.

On this page