Calm motion: animations on this site only fade, with no movement
Affix
Sticky wrapper with an offset
A wrapper that sticks to the top edge of the window when the page scrolls past it. Use it for a table header, a toolbar, or a section nav. It is plain CSS position: sticky, with one observer that reports when it is stuck.
Basic
Scroll down
Line 1 of the scrolling area.
Line 2 of the scrolling area.
Line 3 of the scrolling area.
Line 4 of the scrolling area.
Line 5 of the scrolling area.
Line 6 of the scrolling area.
Line 7 of the scrolling area.
Line 8 of the scrolling area.
Line 9 of the scrolling area.
Line 10 of the scrolling area.
Line 11 of the scrolling area.
Line 12 of the scrolling area.
Line 13 of the scrolling area.
Line 14 of the scrolling area.
offsetis the gap in px from the top edge, for example below a fixed header. It setstopand the observer margin.- The default slot gets
stuck. Use it to add a plate when the box leaves its resting place.v-model:stuckreads the same state. - Attributes go to the sticky box, not to the probe that the component renders before it.
- Sticky positioning works only inside a parent that is taller than the box. A parent with
overflow: hiddenbreaks it. stuckfollows the window scroll. Inside a scroll container, sticky still works butstuckcan be wrong.
Usage
ts
import { BlessAffix } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
offset | number | 0 | distance in px from the top edge where it sticks. The window scroll sets `stuck`. |
stuck | boolean | false |
Events
| Name | Payload | Description |
|---|---|---|
update:stuck | [value: boolean] |
Slots
| Name | Scope | Description |
|---|---|---|
default | { stuck: boolean; } |