@kood/claude-code 0.3.16 → 0.3.17
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/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/.claude/skills/figma-to-code/SKILL.md +482 -0
- package/templates/.claude/skills/figma-to-code/references/design-tokens.md +400 -0
- package/templates/.claude/skills/figma-to-code/references/figma-mcp-tools.md +285 -0
- package/templates/.claude/skills/figma-to-code/references/layout-mapping.md +557 -0
- package/templates/.claude/skills/figma-to-code/references/responsive-design.md +364 -0
- package/templates/.claude/skills/figma-to-code/references/verification.md +219 -0
- package/templates/nextjs/docs/skills/figma-to-code/SKILL.md +482 -0
- package/templates/nextjs/docs/skills/figma-to-code/references/design-tokens.md +400 -0
- package/templates/nextjs/docs/skills/figma-to-code/references/figma-mcp-tools.md +285 -0
- package/templates/nextjs/docs/skills/figma-to-code/references/layout-mapping.md +557 -0
- package/templates/nextjs/docs/skills/figma-to-code/references/responsive-design.md +364 -0
- package/templates/nextjs/docs/skills/figma-to-code/references/verification.md +219 -0
- package/templates/tanstack-start/docs/skills/figma-to-code/SKILL.md +482 -0
- package/templates/tanstack-start/docs/skills/figma-to-code/references/design-tokens.md +400 -0
- package/templates/tanstack-start/docs/skills/figma-to-code/references/figma-mcp-tools.md +285 -0
- package/templates/tanstack-start/docs/skills/figma-to-code/references/layout-mapping.md +557 -0
- package/templates/tanstack-start/docs/skills/figma-to-code/references/responsive-design.md +364 -0
- package/templates/tanstack-start/docs/skills/figma-to-code/references/verification.md +219 -0
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
# Auto Layout → CSS Mapping
|
|
2
|
+
|
|
3
|
+
Guide for precisely converting Figma Auto Layout to Flexbox/Grid.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Auto Layout Fundamentals
|
|
8
|
+
|
|
9
|
+
Figma Auto Layout maps 1:1 to CSS Flexbox.
|
|
10
|
+
|
|
11
|
+
### Core Properties
|
|
12
|
+
|
|
13
|
+
| Figma Property | CSS Property | Description |
|
|
14
|
+
|---------------|----------|-------------|
|
|
15
|
+
| **layoutMode** | `flex-direction` | Horizontal/Vertical |
|
|
16
|
+
| **primaryAxisAlignItems** | `justify-content` | Main axis alignment |
|
|
17
|
+
| **counterAxisAlignItems** | `align-items` | Cross axis alignment |
|
|
18
|
+
| **itemSpacing** | `gap` | Element spacing |
|
|
19
|
+
| **padding** | `padding` | Internal padding |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Layout Mode
|
|
24
|
+
|
|
25
|
+
### Horizontal (Row)
|
|
26
|
+
|
|
27
|
+
**Figma:**
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"layoutMode": "HORIZONTAL"
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**CSS:**
|
|
35
|
+
```css
|
|
36
|
+
.container {
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: row;
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Tailwind:**
|
|
43
|
+
```tsx
|
|
44
|
+
<div className="flex flex-row">
|
|
45
|
+
<div>Item 1</div>
|
|
46
|
+
<div>Item 2</div>
|
|
47
|
+
</div>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Vertical (Column)
|
|
51
|
+
|
|
52
|
+
**Figma:**
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"layoutMode": "VERTICAL"
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**CSS:**
|
|
60
|
+
```css
|
|
61
|
+
.container {
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Tailwind:**
|
|
68
|
+
```tsx
|
|
69
|
+
<div className="flex flex-col">
|
|
70
|
+
<div>Item 1</div>
|
|
71
|
+
<div>Item 2</div>
|
|
72
|
+
</div>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Primary Axis Alignment (Main Axis)
|
|
78
|
+
|
|
79
|
+
### Horizontal Layout
|
|
80
|
+
|
|
81
|
+
| Figma | CSS | Tailwind | Description |
|
|
82
|
+
|-------|-----|----------|-------------|
|
|
83
|
+
| `MIN` | `justify-content: flex-start` | `justify-start` | Left |
|
|
84
|
+
| `CENTER` | `justify-content: center` | `justify-center` | Center |
|
|
85
|
+
| `MAX` | `justify-content: flex-end` | `justify-end` | Right |
|
|
86
|
+
| `SPACE_BETWEEN` | `justify-content: space-between` | `justify-between` | Both ends |
|
|
87
|
+
|
|
88
|
+
**Example:**
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
// Figma
|
|
92
|
+
{
|
|
93
|
+
"layoutMode": "HORIZONTAL",
|
|
94
|
+
"primaryAxisAlignItems": "CENTER"
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
// React
|
|
100
|
+
<div className="flex flex-row justify-center">
|
|
101
|
+
<button>Button 1</button>
|
|
102
|
+
<button>Button 2</button>
|
|
103
|
+
</div>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Vertical Layout
|
|
107
|
+
|
|
108
|
+
| Figma | CSS | Tailwind | Description |
|
|
109
|
+
|-------|-----|----------|-------------|
|
|
110
|
+
| `MIN` | `justify-content: flex-start` | `justify-start` | Top |
|
|
111
|
+
| `CENTER` | `justify-content: center` | `justify-center` | Center |
|
|
112
|
+
| `MAX` | `justify-content: flex-end` | `justify-end` | Bottom |
|
|
113
|
+
| `SPACE_BETWEEN` | `justify-content: space-between` | `justify-between` | Both ends |
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Counter Axis Alignment (Cross Axis)
|
|
118
|
+
|
|
119
|
+
### Horizontal Layout
|
|
120
|
+
|
|
121
|
+
| Figma | CSS | Tailwind | Description |
|
|
122
|
+
|-------|-----|----------|-------------|
|
|
123
|
+
| `MIN` | `align-items: flex-start` | `items-start` | Top |
|
|
124
|
+
| `CENTER` | `align-items: center` | `items-center` | Center |
|
|
125
|
+
| `MAX` | `align-items: flex-end` | `items-end` | Bottom |
|
|
126
|
+
| `BASELINE` | `align-items: baseline` | `items-baseline` | Baseline |
|
|
127
|
+
|
|
128
|
+
**Example:**
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
// Figma
|
|
132
|
+
{
|
|
133
|
+
"layoutMode": "HORIZONTAL",
|
|
134
|
+
"primaryAxisAlignItems": "SPACE_BETWEEN",
|
|
135
|
+
"counterAxisAlignItems": "CENTER"
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
// React
|
|
141
|
+
<div className="flex flex-row justify-between items-center">
|
|
142
|
+
<img src="/logo.png" alt="Logo" />
|
|
143
|
+
<nav>Menu</nav>
|
|
144
|
+
<button>Login</button>
|
|
145
|
+
</div>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Vertical Layout
|
|
149
|
+
|
|
150
|
+
| Figma | CSS | Tailwind | Description |
|
|
151
|
+
|-------|-----|----------|-------------|
|
|
152
|
+
| `MIN` | `align-items: flex-start` | `items-start` | Left |
|
|
153
|
+
| `CENTER` | `align-items: center` | `items-center` | Center |
|
|
154
|
+
| `MAX` | `align-items: flex-end` | `items-end` | Right |
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Item Spacing (Gap)
|
|
159
|
+
|
|
160
|
+
**Figma:**
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"itemSpacing": 16
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**CSS:**
|
|
168
|
+
```css
|
|
169
|
+
.container {
|
|
170
|
+
gap: 16px;
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Tailwind:**
|
|
175
|
+
```tsx
|
|
176
|
+
<div className="flex gap-[16px]">
|
|
177
|
+
<div>Item 1</div>
|
|
178
|
+
<div>Item 2</div>
|
|
179
|
+
</div>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Padding (Internal Spacing)
|
|
185
|
+
|
|
186
|
+
### Uniform Padding
|
|
187
|
+
|
|
188
|
+
**Figma:**
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"paddingLeft": 24,
|
|
192
|
+
"paddingRight": 24,
|
|
193
|
+
"paddingTop": 24,
|
|
194
|
+
"paddingBottom": 24
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Tailwind:**
|
|
199
|
+
```tsx
|
|
200
|
+
<div className="p-[24px]">
|
|
201
|
+
Content
|
|
202
|
+
</div>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Non-uniform Padding
|
|
206
|
+
|
|
207
|
+
**Figma:**
|
|
208
|
+
```json
|
|
209
|
+
{
|
|
210
|
+
"paddingLeft": 16,
|
|
211
|
+
"paddingRight": 16,
|
|
212
|
+
"paddingTop": 12,
|
|
213
|
+
"paddingBottom": 12
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Tailwind:**
|
|
218
|
+
```tsx
|
|
219
|
+
<div className="px-[16px] py-[12px]">
|
|
220
|
+
Content
|
|
221
|
+
</div>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Individual specification:**
|
|
225
|
+
```tsx
|
|
226
|
+
<div className="pl-[16px] pr-[16px] pt-[12px] pb-[12px]">
|
|
227
|
+
Content
|
|
228
|
+
</div>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Resizing (Size Adjustment)
|
|
234
|
+
|
|
235
|
+
### Fixed (Set Size)
|
|
236
|
+
|
|
237
|
+
**Figma:**
|
|
238
|
+
```json
|
|
239
|
+
{
|
|
240
|
+
"layoutGrow": 0,
|
|
241
|
+
"width": 120,
|
|
242
|
+
"height": 44
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Tailwind:**
|
|
247
|
+
```tsx
|
|
248
|
+
<button className="w-[120px] h-[44px]">
|
|
249
|
+
Button
|
|
250
|
+
</button>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Hug Contents (Fit Content)
|
|
254
|
+
|
|
255
|
+
**Figma:**
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"layoutGrow": 0,
|
|
259
|
+
"layoutSizingHorizontal": "HUG",
|
|
260
|
+
"layoutSizingVertical": "HUG"
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Tailwind:**
|
|
265
|
+
```tsx
|
|
266
|
+
<button className="w-auto h-auto">
|
|
267
|
+
Button text
|
|
268
|
+
</button>
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Fill Container (Expand)
|
|
272
|
+
|
|
273
|
+
**Figma:**
|
|
274
|
+
```json
|
|
275
|
+
{
|
|
276
|
+
"layoutGrow": 1
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**Tailwind:**
|
|
281
|
+
```tsx
|
|
282
|
+
<div className="flex-1">
|
|
283
|
+
Content
|
|
284
|
+
</div>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## Complex Examples
|
|
290
|
+
|
|
291
|
+
### Button
|
|
292
|
+
|
|
293
|
+
**Figma:**
|
|
294
|
+
```json
|
|
295
|
+
{
|
|
296
|
+
"name": "Button/Primary",
|
|
297
|
+
"type": "FRAME",
|
|
298
|
+
"layoutMode": "HORIZONTAL",
|
|
299
|
+
"primaryAxisAlignItems": "CENTER",
|
|
300
|
+
"counterAxisAlignItems": "CENTER",
|
|
301
|
+
"itemSpacing": 8,
|
|
302
|
+
"paddingLeft": 16,
|
|
303
|
+
"paddingRight": 16,
|
|
304
|
+
"paddingTop": 12,
|
|
305
|
+
"paddingBottom": 12,
|
|
306
|
+
"width": 120,
|
|
307
|
+
"height": 44,
|
|
308
|
+
"fills": [{ "color": { "r": 0.192, "g": 0.51, "b": 0.965 } }],
|
|
309
|
+
"cornerRadius": 8
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**Code:**
|
|
314
|
+
```tsx
|
|
315
|
+
<button className="
|
|
316
|
+
flex flex-row items-center justify-center
|
|
317
|
+
gap-[8px]
|
|
318
|
+
px-[16px] py-[12px]
|
|
319
|
+
w-[120px] h-[44px]
|
|
320
|
+
bg-[#3182F6]
|
|
321
|
+
rounded-[8px]
|
|
322
|
+
text-white font-semibold text-[14px]
|
|
323
|
+
">
|
|
324
|
+
<svg className="w-5 h-5" />
|
|
325
|
+
<span>Button</span>
|
|
326
|
+
</button>
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Card
|
|
330
|
+
|
|
331
|
+
**Figma:**
|
|
332
|
+
```json
|
|
333
|
+
{
|
|
334
|
+
"name": "Card",
|
|
335
|
+
"type": "FRAME",
|
|
336
|
+
"layoutMode": "VERTICAL",
|
|
337
|
+
"primaryAxisAlignItems": "MIN",
|
|
338
|
+
"counterAxisAlignItems": "MIN",
|
|
339
|
+
"itemSpacing": 16,
|
|
340
|
+
"paddingLeft": 24,
|
|
341
|
+
"paddingRight": 24,
|
|
342
|
+
"paddingTop": 24,
|
|
343
|
+
"paddingBottom": 24,
|
|
344
|
+
"layoutSizingHorizontal": "FILL",
|
|
345
|
+
"layoutSizingVertical": "HUG",
|
|
346
|
+
"fills": [{ "color": { "r": 1, "g": 1, "b": 1 } }],
|
|
347
|
+
"strokes": [{ "color": { "r": 0.9, "g": 0.9, "b": 0.9 } }],
|
|
348
|
+
"cornerRadius": 12
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
**Code:**
|
|
353
|
+
```tsx
|
|
354
|
+
<div className="
|
|
355
|
+
flex flex-col items-start justify-start
|
|
356
|
+
gap-[16px]
|
|
357
|
+
p-[24px]
|
|
358
|
+
w-full
|
|
359
|
+
bg-white
|
|
360
|
+
border border-gray-200
|
|
361
|
+
rounded-[12px]
|
|
362
|
+
">
|
|
363
|
+
<h3 className="text-[18px] font-semibold">Card Title</h3>
|
|
364
|
+
<p className="text-[14px] text-gray-700">Card content</p>
|
|
365
|
+
<button className="text-[14px] text-blue-500 font-medium">Details</button>
|
|
366
|
+
</div>
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Header (Horizontal + Space Between)
|
|
370
|
+
|
|
371
|
+
**Figma:**
|
|
372
|
+
```json
|
|
373
|
+
{
|
|
374
|
+
"name": "Header",
|
|
375
|
+
"layoutMode": "HORIZONTAL",
|
|
376
|
+
"primaryAxisAlignItems": "SPACE_BETWEEN",
|
|
377
|
+
"counterAxisAlignItems": "CENTER",
|
|
378
|
+
"itemSpacing": 24,
|
|
379
|
+
"paddingLeft": 32,
|
|
380
|
+
"paddingRight": 32,
|
|
381
|
+
"paddingTop": 16,
|
|
382
|
+
"paddingBottom": 16,
|
|
383
|
+
"layoutSizingHorizontal": "FILL",
|
|
384
|
+
"height": 64
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
**Code:**
|
|
389
|
+
```tsx
|
|
390
|
+
<header className="
|
|
391
|
+
flex flex-row justify-between items-center
|
|
392
|
+
gap-[24px]
|
|
393
|
+
px-[32px] py-[16px]
|
|
394
|
+
w-full h-[64px]
|
|
395
|
+
bg-white border-b
|
|
396
|
+
">
|
|
397
|
+
<img src="/logo.svg" alt="Logo" className="h-8" />
|
|
398
|
+
<nav className="flex gap-[24px]">
|
|
399
|
+
<a href="/">Home</a>
|
|
400
|
+
<a href="/about">About</a>
|
|
401
|
+
</nav>
|
|
402
|
+
<button className="px-[16px] py-[8px] bg-blue-500 text-white rounded-lg">
|
|
403
|
+
Login
|
|
404
|
+
</button>
|
|
405
|
+
</header>
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## Nested Auto Layout
|
|
411
|
+
|
|
412
|
+
### List Item
|
|
413
|
+
|
|
414
|
+
**Figma Structure:**
|
|
415
|
+
```
|
|
416
|
+
Frame "ListItem" (Horizontal, Space Between, Center)
|
|
417
|
+
├─ Frame "Left" (Horizontal, Center, gap: 12px)
|
|
418
|
+
│ ├─ Image "Thumbnail"
|
|
419
|
+
│ └─ Frame "Text" (Vertical, gap: 4px)
|
|
420
|
+
│ ├─ Text "Title"
|
|
421
|
+
│ └─ Text "Description"
|
|
422
|
+
└─ Frame "Right" (Horizontal, Center, gap: 8px)
|
|
423
|
+
├─ Text "Price"
|
|
424
|
+
└─ Icon "Arrow"
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
**Code:**
|
|
428
|
+
```tsx
|
|
429
|
+
<div className="
|
|
430
|
+
flex flex-row justify-between items-center
|
|
431
|
+
p-[16px]
|
|
432
|
+
hover:bg-gray-50 transition-colors
|
|
433
|
+
">
|
|
434
|
+
{/* Left */}
|
|
435
|
+
<div className="flex flex-row items-center gap-[12px]">
|
|
436
|
+
<img src="/thumb.jpg" className="w-[48px] h-[48px] rounded-lg" />
|
|
437
|
+
<div className="flex flex-col gap-[4px]">
|
|
438
|
+
<div className="text-[14px] font-semibold">Title</div>
|
|
439
|
+
<div className="text-[13px] text-gray-600">Description</div>
|
|
440
|
+
</div>
|
|
441
|
+
</div>
|
|
442
|
+
|
|
443
|
+
{/* Right */}
|
|
444
|
+
<div className="flex flex-row items-center gap-[8px]">
|
|
445
|
+
<span className="text-[14px] font-semibold">$15.00</span>
|
|
446
|
+
<svg className="w-5 h-5 text-gray-400" />
|
|
447
|
+
</div>
|
|
448
|
+
</div>
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## Constraints (Constraints)
|
|
454
|
+
|
|
455
|
+
Figma Constraints define responsive behavior.
|
|
456
|
+
|
|
457
|
+
| Figma Constraint | CSS Equivalent |
|
|
458
|
+
|-----------------|----------|
|
|
459
|
+
| **Left + Right** | `width: 100%` (fill parent width) |
|
|
460
|
+
| **Left** | `margin-right: auto` (fixed left) |
|
|
461
|
+
| **Right** | `margin-left: auto` (fixed right) |
|
|
462
|
+
| **Center** | `margin: 0 auto` (center alignment) |
|
|
463
|
+
| **Scale** | `width: 50%` (maintain ratio) |
|
|
464
|
+
|
|
465
|
+
**Example:**
|
|
466
|
+
|
|
467
|
+
```json
|
|
468
|
+
// Figma: Left + Right Constraint
|
|
469
|
+
{
|
|
470
|
+
"constraints": {
|
|
471
|
+
"horizontal": "LEFT_RIGHT",
|
|
472
|
+
"vertical": "TOP"
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
```tsx
|
|
478
|
+
// Responsive: fill parent width
|
|
479
|
+
<div className="w-full">
|
|
480
|
+
Content
|
|
481
|
+
</div>
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
## Absolute Positioning
|
|
487
|
+
|
|
488
|
+
**Figma:**
|
|
489
|
+
```json
|
|
490
|
+
{
|
|
491
|
+
"layoutPositioning": "ABSOLUTE",
|
|
492
|
+
"x": 20,
|
|
493
|
+
"y": 20
|
|
494
|
+
}
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
**CSS:**
|
|
498
|
+
```css
|
|
499
|
+
.element {
|
|
500
|
+
position: absolute;
|
|
501
|
+
left: 20px;
|
|
502
|
+
top: 20px;
|
|
503
|
+
}
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
**Tailwind:**
|
|
507
|
+
```tsx
|
|
508
|
+
<div className="absolute left-[20px] top-[20px]">
|
|
509
|
+
Floating Element
|
|
510
|
+
</div>
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
## Best Practices
|
|
516
|
+
|
|
517
|
+
### DO
|
|
518
|
+
|
|
519
|
+
| Principle | Description |
|
|
520
|
+
|-----------|-------------|
|
|
521
|
+
| **Auto Layout First** | Use Flexbox instead of Absolute positioning |
|
|
522
|
+
| **Exact gap** | Use `gap-[18px]` not `gap-4` |
|
|
523
|
+
| **Hug → auto** | Hug Contents → `w-auto h-auto` |
|
|
524
|
+
| **Fill → flex-1** | Fill Container → `flex-1` |
|
|
525
|
+
|
|
526
|
+
### DON'T
|
|
527
|
+
|
|
528
|
+
| Forbidden | Reason |
|
|
529
|
+
|-----------|--------|
|
|
530
|
+
| **Arbitrary margin** | Auto Layout uses gap |
|
|
531
|
+
| **Use float** | Flexbox is sufficient |
|
|
532
|
+
| **Use inline-block** | Handle as flex item |
|
|
533
|
+
|
|
534
|
+
---
|
|
535
|
+
|
|
536
|
+
## Conversion Checklist
|
|
537
|
+
|
|
538
|
+
```
|
|
539
|
+
□ layoutMode → flex-direction
|
|
540
|
+
□ primaryAxisAlignItems → justify-content
|
|
541
|
+
□ counterAxisAlignItems → align-items
|
|
542
|
+
□ itemSpacing → gap (exact px)
|
|
543
|
+
□ padding → p-[Npx] / px-[Npx] py-[Npx]
|
|
544
|
+
□ layoutGrow → flex-1 / flex-0
|
|
545
|
+
□ width/height → w-[Npx] h-[Npx]
|
|
546
|
+
□ cornerRadius → rounded-[Npx]
|
|
547
|
+
□ fills → bg-[#HEX]
|
|
548
|
+
□ strokes → border border-[#HEX]
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
---
|
|
552
|
+
|
|
553
|
+
## References
|
|
554
|
+
|
|
555
|
+
- [Figma Auto Layout](https://help.figma.com/hc/en-us/articles/360040451373)
|
|
556
|
+
- [CSS Flexbox Guide](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)
|
|
557
|
+
- [Tailwind Flexbox](https://tailwindcss.com/docs/flex)
|