生态产品多个设计器现已发布候选版本

查看生态总览
Skip to content

Layout ​

Layout component. This page is the API reference, generated from the source code. Usage guidance and live examples are on the Chinese page.

Anatomy ​

Parts in bold are required.

data-scope="layout": root · header · sider-backdrop · sider · content · footer · sider-trigger

API reference ​

Descriptions of individual props, events and slots are written in Chinese and appear on the Chinese page.

Artifacts ​

LayerValue
Custom element<xh-layout>
Vue componentsXhLayoutContent XhLayoutFooter XhLayoutHeader XhLayoutRoot XhLayoutSider XhLayoutSiderBackdrop XhLayoutSiderTrigger
ComposableuseLayout
State machinelayoutMachine
Skin@xihan-ui/styles/layout.css

Props ​

PropTypeRequired
siderCollapsedboolean
defaultSiderCollapsedboolean
siderWidthstring
siderCollapsedWidthstring
siderPlacementLayoutSiderPlacement
siderBreakpointLayoutBreakpoint
siderPresentationLayoutSiderPresentation
headerFixedboolean
siderFixedboolean
splitboolean
onSiderCollapsedChange(details: LayoutSiderCollapsedChangeDetails) => void
onSiderBreakpoint(details: LayoutSiderBreakpointDetails) => void

Events ​

Custom elements put the payload in detail; Vue emits an event of the same name.

EventPayload
sider-collapsed-changeLayoutSiderCollapsedChangeDetails
sider-breakpointLayoutSiderBreakpointDetails

State ​

The following names are internal to the state machine.

States: expanded · collapsed

Events: SIDER.COLLAPSE · SIDER.EXPAND · SIDER.TOGGLE · CONTROLLED.COLLAPSE · CONTROLLED.EXPAND · PRESS.START · PRESS.END

Guards: isSiderCollapsedControlled

connect API ​

getXxxProps() returns the host attributes of the matching part.

MemberType
siderCollapsedboolean
siderPresentationLayoutSiderPresentation
setSiderCollapsed(next: boolean) => void
getRootProps() => T['element']
getHeaderProps() => T['element']
getSiderBackdropProps() => T['element']
getSiderProps() => T['element']
getContentProps() => T['element']
getFooterProps() => T['element']
getSiderTriggerProps() => T['button']

Accessibility ​

Keyboard ​

Specification: W3C APG. Each row is a stable behavior id that the conformance tests cover; the conditions and effects are described on the Chinese page.

KeysBehavior
Space / Enterlayout.kbd.toggle-sider
Enter / Spacelayout.kbd.press
Escapelayout.kbd.dismiss-sider-sheet

ARIA ​

These attributes are produced by connect.

PartAttributeValue
sider-backdroparia-hidden'true'
sider-triggeraria-controlsid of the sider part
sider-triggeraria-expanded'false' | 'true'

Style reference ​

Skin ​

