@joralvmel/cosmos-mcp 0.1.2 → 0.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.
@@ -113,17 +113,15 @@ export function Example() {
113
113
  ```
114
114
  ### `Icon`
115
115
 
116
- Renders a structured SVG icon. Decorative icons are hidden from assistive technology; informative icons require a text label.
116
+ Renders a structured SVG icon. Icons are decorative and hidden from assistive technology unless a nonempty label makes them informative.
117
117
 
118
118
  | Prop | Type | Default | Description |
119
119
  | --- | --- | --- | --- |
120
120
  | `icon` | IconDefinition | Required | Structured icon definition, commonly imported from @joralvmel/cosmos-icons. |
121
121
  | `size` | 'sm' \| 'md' \| 'lg' \| number | `md` | Semantic size (16, 20 or 24) or a positive finite number in pixels / native units. |
122
- | `stroke` | string | `currentColor` | Stroke paint; currentColor inherits on web and resolves to the theme foreground on native. |
123
- | `fill` | string | `none` | Root fill paint. Explicit node fills take precedence. |
124
- | `strokeWidth` | number | `2` | Finite nonnegative stroke width in SVG viewBox units. |
125
- | `label` | string | — | Accessible name required when decorative is false. |
126
- | `decorative` | boolean | `true` | Hides the icon from assistive technology when true. |
122
+ | `variant` | 'outline' \| 'filled' | `outline` | Appearance. outline draws only the stroke; filled also fills the shapes with the icon color (for example a favorite star or heart). Explicit node fills in the definition always win. |
123
+ | `color` | string | `currentColor` | Icon color (stroke, currentColor fills and the filled variant). currentColor inherits the surrounding text color on web and the parent control or theme foreground on native; otherwise a supported color without URLs. |
124
+ | `label` | string | — | Accessible name. A nonempty label makes the icon an informative image; without one the icon is decorative and hidden from assistive technology. |
127
125
 
128
126
  Events: none.
129
127
 
@@ -139,7 +137,7 @@ export function Example() {
139
137
  ```
140
138
  ### `TextField`
141
139
 
142
- Accepts a single line of text with an accessible label, optional help and error text, and native form validation on the web.
140
+ Accepts a single line of text with an accessible label, optional helper and error text, and native form validation on the web.
143
141
 
144
142
  | Prop | Type | Default | Description |
145
143
  | --- | --- | --- | --- |
@@ -149,11 +147,11 @@ Accepts a single line of text with an accessible label, optional help and error
149
147
  | `defaultValue` | string | `` | Initial value for autonomous use. Web form reset restores this value; it does not control subsequent edits. |
150
148
  | `type` | 'text' \| 'email' \| 'password' \| 'tel' \| 'url' \| 'search' | `text` | Single-line input type. Native maps it to supported keyboard, autofill and secure-entry behavior. |
151
149
  | `variant` | 'outlined' \| 'filled' | `outlined` | Visual treatment of the editable control. |
152
- | `size` | 'sm' \| 'md' \| 'lg' \| number | `md` | Semantic size or a positive finite minimum editable-control height in CSS pixels on web and logical units on native. |
150
+ | `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large editable control. |
153
151
  | `placeholder` | string | — | Short input hint; it never replaces the accessible label. |
154
- | `helpText` | string | — | Optional supporting text associated with the editable control. |
155
- | `error` | string | — | Optional externally supplied error text associated with the editable control. |
156
- | `invalid` | boolean | `false` | External invalid state, independent of browser constraints or consumer business validation. |
152
+ | `helperText` | string | — | Optional supporting text associated with the editable control. |
153
+ | `errorText` | string | — | Optional consumer-localized error text associated with the editable control; a nonempty trimmed value also exposes invalid state. |
154
+ | `invalid` | boolean | `false` | External invalid state when the visible error is supplied elsewhere, independent of browser constraints or consumer business validation. |
157
155
  | `required` | boolean | `false` | Exposes required semantics. On web, participates in native HTML constraint validation. |
158
156
  | `disabled` | boolean | `false` | Disables editing and interaction. On web, follows disabled fieldsets and excludes the value from form submission. |
159
157
  | `readOnly` | boolean | `false` | Prevents editing while remaining focusable and form-submittable on web; distinct from disabled. |
@@ -165,7 +163,6 @@ Accepts a single line of text with an accessible label, optional help and error
165
163
  | `inputMode` | 'none' \| 'text' \| 'decimal' \| 'numeric' \| 'tel' \| 'search' \| 'email' \| 'url' | — | Input or keyboard hint (none, text, decimal, numeric, tel, search, email or url); it does not add numeric or multiline field behavior. |
166
164
  | `startIcon` | IconDefinition | — | Optional structured decorative icon before the editable text. |
167
165
  | `endIcon` | IconDefinition | — | Optional structured decorative icon after the editable text. |
168
- | `iconFocusScope` | 'control' \| 'input' | `control` | When configured icon focus colors apply: control includes the input and clear/reveal buttons; input includes only the editable input. Does not change icons without a focus-color override. |
169
166
  | `prefix` | string | — | Optional non-interactive text decoration before the editable text. |
170
167
  | `suffix` | string | — | Optional non-interactive text decoration after the editable text. |
171
168
  | `clearable` | boolean | `false` | Shows a clear action for non-empty editable fields. Supply clearLabel when enabled. |
@@ -238,16 +235,11 @@ Non-modal content anchored to a consumer trigger, with cancelable close requests
238
235
  | `triggerMode` | 'press' \| 'hover' | `press` | Hover adds pointer and keyboard-focus opening on web and React Native Web, while keeping press activation. Android/iOS use press. Does not change panel semantics. |
239
236
  | `closable` | boolean | `false` | Shows a built-in IconButton with an X. Requests a cancelable close with reason close-button. |
240
237
  | `closeLabel` | string | `Close` | Localized accessible name of the close button. Must be non-empty when closable is true. |
241
- | `gap` | number | `8` | Non-negative finite distance from trigger to panel, or to the arrow tip. CSS pixels on web, logical units on native. Viewport/safe-area collision handling takes priority. |
242
238
  | `arrow` | boolean | `false` | Shows a decorative triangular pointer (16 wide, 8 deep), following the actual side, panel background and border. Hidden if it cannot point to the trigger without crossing a corner or viewport edge. |
243
239
  | `closeOnEscape` | boolean | `true` | Requests closure on unhandled Escape on web and React Native Web. Native Android and iOS hardware Escape is not supported. |
244
240
  | `closeOnOutsidePress` | boolean | `true` | Requests closure on an outside press without preventing its interaction or restoring trigger focus. |
245
- | `initialFocus` | boolean | `false` | On committed opening (including initially open), focus the first focusable panel descendant, falling back to the panel without adding semantics. False leaves focus unchanged. Native moves accessible/input focus where supported. |
246
- | `restoreFocus` | boolean | `true` | After committed trigger, Escape, action or Back closure, restore focus only if still inside the panel and the trigger is connected and focusable. Never steal outside focus, restore after outside press, or restore for unsolicited prop closure. |
247
- | `side` | 'top' \| 'right' \| 'bottom' \| 'left' | `bottom` | Requested physical side; actual placement may flip. Recompute for trigger/panel size, viewport/safe-area, scrolling and orientation changes. |
241
+ | `side` | 'top' \| 'right' \| 'bottom' \| 'left' | `bottom` | Requested physical side; actual placement flips to the opposite side when that reduces viewport/safe-area overflow, then shifts within bounds. |
248
242
  | `align` | 'start' \| 'center' \| 'end' | `center` | Cross-axis alignment. On top/bottom, start/end follow inline direction (RTL reverses them); on left/right they mean top/bottom. |
249
- | `flip` | boolean | `true` | Try the opposite side when the requested side overflows the available viewport/safe area; flip only if it reduces main-axis overflow. Ties keep the requested side. Runs before shift. |
250
- | `shift` | boolean | `true` | After flip, translate within available viewport/safe-area bounds to reduce overflow. Constrain oversized panels to that region regardless of collision flags; flags never change requested props. |
251
243
 
252
244
  Events: `onOpenChange` → `PopoverOpenChangeDetail`.
253
245
 
@@ -279,7 +271,7 @@ Selects one or more values from a named vertical collection, with groups, descri
279
271
  | `selectedValues` | ListboxValues | — | Controlled selected values, including an empty array. Activation only proposes changes until the owner updates this prop. Missing collection values are retained, not automatically selected or removed. |
280
272
  | `defaultSelectedValues` | ListboxValues | — | Initial autonomous selected values (empty by default). Later changes do not reset selection. |
281
273
  | `variant` | 'plain' \| 'outlined' | `plain` | Plain composes inside a panel; outlined adds a standalone container boundary. |
282
- | `size` | 'sm' \| 'md' \| 'lg' \| number | `md` | Semantic size or a positive finite minimum option height in CSS pixels/native logical units. Content may grow; native touch targets remain at least 44. |
274
+ | `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large option rows. Content may grow; native touch targets remain at least 44. |
283
275
  | `disabled` | boolean | `false` | Prevents interaction and removes the list from keyboard navigation. |
284
276
  | `readOnly` | boolean | `false` | Allows exploring options without proposing or committing selection changes. |
285
277
  | `locale` | string | — | BCP 47 locale for typeahead. Web inherits the nearest language; native uses the runtime locale when omitted. Invalid locale identifiers are rejected. |
@@ -303,10 +295,322 @@ export function Example() {
303
295
  );
304
296
  }
