Reference
Sticky
A box that sticks to the top of its scrolling parent (offset: below it) as the page scrolls past, marked data-stuck while it is stuck.
Sticky(offset: String, bottom: Bool) { … }
Since 6.2.0
Changelog
7.07.0.19: fixes and small changes
7.0.18: fixes and small changes
7.0.17: fixes and small changes
7.0.16: fixes and small changes
7.0.15: fixes and small changes
7.0.14: fixes and small changes
7.0.13: fixes and small changes
7.0.12: fixes and small changes
7.0.11: fixes and small changes
7.0.10: fixes and small changes
7.0.9: fixes and small changes
7.0.8: fixes and small changes
7.0.7: fixes and small changes
7.0.6: fixes and small changes
7.0.5: fixes and small changes
7.0.4: fixes and small changes
7.0.3: fixes and small changes
7.0.2: fixes and small changes
7.0.1: fixes and small changes
7.0.0: fixes and small changes
Example
ScrollArea(height: "240px", label: "Changelog") {
style { border: 1px solid $color-border; border-radius: $radius-md }
Sticky {
style { background: $color-background; padding: 0.5rem 0.75rem; border-bottom: 1px solid $color-border }
Row(justify: .between, align: .center) {
Text("Changelog").bold
Badge("7.0").primary
}
}
for v in (0..20).map(i => 19 - i).map(n => "7.0.{n}: fixes and small changes") by v {
Text(v) { style { padding: 0.5rem 0.75rem } }
}
}
Below a fixed header
Sticky(offset: "64px") {
Row(gap: .sm) { Button("Bold").sm Button("Italic").sm }
}
Stuck to the bottom
Sticky.bottom {
Row(justify: .end, gap: .sm) { Button("Cancel") Button("Save").primary }
}
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
offset: | String | 0 | A CSS length, |
bottom: | Bool | false | It sticks to the bottom of its scrolling parent instead of the top; |
Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.
Flags and cases
A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.
.bottom
Events
Every element also takes the props, the events and the attribute families listed on every element.
Slots
children
Renders with the class wf-sticky, stable across releases, so a stylesheet may target it.