@unlayer/react-elements 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/README.md +77 -49
  2. package/package.json +13 -1
package/README.md CHANGED
@@ -21,23 +21,25 @@ function WelcomeEmail() {
21
21
  <Row layout={ColumnLayouts.TwoEqual} backgroundColor="#ffffff" padding="20px">
22
22
  <Column>
23
23
  <Heading
24
- text="Hello World"
25
24
  fontSize="24px"
26
25
  fontFamily={{ label: "Arial", value: "arial,helvetica,sans-serif" }}
27
- />
26
+ >
27
+ Hello World
28
+ </Heading>
28
29
  </Column>
29
30
  <Column>
30
- <Paragraph text="Welcome to our newsletter!" fontSize="14px" />
31
+ <Paragraph html="Welcome to our newsletter!" fontSize="14px" />
31
32
  </Column>
32
33
  </Row>
33
34
  <Row layout={ColumnLayouts.OneColumn} padding="10px">
34
35
  <Column>
35
36
  <Button
36
- text="Click Me"
37
37
  href="https://example.com"
38
38
  backgroundColor="#0879A1"
39
39
  color="#ffffff"
40
- />
40
+ >
41
+ Click Me
42
+ </Button>
41
43
  </Column>
42
44
  </Row>
43
45
  </Email>
@@ -57,7 +59,8 @@ These props have non-obvious shapes that **must** be followed exactly:
57
59
  - **Wrapper component**: Use `<Email>`, `<Page>`, or `<Document>` as root — they set the rendering mode automatically.
58
60
  - **href**: Can be a plain string URL (auto-wrapped) or `{ name: "web", values: { href, target } }`.
59
61
  - **Image src**: Can be a plain string URL (auto-wrapped) or `{ url, width?, autoWidth?, maxWidth? }`.
60
- - **children**: Text components accept children as shorthand for `text` prop. `<Paragraph>Hello</Paragraph>` = `<Paragraph text="Hello" />`.
62
+ - **children**: Text components accept children as shorthand. `<Heading>Hello</Heading>` sets the heading text. `<Paragraph>` supports children for plain text.
63
+ - **Paragraph text**: Use `html` prop for text content (supports inline formatting like `<b>`, `<a>`). Use children for plain text.
61
64
 
62
65
  ## Structure: Email/Page/Document > Row > Column > Items
63
66
 
@@ -97,9 +100,9 @@ These props have non-obvious shapes that **must** be followed exactly:
97
100
  | Component | Description |
98
101
  |-----------|-------------|
99
102
  | `<Button>` | CTA button with hover states, links, and full styling |
100
- | `<Paragraph>` | Rich text with `text` (plain) or `html` (formatted) props |
101
- | `<Heading>` | Heading (h1-h4) with `level` shorthand |
102
- | `<Image>` | Responsive image with `src` / `alt` shorthands |
103
+ | `<Paragraph>` | Rich text with `html` (formatted) prop or children (plain text) |
104
+ | `<Heading>` | Heading (h1-h4) with `headingType` prop |
105
+ | `<Image>` | Responsive image with `src` / `altText` props |
103
106
  | `<Divider>` | Horizontal rule / separator |
104
107
  | `<Social>` | Social media icons with `icons` shorthand array |
105
108
  | `<Menu>` | Navigation menu with `items` shorthand array |
@@ -152,59 +155,51 @@ Must be child of Row. Count must match layout.
152
155
  - `padding?: string` — `"10px 20px"`
153
156
  - `borderRadius?: string` — `"4px"`
154
157
  - `textAlign?: "left" | "center" | "right"` — `"center"`
155
- - `containerPadding?: string`
156
158
 
157
159
  ### Paragraph
158
- - `text?: string` — plain text (auto-converted to Lexical JSON internally)
159
160
  - `html?: string` — **rich HTML string** with inline formatting: `<b>`, `<i>`, `<u>`, `<s>`, `<a>`, `<code>`
161
+ - `children` — plain text shorthand (auto-converted internally)
160
162
  - `fontSize?: string` — `"14px"`
161
163
  - `color?: string` — `"#000000"`
162
164
  - `textAlign?: "left" | "center" | "right"` — `"left"`
163
165
  - `lineHeight?: string` — `"140%"`
164
166
  - `fontFamily?: { label: string, value: string }`
165
- - `containerPadding?: string`
166
167
 
167
- Priority: `html` > `text` > children. Use `html` for formatted text, `text` for plain text.
168
+ Use `html` for formatted text, children for plain text.
168
169
 
169
170
  ```tsx
170
- <Paragraph text="Plain text paragraph" fontSize="14px" />
171
171
  <Paragraph html="Hello <b>bold</b> and <a href='#'>link</a>" fontSize="14px" />
172
+ <Paragraph fontSize="14px">Plain text paragraph</Paragraph>
172
173
  ```
173
174
 
174
175
  ### Heading
175
176
  - `text?: string` — `"Heading"` (or use children)
176
177
  - `headingType?: "h1" | "h2" | "h3" | "h4"` — `"h1"`
177
- - `level?: "h1" | "h2" | "h3" | "h4"` — shorthand for headingType
178
178
  - `fontSize?: string` — `"22px"`
179
179
  - `fontWeight?: number` — `400`
180
180
  - `fontFamily?: { label: string, value: string }`
181
181
  - `color?: string` — `"#000000"`
182
182
  - `textAlign?: "left" | "center" | "right"` — `"left"`
183
183
  - `lineHeight?: string` — `"110%"`
184
- - `containerPadding?: string`
185
184
 
186
185
  ### Divider
187
186
  - `borderTopWidth?: string` — `"1px"`
188
187
  - `borderTopColor?: string` — `"#BBBBBB"`
189
188
  - `borderTopStyle?: string` — `"solid"`
190
189
  - `textAlign?: "left" | "center" | "right"` — `"center"`
191
- - `containerPadding?: string`
192
190
 
193
191
  ### Image
194
192
  - `src?: string | { url, width?, autoWidth?, maxWidth? }` — string URLs auto-wrapped
195
193
  - `altText?: string` — alt text for accessibility
196
194
  - `textAlign?: "left" | "center" | "right"` — `"center"`
197
195
  - `action?: { name: "web", values: { href, target } }`
198
- - `containerPadding?: string`
199
196
 
200
197
  ### Video
201
198
  - `videoUrl?: string` — YouTube/Vimeo URL, auto-parsed
202
199
  - `video?: { type: "youtube" | "vimeo", videoId, thumbnail }` — manual control
203
- - `containerPadding?: string`
204
200
 
205
201
  ### Html
206
202
  - `html?: string` — `"<p>Custom HTML content</p>"`
207
- - `containerPadding?: string`
208
203
 
209
204
  ### Table
210
205
  - `headers?: string[]` — shorthand for column headers
@@ -212,7 +207,6 @@ Priority: `html` > `text` > children. Use `html` for formatted text, `text` for
212
207
  - `columns?: number` — `3`
213
208
  - `rows?: number` — `3`
214
209
  - `enableHeader?: boolean` — `true`
215
- - `containerPadding?: string`
216
210
 
217
211
  ### Social
218
212
  - `icons?: { name: string, url: string }[]` — shorthand
@@ -220,14 +214,12 @@ Priority: `html` > `text` > children. Use `html` for formatted text, `text` for
220
214
  - `iconSize?: number` — `32`
221
215
  - `spacing?: number` — `10`
222
216
  - `align?: "left" | "center" | "right"` — `"center"`
223
- - `containerPadding?: string`
224
217
 
225
218
  ### Menu
226
219
  - `items?: { text: string, href: string, target?: string }[]` — shorthand
227
220
  - `layout?: "horizontal" | "vertical"` — `"horizontal"`
228
221
  - `separator?: string` — `"|"`
229
222
  - `align?: "left" | "center" | "right"` — `"center"`
230
- - `containerPadding?: string`
231
223
 
232
224
  ## Column Layouts
233
225
 
@@ -236,15 +228,49 @@ Pre-built layouts for common column configurations:
236
228
  ```tsx
237
229
  import { Row, Column, ColumnLayouts } from '@unlayer/react-elements';
238
230
 
239
- <Row layout={ColumnLayouts.OneColumn}> {/* [1] → 100% */}
240
- <Row layout={ColumnLayouts.TwoEqual}> {/* [1,1] 50% + 50% */}
241
- <Row layout={ColumnLayouts.TwoWideNarrow}> {/* [2,1] → 67% + 33% */}
242
- <Row layout={ColumnLayouts.TwoNarrowWide}> {/* [1,2] → 33% + 67% */}
243
- <Row layout={ColumnLayouts.ThreeEqual}> {/* [1,1,1] 33% each */}
244
- <Row layout={ColumnLayouts.ThreeNarrowWideNarrow}> {/* [1,2,1] → 25% + 50% + 25% */}
245
- <Row layout={ColumnLayouts.FourEqual}> {/* [1,1,1,1] → 25% each */}
246
- <Row layout={ColumnLayouts.FiveEqual}> {/* [1,1,1,1,1] → 20% each */}
247
- <Row cells={[3, 1]}> {/* Custom ratio */}
231
+ // Each Row must contain the matching number of <Column> children.
232
+ <Row layout={ColumnLayouts.OneColumn}> {/* [1] 100% */}
233
+ <Column>{/* content */}</Column>
234
+ </Row>
235
+ <Row layout={ColumnLayouts.TwoEqual}> {/* [1,1] 50% + 50% */}
236
+ <Column>{/* content */}</Column>
237
+ <Column>{/* content */}</Column>
238
+ </Row>
239
+ <Row layout={ColumnLayouts.TwoWideNarrow}> {/* [2,1] → 67% + 33% */}
240
+ <Column>{/* content */}</Column>
241
+ <Column>{/* content */}</Column>
242
+ </Row>
243
+ <Row layout={ColumnLayouts.TwoNarrowWide}> {/* [1,2] → 33% + 67% */}
244
+ <Column>{/* content */}</Column>
245
+ <Column>{/* content */}</Column>
246
+ </Row>
247
+ <Row layout={ColumnLayouts.ThreeEqual}> {/* [1,1,1] → 33% each */}
248
+ <Column>{/* content */}</Column>
249
+ <Column>{/* content */}</Column>
250
+ <Column>{/* content */}</Column>
251
+ </Row>
252
+ <Row layout={ColumnLayouts.ThreeNarrowWideNarrow}> {/* [1,2,1] → 25% + 50% + 25% */}
253
+ <Column>{/* content */}</Column>
254
+ <Column>{/* content */}</Column>
255
+ <Column>{/* content */}</Column>
256
+ </Row>
257
+ <Row layout={ColumnLayouts.FourEqual}> {/* [1,1,1,1] → 25% each */}
258
+ <Column>{/* content */}</Column>
259
+ <Column>{/* content */}</Column>
260
+ <Column>{/* content */}</Column>
261
+ <Column>{/* content */}</Column>
262
+ </Row>
263
+ <Row layout={ColumnLayouts.FiveEqual}> {/* [1,1,1,1,1] → 20% each */}
264
+ <Column>{/* content */}</Column>
265
+ <Column>{/* content */}</Column>
266
+ <Column>{/* content */}</Column>
267
+ <Column>{/* content */}</Column>
268
+ <Column>{/* content */}</Column>
269
+ </Row>
270
+ <Row cells={[3, 1]}> {/* Custom ratio */}
271
+ <Column>{/* content */}</Column>
272
+ <Column>{/* content */}</Column>
273
+ </Row>
248
274
  ```
249
275
 
250
276
  Number of `<Column>` children must match the layout.
@@ -272,12 +298,13 @@ const html = renderToHtml(
272
298
  <Email backgroundColor="#f4f4f4">
273
299
  <Row layout={ColumnLayouts.OneColumn}>
274
300
  <Column>
275
- <Paragraph text="Hello World" fontSize="14px" />
301
+ <Paragraph html="Hello World" fontSize="14px" />
276
302
  <Button
277
- text="Click me"
278
303
  backgroundColor="#3b82f6"
279
304
  color="#ffffff"
280
- />
305
+ >
306
+ Click me
307
+ </Button>
281
308
  </Column>
282
309
  </Row>
283
310
  </Email>
@@ -351,9 +378,9 @@ const monoFont = { label: "Monospace", value: "'SF Mono', 'Fira Code', 'Roboto M
351
378
  ### Accent Bar
352
379
 
353
380
  ```tsx
354
- <Row layout={ColumnLayouts.OneColumn} backgroundColor="#4f46e5" padding="0">
381
+ <Row layout={ColumnLayouts.OneColumn} backgroundColor="#4f46e5" padding="0px">
355
382
  <Column>
356
- <Divider borderTopWidth="3px" borderTopColor="#4f46e5" borderTopStyle="solid" containerPadding="0" />
383
+ <Divider borderTopWidth="3px" borderTopColor="#4f46e5" borderTopStyle="solid" />
357
384
  </Column>
358
385
  </Row>
359
386
  ```
@@ -363,12 +390,12 @@ const monoFont = { label: "Monospace", value: "'SF Mono', 'Fira Code', 'Roboto M
363
390
  ```tsx
364
391
  <Row layout={ColumnLayouts.TwoEqual} backgroundColor="#ffffff" padding="24px 40px">
365
392
  <Column>
366
- <Heading text="Feature 1" headingType="h3" fontSize="16px" fontWeight={600} color="#1a1a1a" />
367
- <Paragraph text="Description of the feature." fontSize="13px" color="#71717a" />
393
+ <Heading headingType="h3" fontSize="16px" fontWeight={600} color="#1a1a1a">Feature 1</Heading>
394
+ <Paragraph html="Description of the feature." fontSize="13px" color="#71717a" />
368
395
  </Column>
369
396
  <Column>
370
- <Heading text="Feature 2" headingType="h3" fontSize="16px" fontWeight={600} color="#1a1a1a" />
371
- <Paragraph text="Description of the feature." fontSize="13px" color="#71717a" />
397
+ <Heading headingType="h3" fontSize="16px" fontWeight={600} color="#1a1a1a">Feature 2</Heading>
398
+ <Paragraph html="Description of the feature." fontSize="13px" color="#71717a" />
372
399
  </Column>
373
400
  </Row>
374
401
  ```
@@ -376,10 +403,10 @@ const monoFont = { label: "Monospace", value: "'SF Mono', 'Fira Code', 'Roboto M
376
403
  ### Metric Cards (3-column)
377
404
 
378
405
  ```tsx
379
- <Row layout={ColumnLayouts.ThreeEqual} backgroundColor="#ffffff" padding="0 40px">
406
+ <Row layout={ColumnLayouts.ThreeEqual} backgroundColor="#ffffff" padding="0px 40px">
380
407
  <Column>
381
- <Heading text="1.2M" headingType="h2" fontSize="28px" fontWeight={700} color="#0f172a" textAlign="center" />
382
- <Paragraph text="API Calls" fontSize="12px" color="#94a3b8" textAlign="center" />
408
+ <Heading headingType="h2" fontSize="28px" fontWeight={700} color="#0f172a" textAlign="center">1.2M</Heading>
409
+ <Paragraph html="API Calls" fontSize="12px" color="#94a3b8" textAlign="center" />
383
410
  </Column>
384
411
  {/* Repeat for each metric */}
385
412
  </Row>
@@ -393,9 +420,9 @@ const monoFont = { label: "Monospace", value: "'SF Mono', 'Fira Code', 'Roboto M
393
420
  <Image src="https://example.com/product.jpg" altText="Product" />
394
421
  </Column>
395
422
  <Column>
396
- <Heading text="Product Name" headingType="h3" fontSize="16px" fontWeight={600} color="#1a1a1a" />
397
- <Paragraph text="Matte White · Medium" fontSize="13px" color="#a1a1aa" />
398
- <Heading text="$89.00" headingType="h3" fontSize="16px" fontWeight={700} color="#1a1a1a" />
423
+ <Heading headingType="h3" fontSize="16px" fontWeight={600} color="#1a1a1a">Product Name</Heading>
424
+ <Paragraph html="Matte White · Medium" fontSize="13px" color="#a1a1aa" />
425
+ <Heading headingType="h3" fontSize="16px" fontWeight={700} color="#1a1a1a">$89.00</Heading>
399
426
  </Column>
400
427
  </Row>
401
428
  ```
@@ -405,7 +432,7 @@ const monoFont = { label: "Monospace", value: "'SF Mono', 'Fira Code', 'Roboto M
405
432
  ```tsx
406
433
  <Row layout={ColumnLayouts.OneColumn} padding="20px 40px 40px 40px">
407
434
  <Column>
408
- <Paragraph text="Company Name · City, State" fontSize="12px" color="#a1a1aa" textAlign="center" />
435
+ <Paragraph html="Company Name · City, State" fontSize="12px" color="#a1a1aa" textAlign="center" />
409
436
  </Column>
410
437
  </Row>
411
438
  ```
@@ -417,7 +444,8 @@ const monoFont = { label: "Monospace", value: "'SF Mono', 'Fira Code', 'Roboto M
417
444
  3. **Column count mismatch** — `TwoEqual` layout requires exactly 2 `<Column>` children
418
445
  4. **Missing Column** — Items must be inside `<Column>`, never directly in `<Row>`
419
446
  5. **Missing Row** — Columns must be inside `<Row>`, never directly in `<Email>`/`<Page>`/`<Document>`
420
- 6. **containerPadding vs padding** — `padding` is on Row/Column containers; `containerPadding` is per-item internal spacing
447
+ 6. **Paragraph text prop** — Use `html` prop or children, not `text` (which is not typed for Paragraph)
448
+ 7. **padding without units** — Use `padding="0px"` not `padding="0"` — the type requires the `px` suffix for consistency
421
449
 
422
450
  ## Development
423
451
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unlayer/react-elements",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "React components for building emails, pages, and documents with Unlayer Elements",
5
5
  "license": "MIT",
6
6
  "author": "Unlayer",
@@ -10,6 +10,18 @@
10
10
  "directory": "packages/react"
11
11
  },
12
12
  "homepage": "https://github.com/unlayer/elements",
13
+ "keywords": [
14
+ "email",
15
+ "react-email",
16
+ "email-components",
17
+ "html-email",
18
+ "email-templates",
19
+ "react-components",
20
+ "email-builder",
21
+ "server-components",
22
+ "ssr",
23
+ "unlayer"
24
+ ],
13
25
  "sideEffects": false,
14
26
  "peerDependencies": {
15
27
  "react": ">=18",