Skip to content

Commit cda0c92

Browse files
authored
feat(Dialog): nested attributes & CSS vars (#1841)
1 parent aca192a commit cda0c92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+653
-100
lines changed

.changeset/cuddly-bees-count.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"bits-ui": minor
3+
---
4+
5+
feat(AlertDialog): add nested attributes and CSS vars for better styling of nested dialogs

.changeset/every-clowns-show.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"bits-ui": minor
3+
---
4+
5+
feat(Dialog): add nested attributes and CSS vars for better styling of nested dialogs

docs/content/components/accordion.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: Organizes content into collapsible sections, allowing users to focu
99
let { schemas } = $props()
1010
</script>
1111

12-
<ComponentPreview name="accordion-demo" componentName="Accordion">
12+
<ComponentPreview name="accordion-demo" componentName="Accordion" variant="preview">
1313

1414
{#snippet preview()}
1515
<AccordionDemo />

docs/content/components/alert-dialog.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: A modal window that alerts users with important information and awa
88
let { schemas } = $props()
99
</script>
1010

11-
<ComponentPreview name="alert-dialog-demo" componentName="Alert Dialog">
11+
<ComponentPreview name="alert-dialog-demo" componentName="Alert Dialog" variant="preview">
1212

1313
{#snippet preview()}
1414
<AlertDialogDemo />
@@ -375,7 +375,29 @@ By leveraging these advanced features, you can create highly customized dialog e
375375

376376
## Nested Dialogs
377377

378-
Dialogs can be nested within each other to create more complex layouts. See the [Dialog](/docs/components/dialog) component for more information on nested dialogs.
378+
Alert Dialogs can be nested within each other (or with regular Dialogs) to create more complex layouts. The same nested dialog tracking and styling capabilities are available for Alert Dialogs.
379+
380+
### Styling Nested Alert Dialogs
381+
382+
Alert Dialogs provide the same data attributes and CSS variables as regular Dialogs for tracking nesting:
383+
384+
**Data Attributes:**
385+
386+
- `data-nested-open`: Present on `AlertDialog.Content` and `AlertDialog.Overlay` when nested dialogs are open.
387+
- `data-nested`: Present on `AlertDialog.Content` and `AlertDialog.Overlay` when the dialog is a nested dialog, useful for hiding the overlay of nested dialogs to avoid overlapping with parent dialogs.
388+
389+
**CSS Variables:**
390+
391+
- `--bits-dialog-depth`: The nesting depth (0 for root, 1 for first nested, etc.).
392+
- `--bits-dialog-nested-count`: The number of currently open nested dialogs (updates reactively).
393+
394+
```svelte
395+
<AlertDialog.Content
396+
style="transform: scale(calc(1 - var(--dialog-nested-count) * 0.05));"
397+
>
398+
<!-- Alert dialog content -->
399+
</AlertDialog.Content>
400+
```
379401

380402
## Svelte Transitions
381403

docs/content/components/aspect-ratio.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: Displays content while maintaining a specified aspect ratio, ensuri
88
let { schemas } = $props()
99
</script>
1010

11-
<ComponentPreview name="aspect-ratio-demo" componentName="Aspect Ratio" nonExpandableItems={["App.svelte"]}>
11+
<ComponentPreview name="aspect-ratio-demo" componentName="Aspect Ratio" nonExpandableItems={["App.svelte"]} variant="preview">
1212

1313
{#snippet preview()}
1414
<AspectRatioDemo />

docs/content/components/avatar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: Represents a user or entity with a recognizable image or placeholde
88
let { schemas } = $props()
99
</script>
1010

11-
<ComponentPreview name="avatar-demo" componentName="Avatar">
11+
<ComponentPreview name="avatar-demo" componentName="Avatar" variant="preview">
1212

1313
{#snippet preview()}
1414
<AvatarDemo />

docs/content/components/button.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: A component that if passed a `href` prop will render an anchor elem
88
let { schemas } = $props()
99
</script>
1010

11-
<ComponentPreview name="button-demo" componentName="Button" nonExpandableItems={["App.svelte"]}>
11+
<ComponentPreview name="button-demo" componentName="Button" nonExpandableItems={["App.svelte"]} variant="preview">
1212

1313
{#snippet preview()}
1414
<ButtonDemo />

docs/content/components/calendar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: Displays dates and days of the week, facilitating date-related inte
88
let { schemas } = $props()
99
</script>
1010

11-
<ComponentPreview name="calendar-demo" componentName="Calendar">
11+
<ComponentPreview name="calendar-demo" componentName="Calendar" variant="preview">
1212

1313
{#snippet preview()}
1414
<CalendarDemo />

docs/content/components/checkbox.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: Allow users to switch between checked, unchecked, and indeterminate
88
let { schemas } = $props()
99
</script>
1010

11-
<ComponentPreview name="checkbox-demo" componentName="Checkbox">
11+
<ComponentPreview name="checkbox-demo" componentName="Checkbox" variant="preview">
1212

1313
{#snippet preview()}
1414
<CheckboxDemo />

docs/content/components/collapsible.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: Conceals or reveals content sections, enhancing space utilization a
88
let { schemas } = $props()
99
</script>
1010

11-
<ComponentPreview name="collapsible-demo" componentName="Collapsible">
11+
<ComponentPreview name="collapsible-demo" componentName="Collapsible" variant="preview">
1212

1313
{#snippet preview()}
1414
<CollapsibleDemo />

0 commit comments

Comments
 (0)