@primer/react 0.0.0-20260519124320 → 0.0.0-20260519202353

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260519124320
3
+ ## 0.0.0-20260519202353
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -24,7 +24,7 @@
24
24
 
25
25
  - [#7776](https://github.com/primer/react/pull/7776) [`d6f61c1`](https://github.com/primer/react/commit/d6f61c1e197b52eb75cff97299bfac4caedcc1ac) Thanks [@llastflowers](https://github.com/llastflowers)! - Add `data-component` attributes for Blankslate, BranchName, Breadcrumbs, ButtonGroup, Checkbox, CheckboxGroup, CircleBadge, ConfirmationDialog, CounterLabel, and Dialog to provide stable selectors.
26
26
 
27
- - [#7852](https://github.com/primer/react/pull/7852) [`8966e0d`](https://github.com/primer/react/commit/8966e0dddd591fa83cc89b962ec1a6d8c0faa875) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Card: Add `data-component` attributes to `Card` and its subcomponents (`Icon`, `Image`, `Heading`, `Description`, `Metadata`, `Menu`). `Card` now requires `children`. Also improves docs and stories.
27
+ - [#7852](https://github.com/primer/react/pull/7852) [`8966e0d`](https://github.com/primer/react/commit/8966e0dddd591fa83cc89b962ec1a6d8c0faa875) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Card: Add `data-component` attributes to `Card` and its subcomponents (`Icon`, `Image`, `Heading`, `Description`, `Metadata`, `Menu`). Add an `as` prop (`'div' | 'section'`) so standalone Cards can render as a labelled region landmark; `as="section"` requires `aria-label` or `aria-labelledby`. `Card` now requires `children`. Also improves docs and stories.
28
28
 
29
29
  - [#7816](https://github.com/primer/react/pull/7816) [`aef8548`](https://github.com/primer/react/commit/aef85486a77a544ab36fcc18470dc06bf2502b09) Thanks [@iansan5653](https://github.com/iansan5653)! - Replace `ActionBar` overflow calculations with CSS wrapping approach to improve performance and stability
30
30
 
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export type CardProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> & {
2
+ type BaseCardProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> & {
3
3
  /**
4
4
  * Provide an optional className to add to the outermost element rendered by
5
5
  * the Card
@@ -25,6 +25,32 @@ export type CardProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children'>
25
25
  */
26
26
  children: React.ReactNode;
27
27
  };
28
+ /**
29
+ * Card rendered as a `<div>` — the default. Use this variant when the Card
30
+ * is inside an `<li>` of a list of cards: the surrounding list already
31
+ * provides grouping, so no additional landmark is needed. Do **not** use
32
+ * `Card.Heading` in this context — screen readers handle list items and
33
+ * headings as separate navigation modes, and combining them produces a
34
+ * confusing experience.
35
+ */
36
+ type DivCardProps = BaseCardProps & {
37
+ as?: 'div';
38
+ };
39
+ /**
40
+ * Card rendered as a `<section>` — use this variant for standalone Cards
41
+ * that are **not** part of a list of cards. The `<section>` becomes a
42
+ * labelled region landmark for screen-reader users, so an accessible name
43
+ * is required via either `aria-label` or `aria-labelledby` (typically
44
+ * referencing the id of the `Card.Heading`).
45
+ */
46
+ type SectionCardProps = BaseCardProps & {
47
+ as: 'section';
48
+ } & ({
49
+ 'aria-label': string;
50
+ } | {
51
+ 'aria-labelledby': string;
52
+ });
53
+ export type CardProps = DivCardProps | SectionCardProps;
28
54
  type HeadingLevel = 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
29
55
  type HeadingProps = React.ComponentPropsWithoutRef<'h3'> & {
30
56
  /**
@@ -80,32 +106,7 @@ type MetadataProps = React.ComponentPropsWithoutRef<'div'> & {
80
106
  */
81
107
  children: React.ReactNode;
82
108
  };
83
- declare const CardImpl: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "children"> & {
84
- /**
85
- * Provide an optional className to add to the outermost element rendered by
86
- * the Card
87
- */
88
- className?: string;
89
- /**
90
- * Controls the internal padding of the Card.
91
- * @default 'normal'
92
- */
93
- padding?: "none" | "condensed" | "normal";
94
- /**
95
- * Controls the border radius of the Card.
96
- * @default 'large'
97
- */
98
- borderRadius?: "medium" | "large";
99
- /**
100
- * The contents of the card. Provide either `Card.*` subcomponents (for
101
- * example `Card.Heading`, `Card.Description`, `Card.Metadata`) or any
102
- * custom content.
103
- *
104
- * A card with no children will not render — at least one meaningful
105
- * child is required.
106
- */
107
- children: React.ReactNode;
108
- } & React.RefAttributes<HTMLDivElement>>;
109
+ declare const CardImpl: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLDivElement>>;
109
110
  declare const CardIcon: {
110
111
  ({ icon: IconComponent, "aria-label": ariaLabel, className }: IconProps): React.JSX.Element;
111
112
  displayName: string;
@@ -114,6 +115,19 @@ declare const CardImage: {
114
115
  ({ src, alt, className, ...rest }: ImageProps): React.JSX.Element;
115
116
  displayName: string;
116
117
  };
118
+ /**
119
+ * Heading shown at the top of a Card.
120
+ *
121
+ * Accessibility:
122
+ * - Use only on **standalone** Cards (those rendered with `as="section"`).
123
+ * When the Card is inside an `<li>` in a list of cards, the surrounding
124
+ * list already provides grouping; adding a heading produces a confusing
125
+ * experience for screen-reader users, who handle list items and headings
126
+ * as separate navigation modes.
127
+ * - Pair with `aria-labelledby` on the parent `Card` (referencing the
128
+ * heading's `id`) so the section landmark uses the visible heading as
129
+ * its accessible name.
130
+ */
117
131
  declare const CardHeading: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & {
118
132
  /**
119
133
  * The heading level to render. Defaults to 'h3'.
@@ -1 +1 @@
1
- {"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/Card/Card.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAIvC,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CA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,IAAI,cAAc,EAAC,CAAA;AAC1C,YAAY,EAAC,SAAS,IAAI,aAAa,EAAC,CAAA;AACxC,YAAY,EAAC,aAAa,IAAI,iBAAiB,EAAC,CAAA"}
package/dist/Card/Card.js CHANGED
@@ -5,19 +5,22 @@ import classes from './Card.module.css.js';
5
5
  import { warning } from '../utils/warning.js';
6
6
  import { jsx, jsxs } from 'react/jsx-runtime';
7
7
 
8
- const CardImpl = /*#__PURE__*/forwardRef(function Card(t0, ref) {
9
- const $ = c(55);
8
+ const CardImpl = /*#__PURE__*/forwardRef(function Card(props, ref) {
9
+ const $ = c(61);
10
+ const t0 = props;
10
11
  let children;
11
12
  let className;
12
13
  let rest;
13
14
  let t1;
14
15
  let t2;
16
+ let t3;
15
17
  if ($[0] !== t0) {
16
18
  ({
17
19
  children,
18
20
  className,
19
21
  padding: t1,
20
22
  borderRadius: t2,
23
+ as: t3,
21
24
  ...rest
22
25
  } = t0);
23
26
  $[0] = t0;
@@ -26,29 +29,34 @@ const CardImpl = /*#__PURE__*/forwardRef(function Card(t0, ref) {
26
29
  $[3] = rest;
27
30
  $[4] = t1;
28
31
  $[5] = t2;
32
+ $[6] = t3;
29
33
  } else {
30
34
  children = $[1];
31
35
  className = $[2];
32
36
  rest = $[3];
33
37
  t1 = $[4];
34
38
  t2 = $[5];
39
+ t3 = $[6];
35
40
  }
36
41
  const padding = t1 === undefined ? "normal" : t1;
37
42
  const borderRadius = t2 === undefined ? "large" : t2;
43
+ const as = t3 === undefined ? "div" : t3;
44
+ const Component = as;
45
+ let T0;
38
46
  let description;
39
47
  let heading;
40
48
  let menu;
41
49
  let metadata;
42
50
  let t10;
43
- let t3;
51
+ let t11;
44
52
  let t4;
45
53
  let t5;
46
54
  let t6;
47
55
  let t7;
48
56
  let t8;
49
57
  let t9;
50
- if ($[6] !== borderRadius || $[7] !== children || $[8] !== className || $[9] !== padding || $[10] !== ref || $[11] !== rest) {
51
- t10 = Symbol.for("react.early_return_sentinel");
58
+ if ($[7] !== Component || $[8] !== as || $[9] !== borderRadius || $[10] !== children || $[11] !== className || $[12] !== padding || $[13] !== ref || $[14] !== rest) {
59
+ t11 = Symbol.for("react.early_return_sentinel");
52
60
  bb0: {
53
61
  let icon = null;
54
62
  let image = null;
@@ -88,166 +96,177 @@ const CardImpl = /*#__PURE__*/forwardRef(function Card(t0, ref) {
88
96
  const hasSlotChildren = icon || image || heading || description || metadata || menu;
89
97
  const isEmpty = !hasSlotChildren && childArray.length === 0;
90
98
  process.env.NODE_ENV !== "production" ? warning(isEmpty, "The <Card> component was rendered with no children and will not render. Provide either Card subcomponents (Card.Heading, Card.Description, etc.) or custom content.") : void 0;
99
+ const ariaLabel = rest["aria-label"];
100
+ const ariaLabelledby = rest["aria-labelledby"];
101
+ process.env.NODE_ENV !== "production" ? warning(as === "section" && !ariaLabel && !ariaLabelledby, "The <Card> component used with `as=\"section\"` requires either `aria-label` or `aria-labelledby` so screen-reader users can identify the labelled region. Typically `aria-labelledby` should reference the id of the `Card.Heading`.") : void 0;
91
102
  if (isEmpty) {
92
- t10 = null;
103
+ t11 = null;
93
104
  break bb0;
94
105
  }
95
106
  if (!hasSlotChildren) {
96
- let t11;
97
- if ($[24] !== className) {
98
- t11 = clsx(classes.Card, className);
99
- $[24] = className;
100
- $[25] = t11;
107
+ const t12 = ref;
108
+ let t13;
109
+ if ($[28] !== className) {
110
+ t13 = clsx(classes.Card, className);
111
+ $[28] = className;
112
+ $[29] = t13;
101
113
  } else {
102
- t11 = $[25];
114
+ t13 = $[29];
103
115
  }
104
- let t12;
105
- if ($[26] !== borderRadius || $[27] !== children || $[28] !== padding || $[29] !== ref || $[30] !== rest || $[31] !== t11) {
106
- t12 = /*#__PURE__*/jsx("div", {
107
- ref: ref,
108
- className: t11,
116
+ let t14;
117
+ if ($[30] !== Component || $[31] !== borderRadius || $[32] !== children || $[33] !== padding || $[34] !== rest || $[35] !== t12 || $[36] !== t13) {
118
+ t14 = /*#__PURE__*/jsx(Component, {
119
+ ref: t12,
120
+ className: t13,
109
121
  "data-component": "Card",
110
122
  "data-padding": padding,
111
123
  "data-border-radius": borderRadius,
112
124
  ...rest,
113
125
  children: children
114
126
  });
115
- $[26] = borderRadius;
116
- $[27] = children;
117
- $[28] = padding;
118
- $[29] = ref;
119
- $[30] = rest;
120
- $[31] = t11;
121
- $[32] = t12;
127
+ $[30] = Component;
128
+ $[31] = borderRadius;
129
+ $[32] = children;
130
+ $[33] = padding;
131
+ $[34] = rest;
132
+ $[35] = t12;
133
+ $[36] = t13;
134
+ $[37] = t14;
122
135
  } else {
123
- t12 = $[32];
136
+ t14 = $[37];
124
137
  }
125
- t10 = t12;
138
+ t11 = t14;
126
139
  break bb0;
127
140
  }
128
- t3 = ref;
129
- if ($[33] !== className) {
130
- t4 = clsx(classes.Card, className);
131
- $[33] = className;
132
- $[34] = t4;
141
+ T0 = Component;
142
+ t4 = ref;
143
+ if ($[38] !== className) {
144
+ t5 = clsx(classes.Card, className);
145
+ $[38] = className;
146
+ $[39] = t5;
133
147
  } else {
134
- t4 = $[34];
148
+ t5 = $[39];
135
149
  }
136
- t5 = "Card";
137
- t6 = padding;
138
- t7 = borderRadius;
139
- t8 = rest;
140
- t9 = (image || icon) && /*#__PURE__*/jsx("div", {
150
+ t6 = "Card";
151
+ t7 = padding;
152
+ t8 = borderRadius;
153
+ t9 = rest;
154
+ t10 = (image || icon) && /*#__PURE__*/jsx("div", {
141
155
  className: clsx(classes.CardHeader, image && classes.CardHeaderEdgeToEdge),
142
156
  children: image || icon
143
157
  });
144
158
  }
145
- $[6] = borderRadius;
146
- $[7] = children;
147
- $[8] = className;
148
- $[9] = padding;
149
- $[10] = ref;
150
- $[11] = rest;
151
- $[12] = description;
152
- $[13] = heading;
153
- $[14] = menu;
154
- $[15] = metadata;
155
- $[16] = t10;
156
- $[17] = t3;
157
- $[18] = t4;
158
- $[19] = t5;
159
- $[20] = t6;
160
- $[21] = t7;
161
- $[22] = t8;
162
- $[23] = t9;
159
+ $[7] = Component;
160
+ $[8] = as;
161
+ $[9] = borderRadius;
162
+ $[10] = children;
163
+ $[11] = className;
164
+ $[12] = padding;
165
+ $[13] = ref;
166
+ $[14] = rest;
167
+ $[15] = T0;
168
+ $[16] = description;
169
+ $[17] = heading;
170
+ $[18] = menu;
171
+ $[19] = metadata;
172
+ $[20] = t10;
173
+ $[21] = t11;
174
+ $[22] = t4;
175
+ $[23] = t5;
176
+ $[24] = t6;
177
+ $[25] = t7;
178
+ $[26] = t8;
179
+ $[27] = t9;
163
180
  } else {
164
- description = $[12];
165
- heading = $[13];
166
- menu = $[14];
167
- metadata = $[15];
168
- t10 = $[16];
169
- t3 = $[17];
170
- t4 = $[18];
171
- t5 = $[19];
172
- t6 = $[20];
173
- t7 = $[21];
174
- t8 = $[22];
175
- t9 = $[23];
181
+ T0 = $[15];
182
+ description = $[16];
183
+ heading = $[17];
184
+ menu = $[18];
185
+ metadata = $[19];
186
+ t10 = $[20];
187
+ t11 = $[21];
188
+ t4 = $[22];
189
+ t5 = $[23];
190
+ t6 = $[24];
191
+ t7 = $[25];
192
+ t8 = $[26];
193
+ t9 = $[27];
176
194
  }
177
- if (t10 !== Symbol.for("react.early_return_sentinel")) {
178
- return t10;
195
+ if (t11 !== Symbol.for("react.early_return_sentinel")) {
196
+ return t11;
179
197
  }
180
- let t11;
181
- if ($[35] !== description || $[36] !== heading) {
182
- t11 = /*#__PURE__*/jsxs("div", {
198
+ let t12;
199
+ if ($[40] !== description || $[41] !== heading) {
200
+ t12 = /*#__PURE__*/jsxs("div", {
183
201
  className: classes.CardContent,
184
202
  children: [heading, description]
185
203
  });
186
- $[35] = description;
187
- $[36] = heading;
188
- $[37] = t11;
204
+ $[40] = description;
205
+ $[41] = heading;
206
+ $[42] = t12;
189
207
  } else {
190
- t11 = $[37];
208
+ t12 = $[42];
191
209
  }
192
- let t12;
193
- if ($[38] !== metadata) {
194
- t12 = metadata ? /*#__PURE__*/jsx("div", {
210
+ let t13;
211
+ if ($[43] !== metadata) {
212
+ t13 = metadata ? /*#__PURE__*/jsx("div", {
195
213
  className: classes.CardMetadataContainer,
196
214
  children: metadata
197
215
  }) : null;
198
- $[38] = metadata;
199
- $[39] = t12;
216
+ $[43] = metadata;
217
+ $[44] = t13;
200
218
  } else {
201
- t12 = $[39];
219
+ t13 = $[44];
202
220
  }
203
- let t13;
204
- if ($[40] !== t11 || $[41] !== t12) {
205
- t13 = /*#__PURE__*/jsxs("div", {
221
+ let t14;
222
+ if ($[45] !== t12 || $[46] !== t13) {
223
+ t14 = /*#__PURE__*/jsxs("div", {
206
224
  className: classes.CardBody,
207
- children: [t11, t12]
225
+ children: [t12, t13]
208
226
  });
209
- $[40] = t11;
210
- $[41] = t12;
211
- $[42] = t13;
227
+ $[45] = t12;
228
+ $[46] = t13;
229
+ $[47] = t14;
212
230
  } else {
213
- t13 = $[42];
231
+ t14 = $[47];
214
232
  }
215
- let t14;
216
- if ($[43] !== menu) {
217
- t14 = menu ? /*#__PURE__*/jsx("div", {
233
+ let t15;
234
+ if ($[48] !== menu) {
235
+ t15 = menu ? /*#__PURE__*/jsx("div", {
218
236
  className: classes.CardMenu,
219
237
  children: menu
220
238
  }) : null;
221
- $[43] = menu;
222
- $[44] = t14;
239
+ $[48] = menu;
240
+ $[49] = t15;
223
241
  } else {
224
- t14 = $[44];
242
+ t15 = $[49];
225
243
  }
226
- let t15;
227
- if ($[45] !== t13 || $[46] !== t14 || $[47] !== t3 || $[48] !== t4 || $[49] !== t5 || $[50] !== t6 || $[51] !== t7 || $[52] !== t8 || $[53] !== t9) {
228
- t15 = /*#__PURE__*/jsxs("div", {
229
- ref: t3,
230
- className: t4,
231
- "data-component": t5,
232
- "data-padding": t6,
233
- "data-border-radius": t7,
234
- ...t8,
235
- children: [t9, t13, t14]
244
+ let t16;
245
+ if ($[50] !== T0 || $[51] !== t10 || $[52] !== t14 || $[53] !== t15 || $[54] !== t4 || $[55] !== t5 || $[56] !== t6 || $[57] !== t7 || $[58] !== t8 || $[59] !== t9) {
246
+ t16 = /*#__PURE__*/jsxs(T0, {
247
+ ref: t4,
248
+ className: t5,
249
+ "data-component": t6,
250
+ "data-padding": t7,
251
+ "data-border-radius": t8,
252
+ ...t9,
253
+ children: [t10, t14, t15]
236
254
  });
237
- $[45] = t13;
238
- $[46] = t14;
239
- $[47] = t3;
240
- $[48] = t4;
241
- $[49] = t5;
242
- $[50] = t6;
243
- $[51] = t7;
244
- $[52] = t8;
245
- $[53] = t9;
246
- $[54] = t15;
255
+ $[50] = T0;
256
+ $[51] = t10;
257
+ $[52] = t14;
258
+ $[53] = t15;
259
+ $[54] = t4;
260
+ $[55] = t5;
261
+ $[56] = t6;
262
+ $[57] = t7;
263
+ $[58] = t8;
264
+ $[59] = t9;
265
+ $[60] = t16;
247
266
  } else {
248
- t15 = $[54];
267
+ t16 = $[60];
249
268
  }
250
- return t15;
269
+ return t16;
251
270
  });
252
271
  const CardIcon = t0 => {
253
272
  const $ = c(10);
@@ -349,6 +368,20 @@ const CardImage = t0 => {
349
368
  return t3;
350
369
  };
351
370
  CardImage.displayName = 'Card.Image';
371
+
372
+ /**
373
+ * Heading shown at the top of a Card.
374
+ *
375
+ * Accessibility:
376
+ * - Use only on **standalone** Cards (those rendered with `as="section"`).
377
+ * When the Card is inside an `<li>` in a list of cards, the surrounding
378
+ * list already provides grouping; adding a heading produces a confusing
379
+ * experience for screen-reader users, who handle list items and headings
380
+ * as separate navigation modes.
381
+ * - Pair with `aria-labelledby` on the parent `Card` (referencing the
382
+ * heading's `id`) so the section landmark uses the visible heading as
383
+ * its accessible name.
384
+ */
352
385
  const CardHeading = /*#__PURE__*/forwardRef(function CardHeading(t0, ref) {
353
386
  const $ = c(13);
354
387
  let children;
@@ -1,10 +1,5 @@
1
1
  import type { CardProps, CardIconProps, CardImageProps, CardHeadingProps, CardDescriptionProps, CardMenuProps, CardMetadataProps } from './Card';
2
- declare const Card: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "children"> & {
3
- className?: string;
4
- padding?: "none" | "condensed" | "normal";
5
- borderRadius?: "medium" | "large";
6
- children: React.ReactNode;
7
- } & import("react").RefAttributes<HTMLDivElement>> & {
2
+ declare const Card: import("react").ForwardRefExoticComponent<CardProps & import("react").RefAttributes<HTMLDivElement>> & {
8
3
  Icon: {
9
4
  ({ icon: IconComponent, "aria-label": ariaLabel, className }: CardIconProps): import("react").JSX.Element;
10
5
  displayName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Card/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EAClB,MAAM,QAAQ,CAAA;AAEf,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOR,CAAA;AAEF,OAAO,EAAC,IAAI,EAAC,CAAA;AACb,YAAY,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,GAClB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Card/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EAClB,MAAM,QAAQ,CAAA;AAEf,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;CAOR,CAAA;AAEF,OAAO,EAAC,IAAI,EAAC,CAAA;AACb,YAAY,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,GAClB,CAAA"}
@@ -2139,6 +2139,18 @@
2139
2139
  {
2140
2140
  "id": "experimental-components-card-features--with-menu",
2141
2141
  "code": "() => {\n return (\n <Card>\n <Card.Icon icon={RepoIcon} />\n <Card.Heading>primer/react</Card.Heading>\n <Card.Description>\n {\n \"GitHub's design system implemented as React components for building consistent user interfaces.\"\n }\n </Card.Description>\n <Card.Menu>\n <ActionMenu>\n <ActionMenu.Anchor>\n <IconButton\n icon={KebabHorizontalIcon}\n aria-label=\"More options for primer/react\"\n variant=\"invisible\"\n />\n </ActionMenu.Anchor>\n <ActionMenu.Overlay>\n <ActionList>\n <ActionList.Item>Star</ActionList.Item>\n <ActionList.Item>Watch</ActionList.Item>\n <ActionList.Item>Fork</ActionList.Item>\n </ActionList>\n </ActionMenu.Overlay>\n </ActionMenu>\n </Card.Menu>\n </Card>\n )\n}"
2142
+ },
2143
+ {
2144
+ "id": "experimental-components-card-features--standalone-section",
2145
+ "code": "() => (\n <Card as=\"section\" aria-labelledby=\"standalone-card-heading\">\n <Card.Icon icon={RepoIcon} />\n <Card.Heading id=\"standalone-card-heading\">primer/react</Card.Heading>\n <Card.Description>\n {\n \"Standalone cards render as a labelled <section> landmark. The Card.Heading's id is referenced via aria-labelledby so screen readers announce the heading as the section's accessible name.\"\n }\n </Card.Description>\n </Card>\n)"
2146
+ },
2147
+ {
2148
+ "id": "experimental-components-card-features--in-list",
2149
+ "code": "() => (\n <ul className={classes.CardList} aria-label=\"Repositories\">\n <li>\n <Card>\n <Card.Icon icon={RepoIcon} />\n <Card.Description>primer/react</Card.Description>\n <Card.Metadata>\n <StarIcon size={16} />\n 1.2k stars\n </Card.Metadata>\n </Card>\n </li>\n <li>\n <Card>\n <Card.Icon icon={RepoIcon} />\n <Card.Description>primer/css</Card.Description>\n <Card.Metadata>\n <StarIcon size={16} />\n 850 stars\n </Card.Metadata>\n </Card>\n </li>\n <li>\n <Card>\n <Card.Icon icon={RepoIcon} />\n <Card.Description>primer/octicons</Card.Description>\n <Card.Metadata>\n <StarIcon size={16} />\n 2.1k stars\n </Card.Metadata>\n </Card>\n </li>\n </ul>\n)"
2150
+ },
2151
+ {
2152
+ "id": "experimental-components-card-features--interactive-content",
2153
+ "code": "() => {\n const repos = [\n {\n name: 'primer/react',\n },\n {\n name: 'primer/css',\n },\n {\n name: 'primer/octicons',\n },\n ]\n return (\n <ul className={classes.CardList} aria-label=\"Repositories\">\n {repos.map((repo) => (\n <li key={repo.name}>\n <Card>\n <Card.Icon icon={RepoIcon} />\n <Card.Description>{repo.name}</Card.Description>\n <Card.Metadata>\n <Button leadingVisual={StarIcon} size=\"small\">\n Star <VisuallyHidden>{repo.name}</VisuallyHidden>\n </Button>\n <Button leadingVisual={RepoForkedIcon} size=\"small\">\n Fork <VisuallyHidden>{repo.name}</VisuallyHidden>\n </Button>\n </Card.Metadata>\n </Card>\n </li>\n ))}\n </ul>\n )\n}"
2142
2154
  }
2143
2155
  ],
2144
2156
  "props": [
@@ -2164,6 +2176,12 @@
2164
2176
  "type": "'medium' | 'large'",
2165
2177
  "defaultValue": "'large'",
2166
2178
  "description": "Controls the border radius of the Card."
2179
+ },
2180
+ {
2181
+ "name": "as",
2182
+ "type": "'div' | 'section'",
2183
+ "defaultValue": "'div'",
2184
+ "description": "The HTML element to render. Use `'section'` for **standalone** Cards (not inside a list of cards) so screen readers announce the Card as a labelled region; in that case, either `aria-label` or `aria-labelledby` is required. Use the default `'div'` (and omit `Card.Heading`) when the Card is inside an `<li>` of a list of cards — the surrounding list already provides grouping."
2167
2185
  }
2168
2186
  ],
2169
2187
  "subcomponents": [
@@ -2205,7 +2223,7 @@
2205
2223
  "name": "as",
2206
2224
  "type": "'h2' | 'h3' | 'h4' | 'h5' | 'h6'",
2207
2225
  "defaultValue": "'h3'",
2208
- "description": "The heading level to render."
2226
+ "description": "The heading level to render. Use on standalone Cards (with `as=\"section\"` on the parent `Card`) only; do not use `Card.Heading` when the Card is inside an `<li>` of a list of cards."
2209
2227
  }
2210
2228
  ]
2211
2229
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260519124320",
4
+ "version": "0.0.0-20260519202353",
5
5
  "description": "An implementation of GitHub's Primer Design System using React",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",