taffy/style/
alignment.rs

1//! Style types for controlling alignment
2
3/// Used to control how child nodes are aligned.
4/// For Flexbox it controls alignment in the cross axis
5/// For Grid it controls alignment in the block axis
6///
7/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items)
8#[derive(Copy, Clone, PartialEq, Eq, Debug)]
9#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
10pub enum AlignItems {
11    /// Items are packed toward the start of the axis
12    Start,
13    /// Items are packed toward the end of the axis
14    End,
15    /// Items are packed towards the flex-relative start of the axis.
16    ///
17    /// For flex containers with flex_direction RowReverse or ColumnReverse this is equivalent
18    /// to End. In all other cases it is equivalent to Start.
19    FlexStart,
20    /// Items are packed towards the flex-relative end of the axis.
21    ///
22    /// For flex containers with flex_direction RowReverse or ColumnReverse this is equivalent
23    /// to Start. In all other cases it is equivalent to End.
24    FlexEnd,
25    /// Items are packed along the center of the cross axis
26    Center,
27    /// Items are aligned such as their baselines align
28    Baseline,
29    /// Stretch to fill the container
30    Stretch,
31}
32/// Used to control how child nodes are aligned.
33/// Does not apply to Flexbox, and will be ignored if specified on a flex container
34/// For Grid it controls alignment in the inline axis
35///
36/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items)
37pub type JustifyItems = AlignItems;
38/// Used to control how the specified nodes is aligned.
39/// Overrides the parent Node's `AlignItems` property.
40/// For Flexbox it controls alignment in the cross axis
41/// For Grid it controls alignment in the block axis
42///
43/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-self)
44pub type AlignSelf = AlignItems;
45/// Used to control how the specified nodes is aligned.
46/// Overrides the parent Node's `JustifyItems` property.
47/// Does not apply to Flexbox, and will be ignored if specified on a flex child
48/// For Grid it controls alignment in the inline axis
49///
50/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self)
51pub type JustifySelf = AlignItems;
52
53/// Sets the distribution of space between and around content items
54/// For Flexbox it controls alignment in the cross axis
55/// For Grid it controls alignment in the block axis
56///
57/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content)
58#[derive(Copy, Clone, PartialEq, Eq, Debug)]
59#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
60pub enum AlignContent {
61    /// Items are packed toward the start of the axis
62    Start,
63    /// Items are packed toward the end of the axis
64    End,
65    /// Items are packed towards the flex-relative start of the axis.
66    ///
67    /// For flex containers with flex_direction RowReverse or ColumnReverse this is equivalent
68    /// to End. In all other cases it is equivalent to Start.
69    FlexStart,
70    /// Items are packed towards the flex-relative end of the axis.
71    ///
72    /// For flex containers with flex_direction RowReverse or ColumnReverse this is equivalent
73    /// to Start. In all other cases it is equivalent to End.
74    FlexEnd,
75    /// Items are centered around the middle of the axis
76    Center,
77    /// Items are stretched to fill the container
78    Stretch,
79    /// The first and last items are aligned flush with the edges of the container (no gap)
80    /// The gap between items is distributed evenly.
81    SpaceBetween,
82    /// The gap between the first and last items is exactly THE SAME as the gap between items.
83    /// The gaps are distributed evenly
84    SpaceEvenly,
85    /// The gap between the first and last items is exactly HALF the gap between items.
86    /// The gaps are distributed evenly in proportion to these ratios.
87    SpaceAround,
88}
89
90/// Sets the distribution of space between and around content items
91/// For Flexbox it controls alignment in the main axis
92/// For Grid it controls alignment in the inline axis
93///
94/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content)
95pub type JustifyContent = AlignContent;