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

查看生态总览
Skip to content

FloatingPanel ​

Overlays 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="floating-panel": root · trigger · positioner · content · header · title · drag-trigger · resize-trigger · window-state-trigger · close-trigger · body

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-floating-panel>
Vue componentsXhFloatingPanelBody XhFloatingPanelCloseTrigger XhFloatingPanelContent XhFloatingPanelDragTrigger XhFloatingPanelHeader XhFloatingPanelPositioner XhFloatingPanelResizeTrigger XhFloatingPanelRoot XhFloatingPanelTitle XhFloatingPanelTrigger XhFloatingPanelWindowStateTrigger
ComposableuseFloatingPanel
State machinefloatingPanelMachine
Skin@xihan-ui/styles/floating-panel.css

Props ​

PropTypeRequired
openboolean
defaultOpenboolean
positionFloatingPanelPosition
defaultPositionFloatingPanelPosition
dimensionsFloatingPanelSize
defaultDimensionsFloatingPanelSize
minSizeFloatingPanelSize
maxSizeFloatingPanelSize
windowStateFloatingPanelWindowState
defaultWindowStateFloatingPanelWindowState
draggableboolean
resizableboolean
disabledboolean
partsPick<TitleDescriptionParts, 'title'>
translationsPartial<FloatingPanelTranslations>
onOpenChange(details: FloatingPanelOpenChangeDetails) => void
onPositionChange(details: FloatingPanelPositionChangeDetails) => void
onDimensionsChange(details: FloatingPanelDimensionsChangeDetails) => void
onWindowStateChange(details: FloatingPanelWindowStateChangeDetails) => void
onDragStart(details: FloatingPanelDragStartDetails) => void
onDragEnd(details: FloatingPanelDragEndDetails) => void

Events ​

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

EventPayload
open-changeFloatingPanelOpenChangeDetails
position-changeFloatingPanelPositionChangeDetails
dimensions-changeFloatingPanelDimensionsChangeDetails
window-state-changeFloatingPanelWindowStateChangeDetails
drag-startFloatingPanelDragStartDetails
drag-endFloatingPanelDragEndDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhFloatingPanelRootdefaultFloatingPanelRootSlotProps

React adapter props ​

Only the props each component declares itself: DOM attributes inherited from ComponentPropsWithRef are left out, and root props already listed in the Props table are not repeated. The Vue counterpart is the slot table above.

React componentPropTypeRequired
XhFloatingPanelPositionercontainer() => Element | null
XhFloatingPanelResizeTriggeredgeFloatingPanelResizeEdgeYes
XhFloatingPanelRootchildrenSlotChildren<FloatingPanelRootSlotProps>
XhFloatingPanelWindowStateTriggerwindowStateFloatingPanelWindowStateYes

State ​

Public state is written to data-state.

PartValues
root'open' | 'closed'
trigger'open' | 'closed'
positioner'open' | 'closed'
content'open' | 'closed'
window-state-trigger'on' | 'off'

The following names are internal to the state machine.

States: closed · open · open.dragging · open.idle · open.resizing

Events: OPEN · CLOSE · TOGGLE · CONTROLLED.OPEN · CONTROLLED.CLOSE · POSITION.SET · POSITION.NUDGE · DIMENSIONS.SET · DIMENSIONS.NUDGE · WINDOW_STATE.SET · DRAG.START · RESIZE.START · DRAG.MOVE · DRAG.END · PRESS.START · PRESS.END · WINDOW_STATE.SETTLED · WINDOW.RAISE · WINDOW.DEPTH

Guards: canDrag · canInteract · canResize · isOpenControlled · canPress

connect API ​

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

MemberType
openboolean
windowStateFloatingPanelWindowState
positionFloatingPanelPosition
dimensionsFloatingPanelSize
draggingboolean
resizingboolean
disabledboolean
canDragboolean
canResizeboolean
setOpen(next: boolean) => void
setPosition(next: FloatingPanelPosition) => void
setDimensions(next: FloatingPanelSize) => void
setWindowState(next: FloatingPanelWindowState) => void
getRootProps() => T['element']
getTriggerProps() => T['button']
getPositionerProps() => T['element']
getContentProps() => T['element']
getHeaderProps() => T['element']
getTitleProps() => T['element']
getDragTriggerProps() => T['button']
getResizeTriggerProps(props: FloatingPanelResizeTriggerProps) => T['element']
getWindowStateTriggerProps(props: FloatingPanelWindowStateTriggerProps) => T['button']
getCloseTriggerProps() => T['button']
getBodyProps() => T['element']

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
Escapefloating-panel.kbd.escape
ArrowUp / ArrowDown / ArrowLeft / ArrowRightfloating-panel.kbd.move
Shift+ArrowUp / Shift+ArrowDown / Shift+ArrowLeft / Shift+ArrowRightfloating-panel.kbd.move-large
Enter / Spacefloating-panel.kbd.recenter
ArrowUp / ArrowDown / ArrowLeft / ArrowRightfloating-panel.kbd.resize
Shift+ArrowUp / Shift+ArrowDown / Shift+ArrowLeft / Shift+ArrowRightfloating-panel.kbd.resize-large
Enter / Spacefloating-panel.kbd.press