305
297
  ```
298
+ ### `Checkbox`
299
+
300
+ Selects an independent boolean value with accessible labeling and native form behavior on the web.
301
+
302
+ | Prop | Type | Default | Description |
303
+ | --- | --- | --- | --- |
304
+ | `label` | string | Required | Required accessible name, visible unless labelHidden is true. |
305
+ | `labelHidden` | boolean | `false` | Visually hides the label while keeping it available to assistive technology. |
306
+ | `checked` | boolean | `false` | Controlled checked value when supplied, including false; activation proposes changes without self-committing. |
307
+ | `defaultChecked` | boolean | `false` | Initial autonomous checked value; later changes do not reset it. |
308
+ | `indeterminate` | boolean | `false` | Presentation-only mixed state. Autonomous activation clears it; controlled use leaves it to the owner. |
309
+ | `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large visual box. |
310
+ | `disabled` | boolean | `false` | Prevents user interaction and excludes the value from web form submission. |
311
+ | `required` | boolean | `false` | Exposes required semantics and participates in native web form validation. Native has no automatic validation. |
312
+ | `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere; web form validity remains based on required. |
313
+ | `helperText` | string | — | Optional consumer-localized supporting text associated with the checkbox. |
314
+ | `errorText` | string | — | Optional consumer-localized error description; a nonempty trimmed value also exposes invalid state. |
315
+ | `name` | string | — | Web form field name; React Native has no HTML form association. |
316
+ | `value` | string | `on` | Web form value submitted when checked and enabled; defaults to on. Angular Forms uses checked as its boolean value. |
317
+
318
+ Events: `onCheckedChange` → `CheckboxCheckedChangeDetail`.
319
+
320
+ ```tsx
321
+ import { Checkbox } from '@joralvmel/cosmos-react';
322
+
323
+ export function Example() {
324
+ return (
325
+ <Checkbox
326
+ label="Checkbox"
327
+ onCheckedChange={event => console.log(event.detail)}
328
+ >
329
+ Checkbox
330
+ </Checkbox>
331
+ );
332
+ }
333
+ ```
334
+ ### `Switch`
335
+
336
+ Toggles a binary setting immediately with a stable accessible name and form behavior on the web.
337
+
338
+ | Prop | Type | Default | Description |
339
+ | --- | --- | --- | --- |
340
+ | `label` | string | Required | Required nonempty accessible name; remains stable in both states. |
341
+ | `labelHidden` | boolean | `false` | Visually hides the label while retaining its accessible name. |
342
+ | `checked` | boolean | `false` | Controlled checked value when supplied, including false; activation proposes changes without self-committing. |
343
+ | `defaultChecked` | boolean | `false` | Initial autonomous checked value; later changes do not reset it. |
344
+ | `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large web switch. Native uses system Switch sizing. |
345
+ | `disabled` | boolean | `false` | Prevents user interaction and excludes the value from web form submission. |
346
+ | `invalid` | boolean | `false` | Externally supplied invalid presentation. Does not change checked state or form validity; native uses danger colors without an equivalent system invalid trait. |
347
+ | `helperText` | string | — | Optional consumer-localized supporting text associated with the switch. |
348
+ | `name` | string | — | Web form field name; React Native has no HTML form association. |
349
+ | `value` | string | `on` | Web form value submitted when checked and enabled; defaults to on. Angular Forms uses checked as its boolean value. |
350
+
351
+ Events: `onCheckedChange` → `SwitchCheckedChangeDetail`.
352
+
353
+ ```tsx
354
+ import { Switch } from '@joralvmel/cosmos-react';
355
+
356
+ export function Example() {
357
+ return (
358
+ <Switch
359
+ label="Switch"
360
+ onCheckedChange={event => console.log(event.detail)}
361
+ >
362
+ </Switch>
363
+ );
364
+ }
365
+ ```
366
+ ### `Badge`
367
+
368
+ Displays a noninteractive status or category label, or caller-formatted count, with an optional decorative leading icon.
369
+
370
+ | Prop | Type | Default | Description |
371
+ | --- | --- | --- | --- |
372
+ | `variant` | 'soft' \| 'solid' \| 'outline' | `soft` | Visual treatment of the static label. |
373
+ | `tone` | 'neutral' \| 'info' \| 'success' \| 'warning' \| 'danger' | `neutral` | Semantic color intent of the static label. |
374
+ | `size` | 'sm' \| 'md' \| 'lg' | `md` | Semantic label size. |
375
+ | `startIcon` | IconDefinition | — | Optional structured decorative icon before the label. |
376
+
377
+ Events: none.
378
+
379
+ ```tsx
380
+ import { Badge } from '@joralvmel/cosmos-react';
381
+ import { heart } from '@joralvmel/cosmos-icons/heart';
382
+
383
+ export function Example() {
384
+ return (
385
+ <Badge startIcon={heart}>Badge</Badge>
386
+ );
387
+ }
388
+ ```
389
+ ### `Calendar`
390
+
391
+ Selects one Gregorian date from an inline, localized calendar with keyboard navigation and optional bounds. Month and year can be selected directly.
392
+
393
+ | Prop | Type | Default | Description |
394
+ | --- | --- | --- | --- |
395
+ | `value` | string | — | Controlled selected date in YYYY-MM-DD format; when supplied, selection proposals wait for the owner to update this value. |
396
+ | `defaultValue` | string | — | Initial autonomous selected date in YYYY-MM-DD format; later changes do not reset selection. |
397
+ | `min` | string | — | Earliest selectable date in YYYY-MM-DD format, inclusive. |
398
+ | `max` | string | — | Latest selectable date in YYYY-MM-DD format, inclusive. |
399
+ | `locale` | string | — | BCP 47 locale for month and weekday names, week start, and text direction; defaults to the environment locale. Invalid locale identifiers are rejected. |
400
+ | `disabled` | boolean | `false` | Disables date selection and calendar navigation. |
401
+
402
+ Events: `onChange` → `CalendarChangeDetail`.
403
+
404
+ ```tsx
405
+ import { Calendar } from '@joralvmel/cosmos-react';
406
+
407
+ export function Example() {
408
+ return (
409
+ <Calendar onChange={event => console.log(event.detail)}></Calendar>
410
+ );
411
+ }
412
+ ```
413
+ ### `Textarea`
414
+
415
+ Accepts multiline plain text with an accessible label, optional helper and error text, and native form behavior on the web.
416
+
417
+ | Prop | Type | Default | Description |
418
+ | --- | --- | --- | --- |
419
+ | `label` | string | Required | Accessible name for the editable control. It is rendered above the control unless visually hidden. |
420
+ | `labelHidden` | boolean | `false` | Visually hides the label while keeping it available to assistive technology. |
421
+ | `value` | string | — | Current text. When bound, edits are proposals and the component waits for the owner to supply the accepted value. |
422
+ | `defaultValue` | string | `` | Initial value for autonomous use. Web form reset restores this value; it does not control subsequent edits. |
423
+ | `rows` | number | `4` | Visible line count of the multiline editor. It is independent of the visual size. |
424
+ | `variant` | 'outlined' \| 'filled' | `outlined` | Visual treatment of the editable control. |
425
+ | `size` | 'sm' \| 'md' \| 'lg' | `md` | Visual size of the editable control, independent of rows. |
426
+ | `placeholder` | string | — | Short input hint; it never replaces the accessible label. |
427
+ | `helperText` | string | — | Optional supporting text associated with the editable control. |
428
+ | `errorText` | string | — | Optional consumer-localized error text associated with the editable control; a nonempty trimmed value also exposes invalid state. |
429
+ | `invalid` | boolean | `false` | External invalid state when the visible error is supplied elsewhere, independent of browser constraints or consumer business validation. |
430
+ | `required` | boolean | `false` | Exposes required semantics. On web, participates in native HTML constraint validation. |
431
+ | `disabled` | boolean | `false` | Disables editing and interaction. On web, follows disabled fieldsets and excludes the value from form submission. |
432
+ | `readOnly` | boolean | `false` | Prevents editing while remaining focusable and form-submittable on web; distinct from disabled. |
433
+ | `maxLength` | number | — | Maximum number of characters. Web uses native HTML length constraints and native applies supported input limits. |
434
+ | `name` | string | — | Form field name on web. React Native has no HTML form association or name-based submission. |
435
+
436
+ Events: `onChange` → `TextareaChangeDetail`.
437
+
438
+ ```tsx
439
+ import { Textarea } from '@joralvmel/cosmos-react';
440
+
441
+ export function Example() {
442
+ return (
443
+ <Textarea
444
+ label="Textarea"
445
+ onChange={event => console.log(event.detail)}
446
+ >
447
+ </Textarea>
448
+ );
449
+ }
450
+ ```
451
+ ### `RadioGroup`
452
+
453
+ Selects one option from a labeled collection, with optional selection and native Web form behavior.
454
+
455
+ | Prop | Type | Default | Description |
456
+ | --- | --- | --- | --- |
457
+ | `label` | string | Required | Required visible accessible name for the group. |
458
+ | `options` | RadioGroupOptions | Required | Readonly flat options with unique nonempty values and labels, optional descriptions and disabled states. |
459
+ | `value` | RadioGroupValue | — | Controlled selected value; null means no selection, and a supplied null remains controlled. |
460
+ | `defaultValue` | RadioGroupValue | — | Initial autonomous selection; null by default. |
461
+ | `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large radio indicator. |
462
+ | `orientation` | 'vertical' \| 'horizontal' | `vertical` | Vertical list or wrapping horizontal options. |
463
+ | `disabled` | boolean | `false` | Prevents interaction and excludes the value from Web form submission. |
464
+ | `required` | boolean | `false` | Requires a selection in Web form validation; Native exposes descriptive semantics. |
465
+ | `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere. |
466
+ | `helperText` | string | — | Optional supporting text associated with the group. |
467
+ | `errorText` | string | — | Optional consumer-localized error text; a nonempty trimmed value also exposes invalid state. |
468
+ | `name` | string | — | Web form field name; React Native has no HTML form association. |
469
+
470
+ Events: `onChange` → `RadioGroupChangeDetail`.
471
+
472
+ ```tsx
473
+ import { RadioGroup } from '@joralvmel/cosmos-react';
474
+ const contactMethods = [{"value":"email","label":"Email","description":"Receive updates by email."},{"value":"phone","label":"Phone","description":"Receive updates by text."},{"value":"mail","label":"Mail","disabled":true}] as const;
475
+
476
+ export function Example() {
477
+ return (
478
+ <RadioGroup
479
+ label="RadioGroup"
480
+ options={contactMethods}
481
+ onChange={event => console.log(event.detail)}
482
+ >
483
+ </RadioGroup>
484
+ );
485
+ }
486
+ ```
487
+ ### `Select`
488
+
489
+ Selects one option from an accessible collection, with native Web form behavior.
490
+
491
+ | Prop | Type | Default | Description |
492
+ | --- | --- | --- | --- |
493
+ | `label` | string | Required | Required visible accessible name for the control. |
494
+ | `items` | SelectItems | Required | Readonly flat options with unique nonempty values, nonempty labels, and optional disabled state. |
495
+ | `value` | SelectValue | — | Controlled selected value; null means no selection, and a supplied null remains controlled. |
496
+ | `defaultValue` | SelectValue | — | Initial autonomous selection; null by default. |
497
+ | `placeholder` | string | Required | Consumer-localized text shown when no value is selected. |
498
+ | `variant` | 'outlined' \| 'filled' | `outlined` | Outlined or filled trigger appearance. |
499
+ | `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium, or large control size. |
500
+ | `disabled` | boolean | `false` | Prevents interaction and excludes the value from Web form submission. |
501
+ | `required` | boolean | `false` | Requires a selection in Web form validation; Native exposes descriptive semantics. |
502
+ | `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere. |
503
+ | `helperText` | string | — | Optional supporting text associated with the control. |
504
+ | `errorText` | string | — | Optional consumer-localized error text; a nonempty trimmed value also exposes invalid state. |
505
+ | `name` | string | — | Web form field name; React Native has no HTML form association. |
506
+
507
+ Events: `onChange` → `SelectChangeDetail`.
508
+
509
+ ```tsx
510
+ import { Select } from '@joralvmel/cosmos-react';
511
+ const flat = [{"value":"apple","label":"Apple"},{"value":"cherry","label":"Cherry"},{"value":"lime","label":"Lime","disabled":true}] as const;
512
+ const none = null as const;
513
+
514
+ export function Example() {
515
+ return (
516
+ <Select
517
+ label="Select"
518
+ items={flat}
519
+ defaultValue={none}
520
+ placeholder="Select"
521
+ onChange={event => console.log(event.detail)}
522
+ >
523
+ </Select>
524
+ );
525
+ }
526
+ ```
527
+ ### `Pagination`
528
+
529
+ Navigates a known number of pages using buttons.
530
+
531
+ | Prop | Type | Default | Description |
532
+ | --- | --- | --- | --- |
533
+ | `totalPages` | number | Required | Required nonnegative safe integer page count. |
534
+ | `page` | number | — | Controlled one-based safe integer page; out-of-range values are displayed clamped. |
535
+ | `defaultPage` | number | `1` | Initial one-based page for autonomous state. |
536
+ | `label` | string | Required | Required localized navigation landmark label. |
537
+ | `previousLabel` | string | `Previous page` | Previous button label. |
538
+ | `nextLabel` | string | `Next page` | Next button label. |
539
+ | `firstLabel` | string | `First page` | First button label. |
540
+ | `lastLabel` | string | `Last page` | Last button label. |
541
+ | `pageLabel` | string | `Page {page}` | Page button label template; {page} is replaced with the localized number. |
542
+ | `summaryLabel` | string | `Page {page} of {total}` | Compact summary template with {page} and {total} placeholders. |
543
+ | `locale` | string | — | Locale for formatted page numbers. |
544
+ | `direction` | 'ltr' \| 'rtl' | `ltr` | Layout and directional icon direction. |
545
+ | `presentation` | 'numbered' \| 'compact' | `numbered` | Show up to seven fixed-width numbered positions or a compact summary. |
546
+ | `variant` | 'solid' \| 'soft' \| 'outline' | `solid` | Selected page emphasis. |
547
+ | `size` | 'sm' \| 'md' \| 'lg' | `md` | Control size. |
548
+ | `showFirstLast` | boolean | `false` | Show first and last page controls. |
549
+ | `disabled` | boolean | `false` | Disable all controls. |
550
+
551
+ Events: `onChange` → `PaginationChangeDetail`.
552
+
553
+ ```tsx
554
+ import { Pagination } from '@joralvmel/cosmos-react';
555
+
556
+ export function Example() {
557
+ return (
558
+ <Pagination
559
+ label="Pagination"
560
+ onChange={event => console.log(event.detail)}
561
+ >
562
+ </Pagination>
563
+ );
564
+ }
565
+ ```
566
+ ### `Dialog`
567
+
568
+ Modal content with a title, actions and cancelable close requests.
569
+
570
+ | Prop | Type | Default | Description |
571
+ | --- | --- | --- | --- |
572
+ | `open` | boolean | `false` | Committed visibility; supplying this prop, including false, controls state. |
573
+ | `defaultOpen` | boolean | `false` | Initial autonomous visibility; subsequent changes do not reset state. |
574
+ | `presentation` | 'standard' \| 'fullscreen' | `standard` | Centered standard surface or fullscreen surface. |
575
+ | `size` | 'sm' \| 'md' \| 'lg' | `md` | Maximum standard width: sm 400, md 640, lg 960 pixels or logical points. |
576
+ | `responsiveFullscreen` | boolean | `false` | Use fullscreen when available viewport width is below 640 pixels or logical points. |
577
+ | `closeLabel` | string | `Close` | Non-empty localized accessible name of the built-in close button. |
578
+ | `closeOnEscape` | boolean | `true` | Request closure on unhandled Escape on web. |
579
+ | `closeOnBackdropPress` | boolean | `false` | Request closure when the backdrop itself is pressed. |
580
+ | `initialFocusTarget` | DialogFocusTarget | — | Optional platform focus target used on committed opening; it must be inside the dialog. |
581
+ | `returnFocusTarget` | DialogFocusTarget | — | Optional platform focus target used after committed closure. |
582
+
583
+ Events: `onOpenChange` → `DialogOpenChangeDetail`.
584
+
585
+ ```tsx
586
+ import { useRef } from 'react';
587
+ import { Button, Dialog } from '@joralvmel/cosmos-react';
588
+ import type { CosmDialog } from '@joralvmel/cosmos-elements/dialog';
589
+
590
+ export function Example() {
591
+ const dialog = useRef<CosmDialog>(null);
592
+ return (
593
+ <>
594
+ <Button onPress={() => dialog.current?.requestOpen()}>Open dialog</Button>
595
+ <Dialog
596
+ ref={dialog}
597
+ onOpenChange={event => {
598
+ const detail = event.detail;
599
+ console.log(detail);
600
+ }}
601
+ >
602
+ <h2 slot="title">Review details</h2>
603
+ <p>Dialog</p>
604
+ <Button slot="actions" onPress={() => dialog.current?.requestClose()}>Done</Button>
605
+ </Dialog>
606
+ </>
607
+ );
608
+ }
609
+ ```
306
610
 
