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/// Controls alignment of an individual node
39///
40/// Overrides the parent Node's `AlignItems` property.
41/// For Flexbox it controls alignment in the cross axis
42/// For Grid it controls alignment in the block axis
43///
44/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-self)
45pub type AlignSelf = AlignItems;
46/// Controls alignment of an individual node
47///
48/// Overrides the parent Node's `JustifyItems` property.
49/// Does not apply to Flexbox, and will be ignored if specified on a flex child
50/// For Grid it controls alignment in the inline axis
51///
52/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self)
53pub type JustifySelf = AlignItems;
54
55/// Sets the distribution of space between and around content items
56/// For Flexbox it controls alignment in the cross axis
57/// For Grid it controls alignment in the block axis
58///
59/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content)
60#[derive(Copy, Clone, PartialEq, Eq, Debug)]
61#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
62pub enum AlignContent {
63    /// Items are packed toward the start of the axis
64    Start,
65    /// Items are packed toward the end of the axis
66    End,
67    /// Items are packed towards the flex-relative start of the axis.
68    ///
69    /// For flex containers with flex_direction RowReverse or ColumnReverse this is equivalent
70    /// to End. In all other cases it is equivalent to Start.
71    FlexStart,
72    /// Items are packed towards the flex-relative end of the axis.
73    ///
74    /// For flex containers with flex_direction RowReverse or ColumnReverse this is equivalent
75    /// to Start. In all other cases it is equivalent to End.
76    FlexEnd,
77    /// Items are centered around the middle of the axis
78    Center,
79    /// Items are stretched to fill the container
80    Stretch,
81    /// The first and last items are aligned flush with the edges of the container (no gap)
82    /// The gap between items is distributed evenly.
83    SpaceBetween,
84    /// The gap between the first and last items is exactly THE SAME as the gap between items.
85    /// The gaps are distributed evenly
86    SpaceEvenly,
87    /// The gap between the first and last items is exactly HALF the gap between items.
88    /// The gaps are distributed evenly in proportion to these ratios.
89    SpaceAround,
90}
91
92/// Sets the distribution of space between and around content items
93/// For Flexbox it controls alignment in the main axis
94/// For Grid it controls alignment in the inline axis
95///
96/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content)
97pub type JustifyContent = AlignContent;