ARIA ​

These attributes are produced by connect.

PartAttributeValue
triggeraria-controlsid of the content part
triggeraria-expanded'true' | 'false'
triggeraria-haspopup'dialog'
contentaria-labelledbyid of the title part | undefined
contentaria-modal'false'
contentrole'dialog'
drag-triggeraria-disabled'false' | 'true'
drag-triggeraria-labellabel.dragTrigger
resize-triggeraria-controlsid of the content part
resize-triggeraria-disabled'false' | 'true'
resize-triggeraria-labellabel.resizeTrigger(item.edge)
resize-triggeraria-orientation'vertical' | 'horizontal'
resize-triggeraria-valuemaxString(Math.round(valueMax)) | undefined
resize-triggeraria-valueminString(Math.round(horizontal ? minSize.width : minSiz…
resize-triggeraria-valuenowString(Math.round(horizontal ? dimensions.width : dim…
resize-triggeraria-valuetextlabel.resizeValueText(dimensions)
resize-triggerrole'separator'
window-state-triggeraria-disabled'true' | 'false'
window-state-triggeraria-labellabel.windowStateTrigger(item.windowState)
window-state-triggeraria-pressed'true' | 'false'
close-triggeraria-labellabel.close

Style reference ​

Skin ​

@xihan-ui/styles/floating-panel.css is written against [data-scope="floating-panel"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-floating-panel 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-disabled'' (present only while the condition holds)
rootdata-dragging'' (present only while the condition holds)
rootdata-resizing'' (present only while the condition holds)
rootdata-state'open' | 'closed'
rootdata-window-statecontext.get('windowState')
triggerdata-pressed'' (present only while the condition holds)
triggerdata-state'open' | 'closed'
triggerdata-xh-action-control''
triggerdata-xh-action-display'always'
triggerdata-xh-action-profile'text'
triggerdata-xh-action-size'md'
triggerdata-xh-action-variant'outline'
positionerdata-animating'' (present only while the condition holds)
positionerdata-instant'' (present only while the condition holds)
positionerdata-positioned''
positionerdata-state'open' | 'closed'
positionerdata-window-statecontext.get('windowState')
contentdata-disabled'' (present only while the condition holds)
contentdata-dragging'' (present only while the condition holds)
contentdata-resizing'' (present only while the condition holds)
contentdata-state'open' | 'closed'
contentdata-window-statecontext.get('windowState')
contentdata-xh-material'frosted'
headerdata-dragging'' (present only while the condition holds)
headerdata-window-statecontext.get('windowState')
drag-triggerdata-disabled'' (present only while the condition holds)
drag-triggerdata-dragging'' (present only while the condition holds)
resize-triggerdata-disabled'' (present only while the condition holds)
resize-triggerdata-edgeitem.edge
resize-triggerdata-resizing'' (present only while the condition holds)
window-state-triggerdata-disabled'' (present only while the condition holds)
window-state-triggerdata-pressed'' (present only while the condition holds)
window-state-triggerdata-state'on' | 'off'
window-state-triggerdata-target-window-stateitem.windowState
window-state-triggerdata-xh-action-control''
window-state-triggerdata-xh-action-display'always'
window-state-triggerdata-xh-action-profile'icon'
window-state-triggerdata-xh-action-size'sm'
window-state-triggerdata-xh-action-variant'ghost'
close-triggerdata-pressed'' (present only while the condition holds)
close-triggerdata-xh-action-control''
close-triggerdata-xh-action-display'always'
close-triggerdata-xh-action-profile'icon'
close-triggerdata-xh-action-size'sm'
close-triggerdata-xh-action-variant'ghost'
bodydata-window-statecontext.get('windowState')

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-floating-panel-action-bg-activeclose-trigger
window-state-trigger
background-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-floating-panel-action-bg-hoverclose-trigger
window-state-trigger
background-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-floating-panel-action-bg-onwindow-state-trigger--xh-ink-surface
background-color
focus-visible
state=on
xh-ink-surface
--xh-bg-brand-subtle
--xh-floating-panel-action-bg-on-activewindow-state-triggerbackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
state=on
--xh-bg-brand-subtle-active
--xh-floating-panel-action-bg-on-hoverwindow-state-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
state=on
--xh-bg-brand-subtle-hover
--xh-floating-panel-action-fgclose-trigger
window-state-trigger
colordefault--xh-material-frosted-fg-muted
--xh-floating-panel-action-fg-activeclose-trigger
window-state-trigger
colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-fg-pressed
--xh-floating-panel-action-fg-hoverclose-trigger
window-state-trigger
colordisabled
focus-visible
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-fg-focus-visible
--xh-_action-variant-fg-hover
--xh-floating-panel-action-fg-onwindow-state-triggercolordisabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
state=on
--xh-fg-on-brand-subtle
--xh-floating-panel-action-radiuswindow-state-triggerborder-radiusdefault--xh-shape-control
--xh-floating-panel-action-sizewindow-state-triggerblock-size
inline-size
default
xh-action-profile=icon
--xh-_action-profile-visual-size
--xh-floating-panel-bgcontentbackgroundnot([data-xh-action-control])
xh-material=frosted
--xh-_material-bg
--xh-floating-panel-body-pxbodypadding-inlinedefault--xh-surface-px-sm
--xh-floating-panel-body-pybodypadding-blockdefault--xh-surface-py-sm
--xh-floating-panel-bordercontentbordernot([data-xh-action-control])
xh-material=frosted
--xh-_material-border
--xh-floating-panel-close-radiusclose-triggerborder-radiusdefault--xh-shape-control
--xh-floating-panel-close-sizeclose-triggerblock-size
inline-size
default
xh-action-profile=icon
--xh-_action-profile-visual-size
--xh-floating-panel-corner-sizepositioner
resize-trigger
height
width
edge=ne
edge=nw
edge=se
edge=sw
--xh-space-4
--xh-floating-panel-fgcontentcolornot([data-xh-action-control])
xh-material=frosted
--xh-_material-fg
--xh-floating-panel-handle-sizepositioner
resize-trigger
height
width
edge=e
edge=n
edge=s
edge=w
--xh-space-2
--xh-floating-panel-header-bgheaderbackgrounddefault--xh-material-frosted-bg
--xh-floating-panel-header-borderheaderborder-block-enddefault--xh-material-frosted-separator
--xh-floating-panel-header-gapheadergapdefault--xh-control-gap-sm
--xh-floating-panel-header-pxheaderpadding-inlinedefault--xh-space-3
--xh-floating-panel-header-pyheaderpadding-blockdefault--xh-space-2
--xh-floating-panel-icon-sizeclose-trigger
content
root
trigger
window-state-trigger
--xh-icon-sizedefault--xh-_action-profile-glyph-size
--xh-glyph-size-md
--xh-floating-panel-layerpositionerz-indexdefault--xh-_layer
--xh-floating-panel-radiuscontentborder-radiusdefault--xh-shape-overlay
--xh-floating-panel-shadowcontentbox-shadownot([data-xh-action-control])
xh-material=frosted
--xh-_material-shadow
--xh-floating-panel-title-fgtitlecolordefault--xh-material-frosted-fg
--xh-floating-panel-title-font-sizetitlefont-sizedefault--xh-text-label-size
--xh-floating-panel-title-font-weighttitlefont-weightdefault--xh-font-weight-medium
--xh-floating-panel-trigger-bgtrigger--xh-ink-surface
background-color
default
focus-visible
xh-ink-surface
--xh-_action-variant-bg-focus-visible
--xh-_action-variant-bg-rest
--xh-floating-panel-trigger-bordertriggerborder
border-color
default
focus-visible
--xh-_action-variant-border-focus-visible
--xh-_action-variant-border-rest
--xh-floating-panel-trigger-fgtriggercolordefault
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-fg-focus-visible
--xh-_action-variant-fg-hover
--xh-_action-variant-fg-pressed
--xh-_action-variant-fg-rest
--xh-floating-panel-trigger-htriggerblock-size
inline-size
default
xh-action-profile=icon
--xh-_action-profile-visual-size
--xh-floating-panel-trigger-pxtriggerpadding-inlinedefault--xh-_action-profile-padding-inline
--xh-floating-panel-trigger-radiustriggerborder-radiusdefault--xh-shape-control

Released under The MIT License