307
611
  ## Themes
308
612
 
309
- Built-in themes: `cosmos`, `nebula` (default `cosmos`), each with `light` and `dark` modes; `system` follows the OS.
613
+ Built-in themes: `cosmos`, `nebula`, `terra`, `supernova`, `aurora`, `solstice` (default `cosmos`), each with `light` and `dark` modes; `system` follows the OS.
310
614
 
311
615
  ```html
312
616
  <html data-theme="nebula" data-mode="system">
@@ -32,7 +32,7 @@ Guide: https://joralvmel.github.io/cosmos-ui/guides/tailwind/
32
32
 
33
33
  ## Themes
34
34
 
35
- Built-in themes: `cosmos`, `nebula` (default `cosmos`), each with `light` and `dark` modes; `system` follows the OS.
35
+ Built-in themes: `cosmos`, `nebula`, `terra`, `supernova`, `aurora`, `solstice` (default `cosmos`), each with `light` and `dark` modes; `system` follows the OS.
36
36
 
37
37
  ```html
38
38
  <html data-theme="nebula" data-mode="system">
@@ -12,7 +12,7 @@ npm install @joralvmel/cosmos-tokens
12
12
 
13
13
  ## Themes
14
14
 
15
- Built-in themes: `cosmos`, `nebula` (default `cosmos`), each with `light` and `dark` modes; `system` follows the OS.
15
+ Built-in themes: `cosmos`, `nebula`, `terra`, `supernova`, `aurora`, `solstice` (default `cosmos`), each with `light` and `dark` modes; `system` follows the OS.
16
16
 
17
17
  ```html
18
18
  <html data-theme="nebula" data-mode="system">