@xihan-ui/styles/layout.css is written against [data-scope="layout"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-layout in place of data-scope (same specificity) and sits in the xihan.components layer. Put overrides in xihan.overrides; the part selectors work as usual.

Data attributes ​

Produced by connect; valueless attributes are omitted while their condition does not hold.

PartAttributeValue
rootdata-collapsed'' (present only while the condition holds)
rootdata-header-fixed'' (present only while the condition holds)
rootdata-sider-breakpointprops.siderBreakpoint
rootdata-sider-fixed'' (present only while the condition holds)
rootdata-sider-placementprops.siderPlacement
rootdata-sider-presentationresolveSiderPresentation( prop('siderPresentation'), …
rootdata-split'' (present only while the condition holds)
headerdata-fixed'' (present only while the condition holds)
headerdata-xh-liquid'' (present only while the condition holds)
sider-backdropdata-collapsed'' (present only while the condition holds)
sider-backdropdata-instant'' (present only while the condition holds)
siderdata-collapsed'' (present only while the condition holds)
siderdata-fixed'' (present only while the condition holds)
siderdata-instant'' (present only while the condition holds)
siderdata-placementprops.siderPlacement
siderdata-presentationresolveSiderPresentation( prop('siderPresentation'), …
sider-triggerdata-collapsed'' (present only while the condition holds)
sider-triggerdata-pressed'' (present only while the condition holds)
sider-triggerdata-xh-action-control''
sider-triggerdata-xh-action-display'always'
sider-triggerdata-xh-action-profile'text'
sider-triggerdata-xh-action-size'sm'
sider-triggerdata-xh-action-variant'ghost'

CSS variables ​

The public override slots, generated from what the standalone skin actually consumes.

VariablePartCSS propertyStateDefault from
--xh-layout-bgrootbackgrounddefault--xh-bg-page
--xh-layout-borderfooter
header
root
sider
border-block-end
border-block-start
border-inline-end
border-inline-start
default
fixed
material=liquid
placement=end
placement=start
presentation=sheet
split
where([data-material='liquid'])
xh-liquid
--xh-border-default
--xh-border-subtle
--xh-material-elevated-border
--xh-material-liquid-border
--xh-layout-content-paddingcontentpaddingdefault--xh-space-4
--xh-layout-fgrootcolordefault--xh-fg-default
--xh-layout-footer-bgfooterbackgrounddefault--xh-bg-surface
--xh-layout-footer-paddingfooterpaddingdefault--xh-space-3
--xh-layout-header-bgheaderbackgrounddefault
fixed
material=liquid
where([data-material='liquid'])
xh-liquid
--xh-_liquid-bg
--xh-bg-surface
--xh-layout-header-gapheadergapdefault--xh-space-3
--xh-layout-header-hheader
root
sider
block-size
grid-template-rows
inset-block-start
max-block-size
default
fixed
header-fixed
sider-fixed
--xh-app-header-h
--xh-layout-header-layerheaderz-indexfixed--xh-layer-sticky
--xh-layout-header-pxheaderpadding-inlinedefault--xh-space-4
--xh-layout-scrollport-hsidermax-block-sizefixed
presentation=sheet
100dvh
100vh
--xh-layout-sider-backdrop-bgsider-backdropbackgrounddefault--xh-bg-overlay
--xh-layout-sider-backdrop-layersider-backdropz-indexdefault--xh-layer-drawer
--xh-layout-sider-bgsiderbackgrounddefault
presentation=sheet
--xh-bg-surface
--xh-material-elevated-bg
--xh-layout-sider-collapsed-wroot
sider
inline-sizecollapsed
sider-breakpoint
--xh-sider-collapsed-w
--xh-layout-sider-layersiderz-indexpresentation=sheet--xh-layer-drawer
--xh-layout-sider-paddingsiderpadding
padding-block-end
padding-block-start
padding-inline
default
presentation=sheet
--xh-_layout-sider-padding
--xh-layout-sider-shadowsiderbox-shadowpresentation=sheet--xh-material-elevated-shadow
--xh-layout-sider-trigger-bgsider-trigger--xh-ink-surface
background-color
default
xh-ink-surface
--xh-_action-variant-bg-rest
--xh-layout-sider-trigger-bg-activesider-triggerbackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-layout-sider-trigger-bg-hoversider-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-layout-sider-trigger-fgsider-triggercolordefault
disabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-fg-hover
--xh-_action-variant-fg-pressed
--xh-_action-variant-fg-rest
--xh-layout-sider-trigger-gapsider-triggergapdefault--xh-_action-profile-gap
--xh-layout-sider-trigger-pxsider-triggerpadding-inlinedefault--xh-_action-profile-padding-inline
--xh-layout-sider-trigger-radiussider-triggerborder-radiusdefault--xh-_action-profile-radius
--xh-layout-sider-wroot
sider
inline-size@media (min-width: 1024px)
@media (min-width: 1280px)
@media (min-width: 640px)
@media (min-width: 768px)
default
presentation=sheet
sider-breakpoint=lg
sider-breakpoint=md
sider-breakpoint=sm
sider-breakpoint=xl
--xh-sider-w

Released under The MIT License