@@ -17,9 +17,20 @@ use crate::core::{
1717use crate :: { Pod , PropertyTuple as _, ViewCtx , WidgetView } ;
1818
1919/// A linear container.
20-
21- // TODO - Add example
22-
20+ /// ```
21+ /// use xilem::view::{label, stack, CrossAxisAlignment, StackExt};
22+ /// # use xilem::{WidgetView};
23+ ///
24+ /// # fn view<State: 'static>() -> impl WidgetView<State> {
25+ /// stack((
26+ /// label("Item"),
27+ /// label("Another Item"),
28+ /// label("More items"),
29+ /// // ...
30+ /// ))
31+ /// # }
32+ /// ```
33+ /// ```
2334pub fn stack < State , Action , Seq : StackSequence < State , Action > > (
2435 sequence : Seq ,
2536) -> Stack < Seq , State , Action > {
@@ -34,7 +45,7 @@ pub fn stack<State, Action, Seq: StackSequence<State, Action>>(
3445 }
3546}
3647
37- /// A layout where the children are laid out in a row.
48+ /// A linear container laid out in a row.
3849///
3950/// This is equivalent to [`stack`] with a pre-applied horizontal
4051/// [`direction`](Stack::direction).
@@ -59,7 +70,7 @@ pub struct Stack<Seq, State, Action = ()> {
5970}
6071
6172impl < Seq , State , Action > Stack < Seq , State , Action > {
62- /// Set the flex direction (see [`Axis`]).
73+ /// Set the direction the container grows in (see [`Axis`]).
6374 pub fn direction ( mut self , axis : Axis ) -> Self {
6475 self . axis = axis;
6576 self
@@ -360,7 +371,7 @@ impl ElementSplice<StackElement> for StackSplice<'_, '_> {
360371 }
361372}
362373
363- /// `StackSequence` is what allows an input to the grid that contains all the grid elements.
374+ /// `StackSequence` is what allows an input to the stack that contains all the stack elements.
364375pub trait StackSequence < State , Action = ( ) > :
365376 ViewSequence < State , Action , ViewCtx , StackElement >
366377{
@@ -371,12 +382,25 @@ impl<Seq, State, Action> StackSequence<State, Action> for Seq where
371382{
372383}
373384
374- /// A trait which extends a [`WidgetView`] with methods to provide parameters for a grid item
385+ /// A trait which extends a [`WidgetView`] with methods to provide parameters for a stack item
375386pub trait StackExt < State , Action > : WidgetView < State , Action > {
376387 /// Applies [`CrossAxisAlignment`] to this view. This allows the view
377388 /// to be placed as a child within a [`Stack`] [`View`].
378-
379- // TODO - Example
389+ ///
390+ /// # Example
391+ /// ```
392+ /// use xilem::view::{button, prose, stack, CrossAxisAlignment, StackExt};
393+ /// # use xilem::{WidgetView};
394+ ///
395+ /// # fn view<State: 'static>() -> impl WidgetView<State> {
396+ /// stack((
397+ /// prose("some text"),
398+ /// prose("more text"),
399+ /// button("click me", |_| ()).stack_item(CrossAxisAlignment::Center),
400+ /// prose("footer"),
401+ /// ))
402+ /// # }
403+ /// ```
380404 fn stack_item ( self , alignment : CrossAxisAlignment ) -> StackItem < Self , State , Action >
381405 where
382406 State : ' static ,
0 commit comments