@fpkit/acss 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libs/{chunk-2NRIP6RB.cjs → chunk-2C3YLBWP.cjs} +3 -3
- package/libs/{chunk-NWJDAHP6.cjs → chunk-2GJHKWEK.cjs} +3 -3
- package/libs/{chunk-FVROL3V5.js → chunk-2JCDEC32.js} +3 -3
- package/libs/{chunk-IRLFZ3OL.js → chunk-3XJC4XUG.js} +2 -2
- package/libs/{chunk-23ANBDCR.js → chunk-4I5MF54P.js} +3 -3
- package/libs/chunk-4I5MF54P.js.map +1 -0
- package/libs/chunk-5CJPTDK3.cjs +31 -0
- package/libs/chunk-5CJPTDK3.cjs.map +1 -0
- package/libs/{chunk-E4OSROCA.cjs → chunk-5QSNJQVH.cjs} +3 -3
- package/libs/{chunk-O3JIHC5M.cjs → chunk-6BUJZ4DJ.cjs} +3 -3
- package/libs/{chunk-WXBFBWYF.cjs → chunk-AFINOD2L.cjs} +3 -3
- package/libs/{chunk-HRRHPLER.js → chunk-AWZLSWDO.js} +2 -2
- package/libs/chunk-DDSXKOUB.js +7 -0
- package/libs/chunk-DDSXKOUB.js.map +1 -0
- package/libs/{chunk-CWRNJA4P.js → chunk-DIJBIOFE.js} +3 -3
- package/libs/chunk-EJ6KYBFE.cjs +13 -0
- package/libs/chunk-EJ6KYBFE.cjs.map +1 -0
- package/libs/{chunk-GUJSMQ3V.cjs → chunk-EKJYOCLY.cjs} +3 -3
- package/libs/{chunk-X5RKCLDC.cjs → chunk-F64GE6RG.cjs} +4 -4
- package/libs/chunk-FMIM3332.js +8 -0
- package/libs/chunk-FMIM3332.js.map +1 -0
- package/libs/{chunk-5RAWNUVD.js → chunk-IBUTNPTQ.js} +2 -2
- package/libs/chunk-IWP4VJEP.cjs +18 -0
- package/libs/chunk-IWP4VJEP.cjs.map +1 -0
- package/libs/{chunk-ZFJ4U45S.js → chunk-KDMX3FAW.js} +2 -2
- package/libs/{chunk-DYFAUAB7.cjs → chunk-LXODKKA3.cjs} +4 -4
- package/libs/chunk-M7JLT62Q.js +9 -0
- package/libs/chunk-M7JLT62Q.js.map +1 -0
- package/libs/{chunk-IQ76HGVP.js → chunk-MBWI67UT.js} +2 -2
- package/libs/{chunk-O5XAJ7BY.cjs → chunk-NCGVF2QS.cjs} +4 -4
- package/libs/{chunk-W2UIN7EV.cjs → chunk-NPWHQVYB.cjs} +3 -3
- package/libs/{chunk-G55UJ53G.cjs → chunk-NZVSXRTB.cjs} +3 -3
- package/libs/chunk-NZVSXRTB.cjs.map +1 -0
- package/libs/{chunk-43TK2ICH.js → chunk-PMWL5XZ4.js} +3 -3
- package/libs/{chunk-KVKQLRJG.js → chunk-TF3GQKOY.js} +2 -2
- package/libs/chunk-TNEJXNZA.cjs +22 -0
- package/libs/chunk-TNEJXNZA.cjs.map +1 -0
- package/libs/{chunk-IEB64SWY.js → chunk-U5VA34SU.js} +2 -2
- package/libs/chunk-UGMP72J2.js +8 -0
- package/libs/chunk-UGMP72J2.js.map +1 -0
- package/libs/{chunk-MGPWZRBX.cjs → chunk-URBGDUFN.cjs} +6 -6
- package/libs/{chunk-QKHPHMG2.js → chunk-ZF6Y7W57.js} +5 -5
- package/libs/component-props-50e69975.d.ts +66 -0
- package/libs/components/box/box.css +1 -0
- package/libs/components/box/box.css.map +1 -0
- package/libs/components/box/box.min.css +3 -0
- package/libs/components/breadcrumbs/breadcrumb.cjs +6 -6
- package/libs/components/breadcrumbs/breadcrumb.js +3 -3
- package/libs/components/button.cjs +4 -4
- package/libs/components/button.d.cts +10 -3
- package/libs/components/button.d.ts +10 -3
- package/libs/components/button.js +2 -2
- package/libs/components/card.cjs +7 -7
- package/libs/components/card.d.cts +13 -85
- package/libs/components/card.d.ts +13 -85
- package/libs/components/card.js +2 -2
- package/libs/components/cards/card.css +1 -1
- package/libs/components/cards/card.css.map +1 -1
- package/libs/components/cards/card.min.css +2 -2
- package/libs/components/cluster/cluster.css +1 -0
- package/libs/components/cluster/cluster.css.map +1 -0
- package/libs/components/cluster/cluster.min.css +3 -0
- package/libs/components/dialog/dialog.cjs +7 -7
- package/libs/components/dialog/dialog.js +5 -5
- package/libs/components/form/fields.cjs +4 -4
- package/libs/components/form/fields.js +2 -2
- package/libs/components/form/textarea.cjs +4 -4
- package/libs/components/form/textarea.js +2 -2
- package/libs/components/grid/grid.css +1 -0
- package/libs/components/grid/grid.css.map +1 -0
- package/libs/components/grid/grid.min.css +3 -0
- package/libs/components/heading/heading.cjs +3 -3
- package/libs/components/heading/heading.js +2 -2
- package/libs/components/icons/icon.cjs +4 -4
- package/libs/components/icons/icon.d.cts +2 -2
- package/libs/components/icons/icon.d.ts +2 -2
- package/libs/components/icons/icon.js +2 -2
- package/libs/components/link/link.cjs +6 -6
- package/libs/components/link/link.js +2 -2
- package/libs/components/list/list.cjs +5 -5
- package/libs/components/list/list.js +2 -2
- package/libs/components/modal.cjs +4 -4
- package/libs/components/modal.d.cts +1 -1
- package/libs/components/modal.d.ts +1 -1
- package/libs/components/modal.js +3 -3
- package/libs/components/nav/nav.cjs +7 -7
- package/libs/components/nav/nav.js +3 -3
- package/libs/components/popover/popover.cjs +4 -4
- package/libs/components/popover/popover.d.cts +1 -1
- package/libs/components/popover/popover.d.ts +1 -1
- package/libs/components/popover/popover.js +1 -1
- package/libs/components/stack/stack.css +1 -0
- package/libs/components/stack/stack.css.map +1 -0
- package/libs/components/stack/stack.min.css +3 -0
- package/libs/components/tables/table.cjs +4 -4
- package/libs/components/tables/table.d.cts +2 -2
- package/libs/components/tables/table.d.ts +2 -2
- package/libs/components/tables/table.js +1 -1
- package/libs/components/text/text.cjs +5 -5
- package/libs/components/text/text.js +2 -2
- package/libs/hooks.cjs +4 -4
- package/libs/hooks.js +3 -3
- package/libs/{icons-287fce3a.d.ts → icons-df8e744f.d.ts} +1 -1
- package/libs/icons.cjs +3 -3
- package/libs/icons.d.cts +2 -2
- package/libs/icons.d.ts +2 -2
- package/libs/icons.js +2 -2
- package/libs/index.cjs +74 -73
- package/libs/index.cjs.map +1 -1
- package/libs/index.css +1 -1
- package/libs/index.css.map +1 -1
- package/libs/index.d.cts +925 -6
- package/libs/index.d.ts +925 -6
- package/libs/index.js +30 -30
- package/libs/index.js.map +1 -1
- package/package.json +2 -2
- package/src/App.tsx +1 -3
- package/src/components/alert/STYLES.mdx +790 -0
- package/src/components/badge/STYLES.mdx +610 -0
- package/src/components/box/README.mdx +401 -0
- package/src/components/box/STYLES.mdx +360 -0
- package/src/components/box/box.scss +245 -0
- package/src/components/box/box.stories.tsx +395 -0
- package/src/components/box/box.test.tsx +425 -0
- package/src/components/box/box.tsx +170 -0
- package/src/components/box/box.types.ts +166 -0
- package/src/components/breadcrumbs/STYLES.mdx +99 -0
- package/src/components/breadcrumbs/bc-item.tsx +0 -1
- package/src/components/buttons/STYLES.mdx +766 -0
- package/src/components/cards/STYLES.mdx +835 -0
- package/src/components/cards/card.scss +29 -21
- package/src/components/cards/card.tsx +13 -3
- package/src/components/cards/card.types.ts +13 -0
- package/src/components/cluster/README.mdx +595 -0
- package/src/components/cluster/STYLES.mdx +626 -0
- package/src/components/cluster/cluster.scss +86 -0
- package/src/components/cluster/cluster.stories.tsx +385 -0
- package/src/components/cluster/cluster.test.tsx +655 -0
- package/src/components/cluster/cluster.tsx +94 -0
- package/src/components/cluster/cluster.types.ts +75 -0
- package/src/components/details/STYLES.mdx +445 -0
- package/src/components/dialog/STYLES.mdx +888 -0
- package/src/components/flexbox/STYLES.mdx +857 -0
- package/src/components/flexbox/flex.stories.tsx +842 -141
- package/src/components/flexbox/flex.types.ts +25 -6
- package/src/components/form/STYLES.mdx +821 -0
- package/src/components/grid/README.mdx +709 -0
- package/src/components/grid/STYLES.mdx +785 -0
- package/src/components/grid/grid.scss +287 -0
- package/src/components/grid/grid.stories.tsx +486 -0
- package/src/components/grid/grid.test.tsx +981 -0
- package/src/components/grid/grid.tsx +222 -0
- package/src/components/grid/grid.types.ts +344 -0
- package/src/components/icons/STYLES.mdx +56 -0
- package/src/components/icons/components/arrow-right.tsx +0 -5
- package/src/components/images/STYLES.mdx +75 -0
- package/src/components/kit.tsx +8 -4
- package/src/components/layout/STYLES.mdx +556 -0
- package/src/components/link/STYLES.mdx +75 -0
- package/src/components/list/STYLES.mdx +631 -0
- package/src/components/nav/STYLES.mdx +460 -0
- package/src/components/popover/popover.tsx +1 -1
- package/src/components/progress/STYLES.mdx +64 -0
- package/src/components/stack/README.mdx +400 -0
- package/src/components/stack/STYLES.mdx +414 -0
- package/src/components/stack/stack.scss +109 -0
- package/src/components/stack/stack.stories.tsx +559 -0
- package/src/components/stack/stack.test.tsx +426 -0
- package/src/components/stack/stack.tsx +141 -0
- package/src/components/stack/stack.types.ts +133 -0
- package/src/components/tables/table-elements.tsx +1 -1
- package/src/components/tables/table.tsx +2 -2
- package/src/components/tag/STYLES.mdx +105 -0
- package/src/components/text-to-speech/STYLES.mdx +80 -0
- package/src/components/text-to-speech/TextToSpeech.tsx +0 -4
- package/src/components/text-to-speech/useTextToSpeech.tsx +2 -6
- package/src/components/ui.tsx +3 -3
- package/src/decorators/instructions.tsx +22 -18
- package/src/hooks/popover/popover.tsx +1 -1
- package/src/index.scss +5 -1
- package/src/index.ts +305 -12
- package/src/sass/GLOBALS-STYLES.md +631 -0
- package/src/sass/_globals.scss +45 -24
- package/src/styles/box/box.css +220 -0
- package/src/styles/box/box.css.map +1 -0
- package/src/styles/cards/card.css +22 -17
- package/src/styles/cards/card.css.map +1 -1
- package/src/styles/cluster/cluster.css +71 -0
- package/src/styles/cluster/cluster.css.map +1 -0
- package/src/styles/grid/grid.css +238 -0
- package/src/styles/grid/grid.css.map +1 -0
- package/src/styles/index.css +667 -49
- package/src/styles/index.css.map +1 -1
- package/src/styles/stack/stack.css +86 -0
- package/src/styles/stack/stack.css.map +1 -0
- package/src/types/component-props.ts +42 -13
- package/src/types/layout-primitives.ts +48 -0
- package/src/types/shared.ts +10 -26
- package/libs/chunk-23ANBDCR.js.map +0 -1
- package/libs/chunk-5QD3DWFI.js +0 -9
- package/libs/chunk-5QD3DWFI.js.map +0 -1
- package/libs/chunk-6WTC4JXH.cjs +0 -31
- package/libs/chunk-6WTC4JXH.cjs.map +0 -1
- package/libs/chunk-ENTCUJ3A.cjs +0 -13
- package/libs/chunk-ENTCUJ3A.cjs.map +0 -1
- package/libs/chunk-G55UJ53G.cjs.map +0 -1
- package/libs/chunk-HHLNOC5T.js +0 -7
- package/libs/chunk-HHLNOC5T.js.map +0 -1
- package/libs/chunk-KK47SYZI.js +0 -8
- package/libs/chunk-KK47SYZI.js.map +0 -1
- package/libs/chunk-US2I5GI7.cjs +0 -22
- package/libs/chunk-US2I5GI7.cjs.map +0 -1
- package/libs/chunk-W5TKWBFC.cjs +0 -18
- package/libs/chunk-W5TKWBFC.cjs.map +0 -1
- package/libs/chunk-Y2PFDELK.js +0 -8
- package/libs/chunk-Y2PFDELK.js.map +0 -1
- package/libs/component-props-67d978a2.d.ts +0 -38
- /package/libs/{chunk-2NRIP6RB.cjs.map → chunk-2C3YLBWP.cjs.map} +0 -0
- /package/libs/{chunk-NWJDAHP6.cjs.map → chunk-2GJHKWEK.cjs.map} +0 -0
- /package/libs/{chunk-FVROL3V5.js.map → chunk-2JCDEC32.js.map} +0 -0
- /package/libs/{chunk-IRLFZ3OL.js.map → chunk-3XJC4XUG.js.map} +0 -0
- /package/libs/{chunk-E4OSROCA.cjs.map → chunk-5QSNJQVH.cjs.map} +0 -0
- /package/libs/{chunk-O3JIHC5M.cjs.map → chunk-6BUJZ4DJ.cjs.map} +0 -0
- /package/libs/{chunk-WXBFBWYF.cjs.map → chunk-AFINOD2L.cjs.map} +0 -0
- /package/libs/{chunk-HRRHPLER.js.map → chunk-AWZLSWDO.js.map} +0 -0
- /package/libs/{chunk-CWRNJA4P.js.map → chunk-DIJBIOFE.js.map} +0 -0
- /package/libs/{chunk-GUJSMQ3V.cjs.map → chunk-EKJYOCLY.cjs.map} +0 -0
- /package/libs/{chunk-X5RKCLDC.cjs.map → chunk-F64GE6RG.cjs.map} +0 -0
- /package/libs/{chunk-5RAWNUVD.js.map → chunk-IBUTNPTQ.js.map} +0 -0
- /package/libs/{chunk-ZFJ4U45S.js.map → chunk-KDMX3FAW.js.map} +0 -0
- /package/libs/{chunk-DYFAUAB7.cjs.map → chunk-LXODKKA3.cjs.map} +0 -0
- /package/libs/{chunk-IQ76HGVP.js.map → chunk-MBWI67UT.js.map} +0 -0
- /package/libs/{chunk-O5XAJ7BY.cjs.map → chunk-NCGVF2QS.cjs.map} +0 -0
- /package/libs/{chunk-W2UIN7EV.cjs.map → chunk-NPWHQVYB.cjs.map} +0 -0
- /package/libs/{chunk-43TK2ICH.js.map → chunk-PMWL5XZ4.js.map} +0 -0
- /package/libs/{chunk-KVKQLRJG.js.map → chunk-TF3GQKOY.js.map} +0 -0
- /package/libs/{chunk-IEB64SWY.js.map → chunk-U5VA34SU.js.map} +0 -0
- /package/libs/{chunk-MGPWZRBX.cjs.map → chunk-URBGDUFN.cjs.map} +0 -0
- /package/libs/{chunk-QKHPHMG2.js.map → chunk-ZF6Y7W57.js.map} +0 -0
|
@@ -0,0 +1,857 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
|
|
3
|
+
<Meta title="FP.REACT Components/Layout/Flex/Styles" />
|
|
4
|
+
|
|
5
|
+
# Flexbox Utility Classes
|
|
6
|
+
|
|
7
|
+
Comprehensive CSS utility classes for building responsive flexbox layouts with
|
|
8
|
+
CSS custom properties and modern media queries.
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
The fpkit flexbox utility system provides a complete set of layout utilities for
|
|
13
|
+
creating flexible, responsive designs. All utilities support responsive
|
|
14
|
+
modifiers and use CSS custom properties for easy customization.
|
|
15
|
+
|
|
16
|
+
### Key Features
|
|
17
|
+
|
|
18
|
+
- **Comprehensive utilities** - Complete coverage of all flexbox properties
|
|
19
|
+
- **Responsive modifiers** - All utilities available at sm, md, lg, xl
|
|
20
|
+
breakpoints
|
|
21
|
+
- **CSS custom properties** - Easily customize gap spacing and defaults
|
|
22
|
+
- **Modern CSS** - Uses range media queries and fluid typography
|
|
23
|
+
- **Rem-based spacing** - All spacing values use rem units (1rem = 16px)
|
|
24
|
+
|
|
25
|
+
## CSS Custom Properties
|
|
26
|
+
|
|
27
|
+
### Gap Spacing Variables
|
|
28
|
+
|
|
29
|
+
The flexbox system uses fluid typography with `clamp()` for responsive gap
|
|
30
|
+
spacing:
|
|
31
|
+
|
|
32
|
+
```css
|
|
33
|
+
:root {
|
|
34
|
+
/* Gap spacing - fluid typography */
|
|
35
|
+
--flex-gap-xs: clamp(0.25rem, 0.2rem + 0.25vw, 0.5rem); /* 4-8px */
|
|
36
|
+
--flex-gap-sm: clamp(0.5rem, 0.45rem + 0.35vw, 0.75rem); /* 8-12px */
|
|
37
|
+
--flex-gap-md: clamp(0.75rem, 0.65rem + 0.45vw, 1.125rem); /* 12-18px */
|
|
38
|
+
--flex-gap-lg: clamp(1rem, 0.85rem + 0.6vw, 1.5rem); /* 16-24px */
|
|
39
|
+
--flex-gap-xl: clamp(1.5rem, 1.25rem + 0.75vw, 2rem); /* 24-32px */
|
|
40
|
+
|
|
41
|
+
/* Default gap for flex containers */
|
|
42
|
+
--flex-gap: var(--flex-gap-sm);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Customizing Gaps
|
|
47
|
+
|
|
48
|
+
Override gap values for specific components:
|
|
49
|
+
|
|
50
|
+
```css
|
|
51
|
+
.custom-flex {
|
|
52
|
+
--flex-gap: 2rem; /* Custom gap spacing */
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or inline:
|
|
57
|
+
|
|
58
|
+
```html
|
|
59
|
+
<div class="flex" style="--flex-gap: 2rem">
|
|
60
|
+
<!-- Custom gap spacing -->
|
|
61
|
+
</div>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Base Flex Containers
|
|
65
|
+
|
|
66
|
+
### `.flex`
|
|
67
|
+
|
|
68
|
+
Standard flex container with default gap:
|
|
69
|
+
|
|
70
|
+
```html
|
|
71
|
+
<div class="flex">
|
|
72
|
+
<div>Item 1</div>
|
|
73
|
+
<div>Item 2</div>
|
|
74
|
+
</div>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**CSS:**
|
|
78
|
+
|
|
79
|
+
```css
|
|
80
|
+
.flex {
|
|
81
|
+
display: flex;
|
|
82
|
+
gap: var(--flex-gap); /* default: --flex-gap-sm */
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### `.flex-inline`
|
|
87
|
+
|
|
88
|
+
Inline flex container:
|
|
89
|
+
|
|
90
|
+
```html
|
|
91
|
+
<div class="flex-inline">
|
|
92
|
+
<span>Inline</span>
|
|
93
|
+
<span>Items</span>
|
|
94
|
+
</div>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**CSS:**
|
|
98
|
+
|
|
99
|
+
```css
|
|
100
|
+
.flex-inline {
|
|
101
|
+
display: inline-flex;
|
|
102
|
+
gap: var(--flex-gap);
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Flex Direction
|
|
107
|
+
|
|
108
|
+
Control the direction of flex items:
|
|
109
|
+
|
|
110
|
+
| Class | CSS Value | Description |
|
|
111
|
+
| ------------------- | -------------------------------- | --------------------------- |
|
|
112
|
+
| `.flex-row` | `flex-direction: row` | Horizontal layout (default) |
|
|
113
|
+
| `.flex-row-reverse` | `flex-direction: row-reverse` | Reverse horizontal |
|
|
114
|
+
| `.flex-col` | `flex-direction: column` | Vertical layout |
|
|
115
|
+
| `.flex-col-reverse` | `flex-direction: column-reverse` | Reverse vertical |
|
|
116
|
+
|
|
117
|
+
### Examples
|
|
118
|
+
|
|
119
|
+
```html
|
|
120
|
+
<!-- Horizontal row -->
|
|
121
|
+
<div class="flex flex-row">
|
|
122
|
+
<div>Left</div>
|
|
123
|
+
<div>Right</div>
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
<!-- Vertical column -->
|
|
127
|
+
<div class="flex flex-col">
|
|
128
|
+
<div>Top</div>
|
|
129
|
+
<div>Bottom</div>
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<!-- Responsive: column on mobile, row on tablet+ -->
|
|
133
|
+
<div class="flex flex-col md:flex-row">
|
|
134
|
+
<div>Content</div>
|
|
135
|
+
<div>Sidebar</div>
|
|
136
|
+
</div>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Flex Wrap
|
|
140
|
+
|
|
141
|
+
Control whether flex items wrap:
|
|
142
|
+
|
|
143
|
+
| Class | CSS Value | Description |
|
|
144
|
+
| -------------------- | ------------------------- | -------------------------- |
|
|
145
|
+
| `.flex-wrap` | `flex-wrap: wrap` | Allow wrapping |
|
|
146
|
+
| `.flex-wrap-reverse` | `flex-wrap: wrap-reverse` | Wrap in reverse |
|
|
147
|
+
| `.flex-nowrap` | `flex-wrap: nowrap` | Prevent wrapping (default) |
|
|
148
|
+
|
|
149
|
+
### Examples
|
|
150
|
+
|
|
151
|
+
```html
|
|
152
|
+
<!-- Allow items to wrap to new lines -->
|
|
153
|
+
<div class="flex flex-wrap gap-md">
|
|
154
|
+
<div>Item 1</div>
|
|
155
|
+
<div>Item 2</div>
|
|
156
|
+
<div>Item 3</div>
|
|
157
|
+
<div>Item 4</div>
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<!-- Responsive: wrap on mobile, nowrap on desktop -->
|
|
161
|
+
<div class="flex flex-wrap lg:flex-nowrap">
|
|
162
|
+
<div>Content</div>
|
|
163
|
+
</div>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Justify Content (Main Axis)
|
|
167
|
+
|
|
168
|
+
Align items along the main axis:
|
|
169
|
+
|
|
170
|
+
| Class | CSS Value | Description |
|
|
171
|
+
| ------------------ | -------------------------------- | ------------------- |
|
|
172
|
+
| `.justify-start` | `justify-content: flex-start` | Align to start |
|
|
173
|
+
| `.justify-end` | `justify-content: flex-end` | Align to end |
|
|
174
|
+
| `.justify-center` | `justify-content: center` | Center items |
|
|
175
|
+
| `.justify-between` | `justify-content: space-between` | Space between items |
|
|
176
|
+
| `.justify-around` | `justify-content: space-around` | Space around items |
|
|
177
|
+
| `.justify-evenly` | `justify-content: space-evenly` | Even spacing |
|
|
178
|
+
|
|
179
|
+
### Examples
|
|
180
|
+
|
|
181
|
+
```html
|
|
182
|
+
<!-- Center horizontally -->
|
|
183
|
+
<div class="flex justify-center">
|
|
184
|
+
<div>Centered</div>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<!-- Space between (common header/footer layout) -->
|
|
188
|
+
<div class="flex justify-between">
|
|
189
|
+
<div>Logo</div>
|
|
190
|
+
<nav>Menu</nav>
|
|
191
|
+
</div>
|
|
192
|
+
|
|
193
|
+
<!-- Even spacing -->
|
|
194
|
+
<div class="flex justify-evenly">
|
|
195
|
+
<button>Action 1</button>
|
|
196
|
+
<button>Action 2</button>
|
|
197
|
+
<button>Action 3</button>
|
|
198
|
+
</div>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Align Items (Cross Axis)
|
|
202
|
+
|
|
203
|
+
Align items along the cross axis:
|
|
204
|
+
|
|
205
|
+
| Class | CSS Value | Description |
|
|
206
|
+
| ----------------- | ------------------------- | ------------------------- |
|
|
207
|
+
| `.items-start` | `align-items: flex-start` | Align to start |
|
|
208
|
+
| `.items-end` | `align-items: flex-end` | Align to end |
|
|
209
|
+
| `.items-center` | `align-items: center` | Center items |
|
|
210
|
+
| `.items-baseline` | `align-items: baseline` | Align to text baseline |
|
|
211
|
+
| `.items-stretch` | `align-items: stretch` | Stretch to fill (default) |
|
|
212
|
+
|
|
213
|
+
### Examples
|
|
214
|
+
|
|
215
|
+
```html
|
|
216
|
+
<!-- Vertically center items -->
|
|
217
|
+
<div class="flex items-center" style="height: 200px">
|
|
218
|
+
<div>Vertically centered</div>
|
|
219
|
+
</div>
|
|
220
|
+
|
|
221
|
+
<!-- Align to baseline (useful for text) -->
|
|
222
|
+
<div class="flex items-baseline gap-sm">
|
|
223
|
+
<h1>Title</h1>
|
|
224
|
+
<span>Subtitle</span>
|
|
225
|
+
</div>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Align Content (Multi-line)
|
|
229
|
+
|
|
230
|
+
Align wrapped flex lines:
|
|
231
|
+
|
|
232
|
+
| Class | CSS Value | Description |
|
|
233
|
+
| ------------------ | ------------------------------ | ----------------------- |
|
|
234
|
+
| `.content-start` | `align-content: flex-start` | Pack lines to start |
|
|
235
|
+
| `.content-end` | `align-content: flex-end` | Pack lines to end |
|
|
236
|
+
| `.content-center` | `align-content: center` | Center lines |
|
|
237
|
+
| `.content-between` | `align-content: space-between` | Space between lines |
|
|
238
|
+
| `.content-around` | `align-content: space-around` | Space around lines |
|
|
239
|
+
| `.content-evenly` | `align-content: space-evenly` | Even spacing |
|
|
240
|
+
| `.content-stretch` | `align-content: stretch` | Stretch lines (default) |
|
|
241
|
+
|
|
242
|
+
### Examples
|
|
243
|
+
|
|
244
|
+
```html
|
|
245
|
+
<!-- Space between wrapped lines -->
|
|
246
|
+
<div class="flex flex-wrap content-between" style="height: 400px">
|
|
247
|
+
<div>Item 1</div>
|
|
248
|
+
<div>Item 2</div>
|
|
249
|
+
<div>Item 3</div>
|
|
250
|
+
<div>Item 4</div>
|
|
251
|
+
</div>
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Align Self (Individual Items)
|
|
255
|
+
|
|
256
|
+
Override alignment for individual flex items:
|
|
257
|
+
|
|
258
|
+
| Class | CSS Value | Description |
|
|
259
|
+
| ---------------- | ------------------------ | ------------------- |
|
|
260
|
+
| `.self-auto` | `align-self: auto` | Inherit from parent |
|
|
261
|
+
| `.self-start` | `align-self: flex-start` | Align to start |
|
|
262
|
+
| `.self-end` | `align-self: flex-end` | Align to end |
|
|
263
|
+
| `.self-center` | `align-self: center` | Center item |
|
|
264
|
+
| `.self-baseline` | `align-self: baseline` | Align to baseline |
|
|
265
|
+
| `.self-stretch` | `align-self: stretch` | Stretch to fill |
|
|
266
|
+
|
|
267
|
+
### Examples
|
|
268
|
+
|
|
269
|
+
```html
|
|
270
|
+
<div class="flex items-start" style="height: 200px">
|
|
271
|
+
<div>Normal</div>
|
|
272
|
+
<div class="self-center">Centered</div>
|
|
273
|
+
<div class="self-end">Bottom</div>
|
|
274
|
+
</div>
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## Flex Item Sizing
|
|
278
|
+
|
|
279
|
+
### Flex Grow
|
|
280
|
+
|
|
281
|
+
Control how items grow to fill space:
|
|
282
|
+
|
|
283
|
+
| Class | CSS Value | Description |
|
|
284
|
+
| -------------- | -------------- | -------------------- |
|
|
285
|
+
| `.flex-grow-0` | `flex-grow: 0` | Don't grow (default) |
|
|
286
|
+
| `.flex-grow-1` | `flex-grow: 1` | Allow growth |
|
|
287
|
+
|
|
288
|
+
```html
|
|
289
|
+
<div class="flex gap-md">
|
|
290
|
+
<div class="flex-grow-0">Fixed width</div>
|
|
291
|
+
<div class="flex-grow-1">Grows to fill</div>
|
|
292
|
+
</div>
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Flex Shrink
|
|
296
|
+
|
|
297
|
+
Control how items shrink:
|
|
298
|
+
|
|
299
|
+
| Class | CSS Value | Description |
|
|
300
|
+
| ---------------- | ---------------- | ------------------------- |
|
|
301
|
+
| `.flex-shrink-0` | `flex-shrink: 0` | Don't shrink |
|
|
302
|
+
| `.flex-shrink-1` | `flex-shrink: 1` | Allow shrinking (default) |
|
|
303
|
+
|
|
304
|
+
```html
|
|
305
|
+
<div class="flex">
|
|
306
|
+
<div class="flex-shrink-0">No shrink</div>
|
|
307
|
+
<div class="flex-shrink-1">Can shrink</div>
|
|
308
|
+
</div>
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Flex Basis
|
|
312
|
+
|
|
313
|
+
Control initial size:
|
|
314
|
+
|
|
315
|
+
| Class | CSS Value | Description |
|
|
316
|
+
| ------------------ | ------------------ | -------------------------- |
|
|
317
|
+
| `.flex-basis-auto` | `flex-basis: auto` | Based on content (default) |
|
|
318
|
+
| `.flex-basis-0` | `flex-basis: 0` | Zero basis |
|
|
319
|
+
| `.flex-basis-full` | `flex-basis: 100%` | Full width/height |
|
|
320
|
+
|
|
321
|
+
### Flex Shorthand
|
|
322
|
+
|
|
323
|
+
Common flex value combinations:
|
|
324
|
+
|
|
325
|
+
| Class | CSS Value | Description |
|
|
326
|
+
| --------------- | ---------------- | ---------------------------- |
|
|
327
|
+
| `.flex-1` | `flex: 1 1 0%` | Grow and shrink equally |
|
|
328
|
+
| `.flex-auto` | `flex: 1 1 auto` | Grow/shrink based on content |
|
|
329
|
+
| `.flex-initial` | `flex: 0 1 auto` | Initial size, can shrink |
|
|
330
|
+
| `.flex-none` | `flex: none` | Don't grow or shrink |
|
|
331
|
+
|
|
332
|
+
### Examples
|
|
333
|
+
|
|
334
|
+
```html
|
|
335
|
+
<!-- Equal width columns -->
|
|
336
|
+
<div class="flex gap-md">
|
|
337
|
+
<div class="flex-1">Column 1</div>
|
|
338
|
+
<div class="flex-1">Column 2</div>
|
|
339
|
+
<div class="flex-1">Column 3</div>
|
|
340
|
+
</div>
|
|
341
|
+
|
|
342
|
+
<!-- Fixed sidebar, flexible content -->
|
|
343
|
+
<div class="flex gap-lg">
|
|
344
|
+
<aside class="flex-none" style="width: 250px">Sidebar</aside>
|
|
345
|
+
<main class="flex-1">Main content</main>
|
|
346
|
+
</div>
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## Gap Utilities
|
|
350
|
+
|
|
351
|
+
### Gap (Both Axes)
|
|
352
|
+
|
|
353
|
+
| Class | CSS Value | Size Range |
|
|
354
|
+
| --------- | ------------------------- | ---------- |
|
|
355
|
+
| `.gap-0` | `gap: 0` | No gap |
|
|
356
|
+
| `.gap-xs` | `gap: var(--flex-gap-xs)` | 4-8px |
|
|
357
|
+
| `.gap-sm` | `gap: var(--flex-gap-sm)` | 8-12px |
|
|
358
|
+
| `.gap-md` | `gap: var(--flex-gap-md)` | 12-18px |
|
|
359
|
+
| `.gap-lg` | `gap: var(--flex-gap-lg)` | 16-24px |
|
|
360
|
+
| `.gap-xl` | `gap: var(--flex-gap-xl)` | 24-32px |
|
|
361
|
+
|
|
362
|
+
### Row Gap (Horizontal Spacing)
|
|
363
|
+
|
|
364
|
+
| Class | CSS Value | Size Range |
|
|
365
|
+
| ------------- | ----------------------------- | ---------- |
|
|
366
|
+
| `.row-gap-0` | `row-gap: 0` | No gap |
|
|
367
|
+
| `.row-gap-xs` | `row-gap: var(--flex-gap-xs)` | 4-8px |
|
|
368
|
+
| `.row-gap-sm` | `row-gap: var(--flex-gap-sm)` | 8-12px |
|
|
369
|
+
| `.row-gap-md` | `row-gap: var(--flex-gap-md)` | 12-18px |
|
|
370
|
+
| `.row-gap-lg` | `row-gap: var(--flex-gap-lg)` | 16-24px |
|
|
371
|
+
| `.row-gap-xl` | `row-gap: var(--flex-gap-xl)` | 24-32px |
|
|
372
|
+
|
|
373
|
+
### Column Gap (Vertical Spacing)
|
|
374
|
+
|
|
375
|
+
| Class | CSS Value | Size Range |
|
|
376
|
+
| ------------- | -------------------------------- | ---------- |
|
|
377
|
+
| `.col-gap-0` | `column-gap: 0` | No gap |
|
|
378
|
+
| `.col-gap-xs` | `column-gap: var(--flex-gap-xs)` | 4-8px |
|
|
379
|
+
| `.col-gap-sm` | `column-gap: var(--flex-gap-sm)` | 8-12px |
|
|
380
|
+
| `.col-gap-md` | `column-gap: var(--flex-gap-md)` | 12-18px |
|
|
381
|
+
| `.col-gap-lg` | `column-gap: var(--flex-gap-lg)` | 16-24px |
|
|
382
|
+
| `.col-gap-xl` | `column-gap: var(--flex-gap-xl)` | 24-32px |
|
|
383
|
+
|
|
384
|
+
### Examples
|
|
385
|
+
|
|
386
|
+
```html
|
|
387
|
+
<!-- Uniform gap -->
|
|
388
|
+
<div class="flex gap-md">
|
|
389
|
+
<div>Item 1</div>
|
|
390
|
+
<div>Item 2</div>
|
|
391
|
+
</div>
|
|
392
|
+
|
|
393
|
+
<!-- Different row and column gaps (grid-like) -->
|
|
394
|
+
<div class="flex flex-wrap row-gap-lg col-gap-sm">
|
|
395
|
+
<div>Item 1</div>
|
|
396
|
+
<div>Item 2</div>
|
|
397
|
+
<div>Item 3</div>
|
|
398
|
+
</div>
|
|
399
|
+
|
|
400
|
+
<!-- Responsive gaps -->
|
|
401
|
+
<div class="flex gap-sm md:gap-md lg:gap-lg">
|
|
402
|
+
<div>Content</div>
|
|
403
|
+
</div>
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
## Common Flex Patterns
|
|
407
|
+
|
|
408
|
+
Pre-built patterns for common layouts:
|
|
409
|
+
|
|
410
|
+
### `.flex-center`
|
|
411
|
+
|
|
412
|
+
Center content on both axes:
|
|
413
|
+
|
|
414
|
+
```css
|
|
415
|
+
.flex-center {
|
|
416
|
+
display: flex;
|
|
417
|
+
align-items: center;
|
|
418
|
+
justify-content: center;
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
```html
|
|
423
|
+
<div class="flex-center" style="height: 300px">
|
|
424
|
+
<div>Perfectly centered</div>
|
|
425
|
+
</div>
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
### `.flex-between`
|
|
429
|
+
|
|
430
|
+
Space between with vertical centering (common for headers):
|
|
431
|
+
|
|
432
|
+
```css
|
|
433
|
+
.flex-between {
|
|
434
|
+
display: flex;
|
|
435
|
+
justify-content: space-between;
|
|
436
|
+
align-items: center;
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
```html
|
|
441
|
+
<header class="flex-between">
|
|
442
|
+
<div class="logo">Logo</div>
|
|
443
|
+
<nav>Navigation</nav>
|
|
444
|
+
</header>
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
### `.flex-around`
|
|
448
|
+
|
|
449
|
+
Space around with vertical centering:
|
|
450
|
+
|
|
451
|
+
```css
|
|
452
|
+
.flex-around {
|
|
453
|
+
display: flex;
|
|
454
|
+
justify-content: space-around;
|
|
455
|
+
align-items: center;
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
```html
|
|
460
|
+
<div class="flex-around">
|
|
461
|
+
<button>Action 1</button>
|
|
462
|
+
<button>Action 2</button>
|
|
463
|
+
<button>Action 3</button>
|
|
464
|
+
</div>
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### `.flex-stack`
|
|
468
|
+
|
|
469
|
+
Vertical stack with gap (responsive: becomes horizontal at md):
|
|
470
|
+
|
|
471
|
+
```css
|
|
472
|
+
.flex-stack {
|
|
473
|
+
display: flex;
|
|
474
|
+
flex-direction: column;
|
|
475
|
+
gap: var(--flex-gap-sm);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
@media (width >= 48rem) {
|
|
479
|
+
.flex-stack {
|
|
480
|
+
flex-direction: row;
|
|
481
|
+
align-items: center;
|
|
482
|
+
gap: var(--flex-gap-md);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
```html
|
|
488
|
+
<div class="flex-stack">
|
|
489
|
+
<div>Stacks vertically on mobile</div>
|
|
490
|
+
<div>Becomes horizontal on tablets+</div>
|
|
491
|
+
</div>
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### `.flex-spread`
|
|
495
|
+
|
|
496
|
+
Equal width children:
|
|
497
|
+
|
|
498
|
+
```css
|
|
499
|
+
.flex-spread > * {
|
|
500
|
+
flex: 1 1 0%;
|
|
501
|
+
}
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
```html
|
|
505
|
+
<div class="flex flex-spread gap-md">
|
|
506
|
+
<div>Equal</div>
|
|
507
|
+
<div>Width</div>
|
|
508
|
+
<div>Columns</div>
|
|
509
|
+
</div>
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
## Order Utilities
|
|
513
|
+
|
|
514
|
+
Control visual order of flex items:
|
|
515
|
+
|
|
516
|
+
| Class | CSS Value | Description |
|
|
517
|
+
| -------------- | ------------ | ---------------------- |
|
|
518
|
+
| `.order-first` | `order: -1` | Move to first position |
|
|
519
|
+
| `.order-last` | `order: 999` | Move to last position |
|
|
520
|
+
| `.order-none` | `order: 0` | Default order |
|
|
521
|
+
|
|
522
|
+
### Examples
|
|
523
|
+
|
|
524
|
+
```html
|
|
525
|
+
<div class="flex">
|
|
526
|
+
<div class="order-last">Appears last (was first in markup)</div>
|
|
527
|
+
<div>Middle</div>
|
|
528
|
+
<div class="order-first">Appears first (was last in markup)</div>
|
|
529
|
+
</div>
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
## Responsive Utilities
|
|
533
|
+
|
|
534
|
+
All utilities support responsive modifiers at four breakpoints:
|
|
535
|
+
|
|
536
|
+
### Breakpoints
|
|
537
|
+
|
|
538
|
+
| Prefix | Min Width | Pixels | Description |
|
|
539
|
+
| ------ | --------- | ------ | ------------- |
|
|
540
|
+
| `sm:` | 30rem | 480px | Small devices |
|
|
541
|
+
| `md:` | 48rem | 768px | Tablets |
|
|
542
|
+
| `lg:` | 62rem | 992px | Desktops |
|
|
543
|
+
| `xl:` | 80rem | 1280px | Large screens |
|
|
544
|
+
|
|
545
|
+
### Syntax
|
|
546
|
+
|
|
547
|
+
```
|
|
548
|
+
{breakpoint}:{utility}
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
### Available Responsive Utilities
|
|
552
|
+
|
|
553
|
+
All the following utilities support responsive modifiers:
|
|
554
|
+
|
|
555
|
+
- **Direction:** `flex-row`, `flex-row-reverse`, `flex-col`, `flex-col-reverse`
|
|
556
|
+
- **Wrap:** `flex-wrap`, `flex-nowrap`
|
|
557
|
+
- **Justify:** `justify-start`, `justify-end`, `justify-center`,
|
|
558
|
+
`justify-between`, `justify-around`, `justify-evenly`
|
|
559
|
+
- **Align Items:** `items-start`, `items-end`, `items-center`, `items-baseline`,
|
|
560
|
+
`items-stretch`
|
|
561
|
+
- **Gaps:** `gap-0`, `gap-xs`, `gap-sm`, `gap-md`, `gap-lg`, `gap-xl`
|
|
562
|
+
- **Flex Sizing:** `flex-1`, `flex-auto`, `flex-none`
|
|
563
|
+
|
|
564
|
+
### Responsive Examples
|
|
565
|
+
|
|
566
|
+
```html
|
|
567
|
+
<!-- Stack on mobile, row on tablet+ -->
|
|
568
|
+
<div class="flex flex-col md:flex-row gap-md">
|
|
569
|
+
<div>Content</div>
|
|
570
|
+
<div>Sidebar</div>
|
|
571
|
+
</div>
|
|
572
|
+
|
|
573
|
+
<!-- Center on mobile, space-between on desktop -->
|
|
574
|
+
<div class="flex justify-center lg:justify-between">
|
|
575
|
+
<div>Item 1</div>
|
|
576
|
+
<div>Item 2</div>
|
|
577
|
+
</div>
|
|
578
|
+
|
|
579
|
+
<!-- Small gap on mobile, larger on desktop -->
|
|
580
|
+
<div class="flex gap-sm md:gap-md lg:gap-lg xl:gap-xl">
|
|
581
|
+
<div>Item 1</div>
|
|
582
|
+
<div>Item 2</div>
|
|
583
|
+
</div>
|
|
584
|
+
|
|
585
|
+
<!-- Complex responsive layout -->
|
|
586
|
+
<div
|
|
587
|
+
class="flex flex-col sm:flex-row sm:flex-wrap lg:flex-nowrap gap-sm md:gap-md lg:gap-lg"
|
|
588
|
+
>
|
|
589
|
+
<div class="flex-1">Column 1</div>
|
|
590
|
+
<div class="flex-1">Column 2</div>
|
|
591
|
+
<div class="flex-1">Column 3</div>
|
|
592
|
+
</div>
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
## Automatic Responsive Adjustments
|
|
596
|
+
|
|
597
|
+
The flexbox system includes built-in responsive gap adjustments:
|
|
598
|
+
|
|
599
|
+
### Large Breakpoint (lg: 992px+)
|
|
600
|
+
|
|
601
|
+
```css
|
|
602
|
+
@media (width >= 62rem) {
|
|
603
|
+
.flex,
|
|
604
|
+
.flex-inline {
|
|
605
|
+
gap: var(--flex-gap-md); /* Increases from sm to md */
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
.flex-stack {
|
|
609
|
+
gap: var(--flex-gap-lg); /* Increases to lg */
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
### Extra Large Breakpoint (xl: 1280px+)
|
|
615
|
+
|
|
616
|
+
```css
|
|
617
|
+
@media (width >= 80rem) {
|
|
618
|
+
.flex,
|
|
619
|
+
.flex-inline {
|
|
620
|
+
gap: var(--flex-gap-lg); /* Increases to lg */
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
.flex-stack {
|
|
624
|
+
gap: var(--flex-gap-xl); /* Increases to xl */
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
## Real-World Examples
|
|
630
|
+
|
|
631
|
+
### Responsive Navigation Header
|
|
632
|
+
|
|
633
|
+
```html
|
|
634
|
+
<header
|
|
635
|
+
class="flex flex-col md:flex-row justify-between items-center gap-md md:gap-lg"
|
|
636
|
+
>
|
|
637
|
+
<div class="logo">
|
|
638
|
+
<img src="/logo.svg" alt="Logo" />
|
|
639
|
+
</div>
|
|
640
|
+
<nav class="flex gap-md">
|
|
641
|
+
<a href="/">Home</a>
|
|
642
|
+
<a href="/about">About</a>
|
|
643
|
+
<a href="/contact">Contact</a>
|
|
644
|
+
</nav>
|
|
645
|
+
</header>
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
### Card Grid with Wrapping
|
|
649
|
+
|
|
650
|
+
```html
|
|
651
|
+
<div class="flex flex-wrap gap-md lg:gap-lg">
|
|
652
|
+
<div class="flex-basis-full md:flex-basis-0 md:flex-1">
|
|
653
|
+
<div class="card">Card 1</div>
|
|
654
|
+
</div>
|
|
655
|
+
<div class="flex-basis-full md:flex-basis-0 md:flex-1">
|
|
656
|
+
<div class="card">Card 2</div>
|
|
657
|
+
</div>
|
|
658
|
+
<div class="flex-basis-full md:flex-basis-0 md:flex-1">
|
|
659
|
+
<div class="card">Card 3</div>
|
|
660
|
+
</div>
|
|
661
|
+
</div>
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
### Sidebar Layout
|
|
665
|
+
|
|
666
|
+
```html
|
|
667
|
+
<div class="flex flex-col lg:flex-row gap-lg">
|
|
668
|
+
<aside class="flex-none lg:flex-basis-0" style="--flex-basis: 250px">
|
|
669
|
+
<nav class="flex flex-col gap-sm">
|
|
670
|
+
<a href="#section1">Section 1</a>
|
|
671
|
+
<a href="#section2">Section 2</a>
|
|
672
|
+
<a href="#section3">Section 3</a>
|
|
673
|
+
</nav>
|
|
674
|
+
</aside>
|
|
675
|
+
<main class="flex-1">
|
|
676
|
+
<article>Main content</article>
|
|
677
|
+
</main>
|
|
678
|
+
</div>
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
### Form Layout
|
|
682
|
+
|
|
683
|
+
```html
|
|
684
|
+
<form class="flex flex-col gap-md">
|
|
685
|
+
<div class="flex flex-col sm:flex-row gap-sm">
|
|
686
|
+
<label class="flex-none sm:flex-basis-0" style="--flex-basis: 150px">
|
|
687
|
+
First Name
|
|
688
|
+
</label>
|
|
689
|
+
<input class="flex-1" type="text" />
|
|
690
|
+
</div>
|
|
691
|
+
<div class="flex flex-col sm:flex-row gap-sm">
|
|
692
|
+
<label class="flex-none sm:flex-basis-0" style="--flex-basis: 150px">
|
|
693
|
+
Last Name
|
|
694
|
+
</label>
|
|
695
|
+
<input class="flex-1" type="text" />
|
|
696
|
+
</div>
|
|
697
|
+
<div class="flex justify-end gap-sm">
|
|
698
|
+
<button type="button">Cancel</button>
|
|
699
|
+
<button type="submit">Submit</button>
|
|
700
|
+
</div>
|
|
701
|
+
</form>
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
### Centered Modal Dialog
|
|
705
|
+
|
|
706
|
+
```html
|
|
707
|
+
<div class="flex-center" style="min-height: 100vh">
|
|
708
|
+
<div class="modal flex flex-col gap-md" style="width: 90%; max-width: 500px">
|
|
709
|
+
<div class="flex justify-between items-center">
|
|
710
|
+
<h2>Dialog Title</h2>
|
|
711
|
+
<button>✕</button>
|
|
712
|
+
</div>
|
|
713
|
+
<div class="flex-1">
|
|
714
|
+
<p>Dialog content</p>
|
|
715
|
+
</div>
|
|
716
|
+
<div class="flex justify-end gap-sm">
|
|
717
|
+
<button>Cancel</button>
|
|
718
|
+
<button>Confirm</button>
|
|
719
|
+
</div>
|
|
720
|
+
</div>
|
|
721
|
+
</div>
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
## Browser Support
|
|
725
|
+
|
|
726
|
+
The flexbox utilities use modern CSS features:
|
|
727
|
+
|
|
728
|
+
- **Flexbox:** All modern browsers (IE11+ with prefixes)
|
|
729
|
+
- **Range media queries:** Chrome 104+, Firefox 102+, Safari 16.4+
|
|
730
|
+
- **CSS custom properties:** All modern browsers (IE11 not supported)
|
|
731
|
+
- **Gap property:** Chrome 84+, Firefox 63+, Safari 14.1+
|
|
732
|
+
|
|
733
|
+
For older browsers, consider using PostCSS with autoprefixer.
|
|
734
|
+
|
|
735
|
+
## Accessibility Considerations
|
|
736
|
+
|
|
737
|
+
### Visual vs Source Order
|
|
738
|
+
|
|
739
|
+
When using `order` utilities or `flex-direction: *-reverse`, be aware that
|
|
740
|
+
visual order differs from source order:
|
|
741
|
+
|
|
742
|
+
```html
|
|
743
|
+
<!-- Screen readers will announce in source order, not visual order -->
|
|
744
|
+
<div class="flex flex-row-reverse">
|
|
745
|
+
<div>Appears second visually, but first in source</div>
|
|
746
|
+
<div>Appears first visually, but second in source</div>
|
|
747
|
+
</div>
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
**Best practice:** Keep source order logical for screen readers. Use CSS for
|
|
751
|
+
visual adjustments only.
|
|
752
|
+
|
|
753
|
+
### Focus Order
|
|
754
|
+
|
|
755
|
+
Focus order follows source order, not visual order:
|
|
756
|
+
|
|
757
|
+
```html
|
|
758
|
+
<!-- Tab order follows 1→2→3 regardless of visual order -->
|
|
759
|
+
<div class="flex">
|
|
760
|
+
<button class="order-last">Button 1 (visually last, focus first)</button>
|
|
761
|
+
<button>Button 2</button>
|
|
762
|
+
<button class="order-first">Button 3 (visually first, focus last)</button>
|
|
763
|
+
</div>
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
**Best practice:** Avoid changing visual order of interactive elements.
|
|
767
|
+
|
|
768
|
+
## Performance Tips
|
|
769
|
+
|
|
770
|
+
### Avoid Deep Nesting
|
|
771
|
+
|
|
772
|
+
Prefer flat structures over deeply nested flex containers:
|
|
773
|
+
|
|
774
|
+
```html
|
|
775
|
+
<!-- Good: Flat structure -->
|
|
776
|
+
<div class="flex gap-md">
|
|
777
|
+
<div>Item 1</div>
|
|
778
|
+
<div>Item 2</div>
|
|
779
|
+
<div>Item 3</div>
|
|
780
|
+
</div>
|
|
781
|
+
|
|
782
|
+
<!-- Avoid: Unnecessary nesting -->
|
|
783
|
+
<div class="flex">
|
|
784
|
+
<div class="flex">
|
|
785
|
+
<div class="flex">
|
|
786
|
+
<div>Over-nested</div>
|
|
787
|
+
</div>
|
|
788
|
+
</div>
|
|
789
|
+
</div>
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
### Use Shorthand Properties
|
|
793
|
+
|
|
794
|
+
Prefer shorthand utilities like `.flex-1` over multiple utilities:
|
|
795
|
+
|
|
796
|
+
```html
|
|
797
|
+
<!-- Good: Shorthand -->
|
|
798
|
+
<div class="flex-1">Content</div>
|
|
799
|
+
|
|
800
|
+
<!-- Verbose: Multiple utilities -->
|
|
801
|
+
<div class="flex-grow-1 flex-shrink-1 flex-basis-0">Content</div>
|
|
802
|
+
```
|
|
803
|
+
|
|
804
|
+
### Combine Utilities Strategically
|
|
805
|
+
|
|
806
|
+
Use pattern classes when appropriate:
|
|
807
|
+
|
|
808
|
+
```html
|
|
809
|
+
<!-- Good: Pattern class -->
|
|
810
|
+
<div class="flex-between">
|
|
811
|
+
<div>Left</div>
|
|
812
|
+
<div>Right</div>
|
|
813
|
+
</div>
|
|
814
|
+
|
|
815
|
+
<!-- Works but verbose -->
|
|
816
|
+
<div class="flex justify-between items-center">
|
|
817
|
+
<div>Left</div>
|
|
818
|
+
<div>Right</div>
|
|
819
|
+
</div>
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
## Migration from Other Systems
|
|
823
|
+
|
|
824
|
+
### From Tailwind CSS
|
|
825
|
+
|
|
826
|
+
| Tailwind | fpkit | Notes |
|
|
827
|
+
| ----------------- | ------------------ | --------------- |
|
|
828
|
+
| `flex` | `.flex` | Same |
|
|
829
|
+
| `flex-row` | `.flex-row` | Same |
|
|
830
|
+
| `flex-col` | `.flex-col` | Same |
|
|
831
|
+
| `justify-between` | `.justify-between` | Same |
|
|
832
|
+
| `items-center` | `.items-center` | Same |
|
|
833
|
+
| `gap-4` | `.gap-md` | Different scale |
|
|
834
|
+
| `flex-1` | `.flex-1` | Same |
|
|
835
|
+
| `md:flex-row` | `.md:flex-row` | Same syntax |
|
|
836
|
+
|
|
837
|
+
### From Bootstrap
|
|
838
|
+
|
|
839
|
+
| Bootstrap | fpkit | Notes |
|
|
840
|
+
| ------------------------- | --------------------------- | ----------------- |
|
|
841
|
+
| `d-flex` | `.flex` | Shorter |
|
|
842
|
+
| `flex-row` | `.flex-row` | Same |
|
|
843
|
+
| `flex-column` | `.flex-col` | Shorter |
|
|
844
|
+
| `justify-content-between` | `.justify-between` | Shorter |
|
|
845
|
+
| `align-items-center` | `.items-center` | Shorter |
|
|
846
|
+
| `flex-grow-1` | `.flex-grow-1` or `.flex-1` | Same or shorthand |
|
|
847
|
+
|
|
848
|
+
## Related Resources
|
|
849
|
+
|
|
850
|
+
- **React Component** - See [README.mdx](./README.mdx) for the React Flex
|
|
851
|
+
component API
|
|
852
|
+
- **MDN: Flexbox** -
|
|
853
|
+
[https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout)
|
|
854
|
+
- **CSS Tricks: Complete Guide to Flexbox** -
|
|
855
|
+
[https://css-tricks.com/snippets/css/a-guide-to-flexbox/](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)
|
|
856
|
+
- **W3C Flexbox Specification** -
|
|
857
|
+
[https://www.w3.org/TR/css-flexbox-1/](https://www.w3.org/TR/css-flexbox-1/)
|