Slide
Slide — wraps a child and slides it in or out from a chosen
edge when an external Signal<bool> toggles. Common patterns:
drawers, snackbars, side panels, banner notifications.
Public types
| Kind | Name |
|---|---|
enum | SlideEdge — Which edge the child slides in from / out to |
struct | Slide — Wraps a child widget and translates it in or out from one edge of its slot whenever visible flips |
Public functions
Slide
| Returns | Function |
|---|---|
| Constructors | |
Self | new(visible: impl Into<Prop<bool>>) |
| Builder methods | |
Self | from(edge: SlideEdge) |
Self | child(widget: impl teksilo_core::IntoTeksiChild) |
Self | child_opt(widget: Option<impl teksilo_core::IntoTeksiChild>) |
Detailed description
let visible = ctx.signal(false);
ctx.add(
Slide::new(visible.clone())
.from(SlideEdge::Bottom)
.child(snackbar_content),
);
// ...elsewhere:
visible.set(true); // slides in from below
Layout semantics
Slide's own slot stays in its laid-out position; the child is
translated within the slot via place_children. The wrapper
clips so a sliding-in child doesn't bleed past the slot edges.
The wrapper reports the child's full natural size at all
progress values — siblings don't reflow as the child slides.
For a "slide + fade" effect (notification snackbar), wrap the
child in Fade before passing it to Slide:
#![allow(unused)] fn main() { use teksilo_widgets::animations::{Slide, Fade, SlideEdge}; use teksilo_widgets::primitives::TextWidget; use teksilo_core::signal::Signal; use teksilo_i18n::lit; let visible = Signal::new(false); let snackbar_content = TextWidget::new(lit!("Changes saved")); let _w = Slide::new(visible.clone()) .from(SlideEdge::Bottom) .child(Fade::new(visible).child(snackbar_content)); }
Reduced motion
Honours prefers-reduced-motion: snaps the child instantly into
or out of position instead of tweening.
API reference
📖 Full rustdoc API for this module
pub enum SlideEdge
Import: use teksilo::widgets::SlideEdge;
Which edge the child slides in from / out to.
Leading and Trailing honour layout direction (RTL flips them);
the resolution happens in place_children via the layout context.
#![allow(unused)] fn main() { pub enum SlideEdge { /* variants */ } }
Variants
Leading— Slide from the leading edge (left in LTR, right in RTL). Suits drawers and side panels.Trailing— Slide from the trailing edge (right in LTR, left in RTL).Top— Slide from the top edge. Suits drop-down banners or navigation bars.Bottom— Slide from the bottom edge. Suits snackbars and bottom sheets.
pub struct Slide
Import: use teksilo::widgets::Slide;
Wraps a child widget and translates it in or out from one edge of
its slot whenever visible flips.
#![allow(unused)] fn main() { pub struct Slide { /* fields */ } }
Methods
pub fn new(visible: impl Into<Prop<bool>>) -> Self
Create a slide wrapper bound to visible; accepts a static bool
or a reactive Signal<bool>. Defaults to SlideEdge::Bottom —
override with .from(...).
pub fn from(mut self, edge: SlideEdge) -> Self (default: SlideEdge::Bottom)
Edge the child slides in from (and out to).
pub fn child(mut self, widget: impl teksilo_core::IntoTeksiChild) -> Self
Inline child widget (deferred insertion).
pub fn child_opt(self, widget: Option<impl teksilo_core::IntoTeksiChild>) -> Self
Attach widget when it is Some, and do nothing when it is None.
The conditional-child form. teksu!'s if without an else lowers to
this, and it is what cond.then(|| w) is for in a builder chain. None
adds no arena node, so nothing is laid out, painted, or published to the
accessibility tree, and a stack applies no spacing around it.