Back to Element Plus

Affix

docs/en-US/component/affix.md

2.13.72.9 KB
Original Source

Affix

Fix the element to a specific visible area.

Basic Usage

Affix is fixed at the top of the page by default.

:::demo You can set offset attribute to change the offset top,the default value is 0.

affix/basic

:::

Target Container

You can set target attribute to keep the affix in the container at all times. It will be hidden if out of range.

:::demo Please notice that the container avoid having scrollbar.

affix/target

:::

Fixed Position

The affix component provides two fixed positions: top and bottom.

:::demo You can set position attribute to change the fixed position, the default value is top.

affix/fixed

:::

API

Attributes

NameDescriptionTypeDefault
offsetoffset distance^[number]0
positionposition of affix^[enum]'top' | 'bottom'top
targettarget container (CSS selector)^[string]
z-indexz-index of affix^[number]100
teleported ^(2.13.0)whether affix element is teleported, if true it will be teleported to where append-to sets^[boolean]false
append-to ^(2.13.0)which element the affix element appends to^[CSSSelector] / ^[HTMLElement]body

Events

NameDescriptionType
changetriggers when fixed state changed^[Function](fixed: boolean) => void
scrolltriggers when scrolling^[Function](value: { scrollTop: number, fixed: boolean }) => void

Slots

NameDescription
defaultcustomize default content

Exposes

NameDescriptionType
updateupdate affix state manually^[Function]() => void
updateRootupdate rootRect info^[Function]() => void