@fpkit/acss 3.3.0 → 3.4.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/components/alert/alert.min.min.css +2 -0
- package/libs/components/badge/badge.min.min.css +2 -0
- package/libs/components/box/box.min.min.css +2 -0
- package/libs/components/breadcrumbs/breadcrumb.min.min.css +2 -0
- package/libs/components/buttons/button.min.min.css +2 -0
- package/libs/components/cards/card-style.min.min.css +2 -0
- package/libs/components/cards/card.min.min.css +2 -0
- package/libs/components/cluster/cluster.min.min.css +2 -0
- package/libs/components/details/details.min.min.css +2 -0
- package/libs/components/dialog/dialog.min.min.css +2 -0
- package/libs/components/flexbox/flex.min.min.css +2 -0
- package/libs/components/form/form.min.min.css +2 -0
- package/libs/components/grid/grid.min.min.css +2 -0
- package/libs/components/icons/icon.min.min.css +2 -0
- package/libs/components/images/img.min.min.css +2 -0
- package/libs/components/layout/landmarks.min.min.css +2 -0
- package/libs/components/link/link.min.min.css +2 -0
- package/libs/components/list/list.min.min.css +2 -0
- package/libs/components/nav/nav.min.min.css +2 -0
- package/libs/components/progress/progress.min.min.css +2 -0
- package/libs/components/stack/stack.min.min.css +2 -0
- package/libs/components/styles/index.min.min.css +2 -0
- package/libs/components/tag/tag.min.min.css +2 -0
- package/libs/components/text-to-speech/text-to-speech.min.min.css +2 -0
- package/libs/index.cjs +22 -20
- 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 +275 -1
- package/libs/index.d.ts +275 -1
- package/libs/index.js +9 -9
- package/libs/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/col/README.mdx +532 -0
- package/src/components/col/col.stories.tsx +424 -0
- package/src/components/col/col.test.tsx +321 -0
- package/src/components/col/col.tsx +105 -0
- package/src/components/col/col.types.ts +76 -0
- package/src/components/row/README.mdx +324 -0
- package/src/components/row/row.stories.tsx +595 -0
- package/src/components/row/row.test.tsx +358 -0
- package/src/components/row/row.tsx +121 -0
- package/src/components/row/row.types.ts +93 -0
- package/src/index.scss +1 -0
- package/src/index.ts +2 -0
- package/src/sass/README.mdx +597 -0
- package/src/sass/_columns.scss +198 -0
- package/src/sass/columns.stories.tsx +456 -0
- package/src/styles/index.css +340 -0
- package/src/styles/index.css.map +1 -1
- package/src/types/layout-primitives.ts +61 -0
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
|
|
3
|
+
import * as ColStories from "./col.stories";
|
|
4
|
+
|
|
5
|
+
<Meta of={ColStories} />
|
|
6
|
+
|
|
7
|
+
# Col
|
|
8
|
+
|
|
9
|
+
A column component for building responsive 12-column layouts within Row
|
|
10
|
+
containers.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Col provides a type-safe React wrapper around column utility classes, allowing
|
|
15
|
+
developers to create responsive columns with precise control over width,
|
|
16
|
+
positioning, and visual order. Unlike Row, Col has **no base class** - it's pure
|
|
17
|
+
utility class composition following the Grid.Item pattern.
|
|
18
|
+
|
|
19
|
+
## Key Features
|
|
20
|
+
|
|
21
|
+
- **No Base Class**: Pure utility class mapping for maximum flexibility
|
|
22
|
+
- **Span Control**: 1-12 column widths via the `span` prop
|
|
23
|
+
- **Offset Positioning**: Push columns right with `offset` prop
|
|
24
|
+
- **Visual Reordering**: Change display order with `order` prop
|
|
25
|
+
- **Auto-Width**: Content-based width with `auto` prop
|
|
26
|
+
- **Polymorphic**: Render as any semantic HTML element
|
|
27
|
+
- **Type-Safe**: Full TypeScript support with literal types
|
|
28
|
+
|
|
29
|
+
## When to Use
|
|
30
|
+
|
|
31
|
+
Use Col when you need:
|
|
32
|
+
|
|
33
|
+
- Responsive column layouts within Row containers
|
|
34
|
+
- Precise control over column widths (12-column grid)
|
|
35
|
+
- Offset positioning to create whitespace
|
|
36
|
+
- Visual reordering without changing DOM order
|
|
37
|
+
- Content-based column widths
|
|
38
|
+
|
|
39
|
+
## Props
|
|
40
|
+
|
|
41
|
+
### span
|
|
42
|
+
|
|
43
|
+
Column span (width) from 1-12 columns. Ignored if `auto` is true.
|
|
44
|
+
|
|
45
|
+
- **Type**: `1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12`
|
|
46
|
+
- **Default**: `undefined`
|
|
47
|
+
- **CSS Class**: `.col-{span}`
|
|
48
|
+
- **Calculation**: `span / 12 * 100%`
|
|
49
|
+
|
|
50
|
+
**Examples:**
|
|
51
|
+
|
|
52
|
+
- `span={12}` = 100% width (`.col-12`)
|
|
53
|
+
- `span={6}` = 50% width (`.col-6`)
|
|
54
|
+
- `span={4}` = 33.33% width (`.col-4`)
|
|
55
|
+
- `span={3}` = 25% width (`.col-3`)
|
|
56
|
+
|
|
57
|
+
### offset
|
|
58
|
+
|
|
59
|
+
Column offset (left margin) from 0-11 columns. Pushes column to the right.
|
|
60
|
+
|
|
61
|
+
- **Type**: `0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11`
|
|
62
|
+
- **Default**: `undefined`
|
|
63
|
+
- **CSS Class**: `.col-offset-{offset}`
|
|
64
|
+
- **Calculation**: `offset / 12 * 100%`
|
|
65
|
+
|
|
66
|
+
**Examples:**
|
|
67
|
+
|
|
68
|
+
- `offset={3}` = Push right by 25% (`.col-offset-3`)
|
|
69
|
+
- `offset={0}` = No offset (`.col-offset-0`)
|
|
70
|
+
|
|
71
|
+
### order
|
|
72
|
+
|
|
73
|
+
Visual display order using flexbox `order` property. Does not change DOM order.
|
|
74
|
+
|
|
75
|
+
- **Type**:
|
|
76
|
+
`"first" | "last" | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12`
|
|
77
|
+
- **Default**: `undefined`
|
|
78
|
+
- **CSS Class**: `.col-order-{order}`
|
|
79
|
+
|
|
80
|
+
**Examples:**
|
|
81
|
+
|
|
82
|
+
- `order="first"` = Display first (order: -1)
|
|
83
|
+
- `order="last"` = Display last (order: 13)
|
|
84
|
+
- `order={1}` = Display in position 1
|
|
85
|
+
|
|
86
|
+
### auto
|
|
87
|
+
|
|
88
|
+
Auto-width column based on content. Takes precedence over `span`.
|
|
89
|
+
|
|
90
|
+
- **Type**: `boolean`
|
|
91
|
+
- **Default**: `false`
|
|
92
|
+
- **CSS Class**: `.col-auto`
|
|
93
|
+
|
|
94
|
+
When `true`, column width adjusts to fit content instead of spanning a fixed
|
|
95
|
+
number of columns.
|
|
96
|
+
|
|
97
|
+
### as
|
|
98
|
+
|
|
99
|
+
Element type to render. Supports semantic HTML elements.
|
|
100
|
+
|
|
101
|
+
- **Type**: `"div" | "section" | "article" | "li"`
|
|
102
|
+
- **Default**: `"div"`
|
|
103
|
+
|
|
104
|
+
### className
|
|
105
|
+
|
|
106
|
+
Additional CSS classes to merge with utility classes.
|
|
107
|
+
|
|
108
|
+
- **Type**: `string`
|
|
109
|
+
- **Default**: `undefined`
|
|
110
|
+
|
|
111
|
+
## Basic Usage
|
|
112
|
+
|
|
113
|
+
```jsx
|
|
114
|
+
import { Row, Col } from "@fpkit/acss";
|
|
115
|
+
|
|
116
|
+
function MyLayout() {
|
|
117
|
+
return (
|
|
118
|
+
<Row>
|
|
119
|
+
<Col span={6}>Left column (50%)</Col>
|
|
120
|
+
<Col span={6}>Right column (50%)</Col>
|
|
121
|
+
</Row>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Examples
|
|
127
|
+
|
|
128
|
+
### Column Spans
|
|
129
|
+
|
|
130
|
+
```jsx
|
|
131
|
+
<Row gap="md">
|
|
132
|
+
{/* Full width */}
|
|
133
|
+
<Col span={12}>100% width</Col>
|
|
134
|
+
|
|
135
|
+
{/* Half width */}
|
|
136
|
+
<Col span={6}>50% width</Col>
|
|
137
|
+
<Col span={6}>50% width</Col>
|
|
138
|
+
|
|
139
|
+
{/* Thirds */}
|
|
140
|
+
<Col span={4}>33.33% width</Col>
|
|
141
|
+
<Col span={4}>33.33% width</Col>
|
|
142
|
+
<Col span={4}>33.33% width</Col>
|
|
143
|
+
|
|
144
|
+
{/* Quarters */}
|
|
145
|
+
<Col span={3}>25%</Col>
|
|
146
|
+
<Col span={3}>25%</Col>
|
|
147
|
+
<Col span={3}>25%</Col>
|
|
148
|
+
<Col span={3}>25%</Col>
|
|
149
|
+
</Row>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Column Offsets
|
|
153
|
+
|
|
154
|
+
```jsx
|
|
155
|
+
<Row gap="md">
|
|
156
|
+
{/* Centered column */}
|
|
157
|
+
<Col span={6} offset={3}>
|
|
158
|
+
Centered (50% width, 25% left margin)
|
|
159
|
+
</Col>
|
|
160
|
+
|
|
161
|
+
{/* Two columns with gap in middle */}
|
|
162
|
+
<Col span={3}>Left column</Col>
|
|
163
|
+
<Col span={3} offset={6}>
|
|
164
|
+
Right column (50% gap between)
|
|
165
|
+
</Col>
|
|
166
|
+
|
|
167
|
+
{/* Multiple offsets */}
|
|
168
|
+
<Col span={2} offset={2}>
|
|
169
|
+
offset-2
|
|
170
|
+
</Col>
|
|
171
|
+
<Col span={2} offset={2}>
|
|
172
|
+
offset-2
|
|
173
|
+
</Col>
|
|
174
|
+
<Col span={2} offset={2}>
|
|
175
|
+
offset-2
|
|
176
|
+
</Col>
|
|
177
|
+
</Row>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Visual Reordering
|
|
181
|
+
|
|
182
|
+
```jsx
|
|
183
|
+
<Row gap="md">
|
|
184
|
+
{/* Source order: 1, 2, 3 */}
|
|
185
|
+
{/* Visual order: 3, 1, 2 */}
|
|
186
|
+
<Col span={4} order={2}>DOM 1st, Visual 3rd</Col>
|
|
187
|
+
<Col span={4} order={0}>DOM 2nd, Visual 1st</Col>
|
|
188
|
+
<Col span={4} order={1}>DOM 3rd, Visual 2nd</Col>
|
|
189
|
+
</Row>
|
|
190
|
+
|
|
191
|
+
<Row gap="md">
|
|
192
|
+
{/* order-first and order-last */}
|
|
193
|
+
<Col span={6} order="last">Appears last visually</Col>
|
|
194
|
+
<Col span={6} order="first">Appears first visually</Col>
|
|
195
|
+
</Row>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Auto-Width Columns
|
|
199
|
+
|
|
200
|
+
```jsx
|
|
201
|
+
<Row gap="sm">
|
|
202
|
+
{/* Content-based width */}
|
|
203
|
+
<Col auto>Button</Col>
|
|
204
|
+
<Col auto>Another Button</Col>
|
|
205
|
+
<Col auto>Third Button</Col>
|
|
206
|
+
</Row>
|
|
207
|
+
|
|
208
|
+
<Row gap="md">
|
|
209
|
+
{/* Mix fixed and auto */}
|
|
210
|
+
<Col span={3}>Fixed 25%</Col>
|
|
211
|
+
<Col auto>Auto (fills remaining)</Col>
|
|
212
|
+
<Col span={2}>Fixed 16.66%</Col>
|
|
213
|
+
</Row>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Responsive Columns
|
|
217
|
+
|
|
218
|
+
```jsx
|
|
219
|
+
<Row gap="md">
|
|
220
|
+
{/* Mobile: 100%, Tablet: 50%, Desktop: 33% */}
|
|
221
|
+
<Col span={12} className="col-md-6 col-lg-4">
|
|
222
|
+
Responsive column
|
|
223
|
+
</Col>
|
|
224
|
+
<Col span={12} className="col-md-6 col-lg-4">
|
|
225
|
+
Responsive column
|
|
226
|
+
</Col>
|
|
227
|
+
<Col span={12} className="col-md-6 col-lg-4">
|
|
228
|
+
Responsive column
|
|
229
|
+
</Col>
|
|
230
|
+
</Row>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Semantic HTML
|
|
234
|
+
|
|
235
|
+
```jsx
|
|
236
|
+
{
|
|
237
|
+
/* List items */
|
|
238
|
+
}
|
|
239
|
+
<Row as="ul" gap="sm">
|
|
240
|
+
<Col as="li" span={4}>
|
|
241
|
+
List item 1
|
|
242
|
+
</Col>
|
|
243
|
+
<Col as="li" span={4}>
|
|
244
|
+
List item 2
|
|
245
|
+
</Col>
|
|
246
|
+
<Col as="li" span={4}>
|
|
247
|
+
List item 3
|
|
248
|
+
</Col>
|
|
249
|
+
</Row>;
|
|
250
|
+
|
|
251
|
+
{
|
|
252
|
+
/* Article sections */
|
|
253
|
+
}
|
|
254
|
+
<Row as="section">
|
|
255
|
+
<Col as="article" span={6}>
|
|
256
|
+
Article content 1
|
|
257
|
+
</Col>
|
|
258
|
+
<Col as="article" span={6}>
|
|
259
|
+
Article content 2
|
|
260
|
+
</Col>
|
|
261
|
+
</Row>;
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Accessibility
|
|
265
|
+
|
|
266
|
+
### Visual vs. DOM Order
|
|
267
|
+
|
|
268
|
+
**Important**: The `order` prop changes **visual order only**, not DOM order.
|
|
269
|
+
Screen readers and keyboard navigation follow DOM order, not visual order.
|
|
270
|
+
|
|
271
|
+
```jsx
|
|
272
|
+
{
|
|
273
|
+
/* Screen readers read: "Column A", "Column B"
|
|
274
|
+
Visually displays: "Column B", "Column A" */
|
|
275
|
+
}
|
|
276
|
+
<Row>
|
|
277
|
+
<Col span={6} order={2}>
|
|
278
|
+
Column A
|
|
279
|
+
</Col>
|
|
280
|
+
<Col span={6} order={1}>
|
|
281
|
+
Column B
|
|
282
|
+
</Col>
|
|
283
|
+
</Row>;
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**Best Practice**: Only use `order` when visual reordering doesn't affect
|
|
287
|
+
content comprehension. Avoid reordering critical content like navigation or form
|
|
288
|
+
fields.
|
|
289
|
+
|
|
290
|
+
### Semantic Elements
|
|
291
|
+
|
|
292
|
+
Use appropriate HTML elements via the `as` prop:
|
|
293
|
+
|
|
294
|
+
```jsx
|
|
295
|
+
{
|
|
296
|
+
/* Good: Semantic list */
|
|
297
|
+
}
|
|
298
|
+
<Row as="ul">
|
|
299
|
+
<Col as="li" span={4}>
|
|
300
|
+
Item
|
|
301
|
+
</Col>
|
|
302
|
+
</Row>;
|
|
303
|
+
|
|
304
|
+
{
|
|
305
|
+
/* Good: Article sections */
|
|
306
|
+
}
|
|
307
|
+
<Row>
|
|
308
|
+
<Col as="article" span={6}>
|
|
309
|
+
Article 1
|
|
310
|
+
</Col>
|
|
311
|
+
<Col as="article" span={6}>
|
|
312
|
+
Article 2
|
|
313
|
+
</Col>
|
|
314
|
+
</Row>;
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Focus Order
|
|
318
|
+
|
|
319
|
+
Keyboard navigation follows DOM order, not visual `order`. Ensure tab order is
|
|
320
|
+
logical:
|
|
321
|
+
|
|
322
|
+
```jsx
|
|
323
|
+
{
|
|
324
|
+
/* Tab order: Input 1 → Input 2 → Button
|
|
325
|
+
Visual order may differ if using order prop */
|
|
326
|
+
}
|
|
327
|
+
<Row>
|
|
328
|
+
<Col span={6} order={1}>
|
|
329
|
+
<input id="input1" />
|
|
330
|
+
</Col>
|
|
331
|
+
<Col span={6} order={2}>
|
|
332
|
+
<input id="input2" />
|
|
333
|
+
</Col>
|
|
334
|
+
<Col span={12} order={0}>
|
|
335
|
+
<button>Submit</button>
|
|
336
|
+
</Col>
|
|
337
|
+
</Row>;
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
## Responsive Behavior
|
|
341
|
+
|
|
342
|
+
Col uses a **mobile-first** approach:
|
|
343
|
+
|
|
344
|
+
- **Mobile** (`<768px`): Columns default to 100% width and stack vertically
|
|
345
|
+
- **Desktop** (`≥768px`): Columns use their specified span values
|
|
346
|
+
|
|
347
|
+
### Responsive Classes
|
|
348
|
+
|
|
349
|
+
Use responsive utility classes on Col for breakpoint-specific widths:
|
|
350
|
+
|
|
351
|
+
```jsx
|
|
352
|
+
<Col
|
|
353
|
+
span={12} // Mobile: 100%
|
|
354
|
+
className="col-md-6 col-lg-4" // Tablet: 50%, Desktop: 33%
|
|
355
|
+
>
|
|
356
|
+
Responsive content
|
|
357
|
+
</Col>
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
**Available Breakpoints:**
|
|
361
|
+
|
|
362
|
+
- `col-md-*` - Tablet and up (`≥768px`)
|
|
363
|
+
- `col-lg-*` - Desktop and up (`≥992px`)
|
|
364
|
+
- `col-xl-*` - Large desktop and up (`≥1280px`)
|
|
365
|
+
|
|
366
|
+
## Advanced Patterns
|
|
367
|
+
|
|
368
|
+
### Asymmetric Layouts
|
|
369
|
+
|
|
370
|
+
```jsx
|
|
371
|
+
<Row gap="lg">
|
|
372
|
+
<Col span={8}>Main content (66.66%)</Col>
|
|
373
|
+
<Col span={4}>Sidebar (33.33%)</Col>
|
|
374
|
+
</Row>
|
|
375
|
+
|
|
376
|
+
<Row gap="lg">
|
|
377
|
+
<Col span={3}>Nav (25%)</Col>
|
|
378
|
+
<Col span={6}>Content (50%)</Col>
|
|
379
|
+
<Col span={3}>Aside (25%)</Col>
|
|
380
|
+
</Row>
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### Complex Grid
|
|
384
|
+
|
|
385
|
+
```jsx
|
|
386
|
+
<Row gap="md">
|
|
387
|
+
<Col span={12}>Header</Col>
|
|
388
|
+
<Col span={8} className="col-lg-9">
|
|
389
|
+
Main content
|
|
390
|
+
</Col>
|
|
391
|
+
<Col span={4} className="col-lg-3">
|
|
392
|
+
Sidebar
|
|
393
|
+
</Col>
|
|
394
|
+
<Col span={6} className="col-lg-3">
|
|
395
|
+
Footer column 1
|
|
396
|
+
</Col>
|
|
397
|
+
<Col span={6} className="col-lg-3">
|
|
398
|
+
Footer column 2
|
|
399
|
+
</Col>
|
|
400
|
+
<Col span={12} className="col-lg-6">
|
|
401
|
+
Footer column 3
|
|
402
|
+
</Col>
|
|
403
|
+
</Row>
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Dashboard Metrics
|
|
407
|
+
|
|
408
|
+
```jsx
|
|
409
|
+
<Row gap="md" align="stretch">
|
|
410
|
+
{/* 4 equal columns on desktop, stacked on mobile */}
|
|
411
|
+
<Col span={12} className="col-sm-6 col-lg-3">
|
|
412
|
+
<Card>
|
|
413
|
+
<h3>Total Users</h3>
|
|
414
|
+
<p>1,234</p>
|
|
415
|
+
</Card>
|
|
416
|
+
</Col>
|
|
417
|
+
<Col span={12} className="col-sm-6 col-lg-3">
|
|
418
|
+
<Card>
|
|
419
|
+
<h3>Revenue</h3>
|
|
420
|
+
<p>$12,345</p>
|
|
421
|
+
</Card>
|
|
422
|
+
</Col>
|
|
423
|
+
<Col span={12} className="col-sm-6 col-lg-3">
|
|
424
|
+
<Card>
|
|
425
|
+
<h3>Conversions</h3>
|
|
426
|
+
<p>567</p>
|
|
427
|
+
</Card>
|
|
428
|
+
</Col>
|
|
429
|
+
<Col span={12} className="col-sm-6 col-lg-3">
|
|
430
|
+
<Card>
|
|
431
|
+
<h3>Growth</h3>
|
|
432
|
+
<p>+23%</p>
|
|
433
|
+
</Card>
|
|
434
|
+
</Col>
|
|
435
|
+
</Row>
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### Form Layout
|
|
439
|
+
|
|
440
|
+
```jsx
|
|
441
|
+
<Row gap="md">
|
|
442
|
+
<Col span={12} className="col-md-6">
|
|
443
|
+
<Field>
|
|
444
|
+
<FieldLabel htmlFor="first-name">First Name</FieldLabel>
|
|
445
|
+
<FieldInput id="first-name" />
|
|
446
|
+
</Field>
|
|
447
|
+
</Col>
|
|
448
|
+
<Col span={12} className="col-md-6">
|
|
449
|
+
<Field>
|
|
450
|
+
<FieldLabel htmlFor="last-name">Last Name</FieldLabel>
|
|
451
|
+
<FieldInput id="last-name" />
|
|
452
|
+
</Field>
|
|
453
|
+
</Col>
|
|
454
|
+
<Col span={12}>
|
|
455
|
+
<Field>
|
|
456
|
+
<FieldLabel htmlFor="email">Email</FieldLabel>
|
|
457
|
+
<FieldInput id="email" type="email" />
|
|
458
|
+
</Field>
|
|
459
|
+
</Col>
|
|
460
|
+
<Col span={12}>
|
|
461
|
+
<button type="submit">Submit</button>
|
|
462
|
+
</Col>
|
|
463
|
+
</Row>
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
## Related Components
|
|
467
|
+
|
|
468
|
+
- **Row** - Flex container for Col components
|
|
469
|
+
- **Grid** - Alternative grid system using CSS Grid
|
|
470
|
+
- **Grid.Item** - Item component for Grid (similar pattern to Col)
|
|
471
|
+
|
|
472
|
+
## Best Practices
|
|
473
|
+
|
|
474
|
+
1. **Always use Col within Row**: Col is designed for use within Row containers
|
|
475
|
+
2. **Total span = 12**: Columns in a row should sum to 12 (or less if
|
|
476
|
+
intentional gaps)
|
|
477
|
+
3. **Mobile-first responsive**: Start with mobile layout, enhance for desktop
|
|
478
|
+
4. **Semantic HTML**: Use `as` prop for appropriate elements (li, article,
|
|
479
|
+
section)
|
|
480
|
+
5. **Avoid order for critical content**: Only reorder decorative or non-critical
|
|
481
|
+
content
|
|
482
|
+
6. **Consistent gaps**: Use Row's `gap` prop for uniform spacing
|
|
483
|
+
|
|
484
|
+
## Technical Notes
|
|
485
|
+
|
|
486
|
+
### CSS Classes
|
|
487
|
+
|
|
488
|
+
Col renders with **no base class**. Only utility classes are applied:
|
|
489
|
+
|
|
490
|
+
- Span: `.col-{1-12}`
|
|
491
|
+
- Offset: `.col-offset-{0-11}`
|
|
492
|
+
- Order: `.col-order-{first|last|0-12}`
|
|
493
|
+
- Auto: `.col-auto`
|
|
494
|
+
|
|
495
|
+
### Column Width Calculation
|
|
496
|
+
|
|
497
|
+
Column widths are calculated as:
|
|
498
|
+
|
|
499
|
+
```
|
|
500
|
+
width = (span / 12) * 100%
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
**Examples:**
|
|
504
|
+
|
|
505
|
+
- `.col-12` = 100% (12/12)
|
|
506
|
+
- `.col-6` = 50% (6/12)
|
|
507
|
+
- `.col-4` = 33.33% (4/12)
|
|
508
|
+
- `.col-3` = 25% (3/12)
|
|
509
|
+
- `.col-1` = 8.33% (1/12)
|
|
510
|
+
|
|
511
|
+
### Offset Calculation
|
|
512
|
+
|
|
513
|
+
Offsets use margin-inline-start:
|
|
514
|
+
|
|
515
|
+
```
|
|
516
|
+
margin-inline-start = (offset / 12) * 100%
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
**Examples:**
|
|
520
|
+
|
|
521
|
+
- `.col-offset-3` = 25% left margin
|
|
522
|
+
- `.col-offset-6` = 50% left margin
|
|
523
|
+
|
|
524
|
+
### Auto-Width Behavior
|
|
525
|
+
|
|
526
|
+
`.col-auto` uses `flex: 0 0 auto` with `width: auto`, allowing the column to
|
|
527
|
+
size based on its content.
|
|
528
|
+
|
|
529
|
+
### Performance
|
|
530
|
+
|
|
531
|
+
Col is a lightweight wrapper with no runtime overhead. All layout calculations
|
|
532
|
+
are handled via CSS utility classes at build time.
|