maz-ui 5.0.0 → 5.1.0-beta.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.
- package/dist/assets/{MazDropzone.DJ8au25t.css → MazDropzone.BW2grpTi.css} +1 -1
- package/dist/chunks/{MazDrawer.DANxKYxJ.js → MazDrawer.CC8zomfx.js} +2 -2
- package/dist/chunks/{MazDropzone.POH3pmfi.js → MazDropzone.Dez5j0WP.js} +2 -2
- package/dist/components/MazDrawer.js +1 -1
- package/dist/components/MazDropzone.js +1 -1
- package/dist/components/MazDropzone.vue.d.ts +2 -2
- package/dist/components/MazInputPrice.vue.d.ts +1 -1
- package/dist/components/index.js +2 -2
- package/docs/README.md +207 -0
- package/docs/agents/agents-md.md +52 -0
- package/docs/agents/claude-rule.md +52 -0
- package/docs/components/maz-accordion.md +76 -0
- package/docs/components/maz-alert.md +241 -0
- package/docs/components/maz-animated-counter.md +87 -0
- package/docs/components/maz-animated-element.md +46 -0
- package/docs/components/maz-animated-text.md +53 -0
- package/docs/components/maz-avatar.md +193 -0
- package/docs/components/maz-backdrop.md +178 -0
- package/docs/components/maz-badge.md +167 -0
- package/docs/components/maz-bottom-sheet.md +257 -0
- package/docs/components/maz-btn-group.md +316 -0
- package/docs/components/maz-btn.md +423 -0
- package/docs/components/maz-card-spotlight.md +84 -0
- package/docs/components/maz-card.md +321 -0
- package/docs/components/maz-carousel.md +153 -0
- package/docs/components/maz-chart.md +206 -0
- package/docs/components/maz-checkbox.md +138 -0
- package/docs/components/maz-checklist.md +251 -0
- package/docs/components/maz-circular-progress-bar.md +109 -0
- package/docs/components/maz-code-highlight.md +155 -0
- package/docs/components/maz-container.md +241 -0
- package/docs/components/maz-date-picker.md +791 -0
- package/docs/components/maz-dialog-confirm.md +215 -0
- package/docs/components/maz-dialog.md +143 -0
- package/docs/components/maz-drawer.md +106 -0
- package/docs/components/maz-dropdown.md +419 -0
- package/docs/components/maz-dropzone.md +387 -0
- package/docs/components/maz-expand-animation.md +82 -0
- package/docs/components/maz-fullscreen-loader.md +58 -0
- package/docs/components/maz-gallery.md +79 -0
- package/docs/components/maz-icon.md +203 -0
- package/docs/components/maz-input-code.md +73 -0
- package/docs/components/maz-input-number.md +79 -0
- package/docs/components/maz-input-phone-number.md +536 -0
- package/docs/components/maz-input-price.md +68 -0
- package/docs/components/maz-input-tags.md +112 -0
- package/docs/components/maz-input.md +334 -0
- package/docs/components/maz-lazy-img.md +113 -0
- package/docs/components/maz-link.md +146 -0
- package/docs/components/maz-loading-bar.md +38 -0
- package/docs/components/maz-markdown-editor.md +320 -0
- package/docs/components/maz-pagination.md +82 -0
- package/docs/components/maz-popover.md +794 -0
- package/docs/components/maz-pull-to-refresh.md +222 -0
- package/docs/components/maz-radio-buttons.md +313 -0
- package/docs/components/maz-radio.md +119 -0
- package/docs/components/maz-read-more.md +209 -0
- package/docs/components/maz-reading-progress-bar.md +96 -0
- package/docs/components/maz-select-country.md +513 -0
- package/docs/components/maz-select.md +318 -0
- package/docs/components/maz-sidebar-content.md +25 -0
- package/docs/components/maz-sidebar-footer.md +25 -0
- package/docs/components/maz-sidebar-group.md +27 -0
- package/docs/components/maz-sidebar-header.md +25 -0
- package/docs/components/maz-sidebar-menu-button.md +41 -0
- package/docs/components/maz-sidebar-menu-item.md +25 -0
- package/docs/components/maz-sidebar-menu-sub.md +32 -0
- package/docs/components/maz-sidebar-menu.md +25 -0
- package/docs/components/maz-sidebar-separator.md +21 -0
- package/docs/components/maz-sidebar-trigger.md +25 -0
- package/docs/components/maz-sidebar.md +507 -0
- package/docs/components/maz-skeleton.md +226 -0
- package/docs/components/maz-slider.md +165 -0
- package/docs/components/maz-spinner.md +84 -0
- package/docs/components/maz-stepper.md +301 -0
- package/docs/components/maz-switch.md +86 -0
- package/docs/components/maz-table-cell.md +27 -0
- package/docs/components/maz-table-row.md +28 -0
- package/docs/components/maz-table-title.md +27 -0
- package/docs/components/maz-table-virtualizer.md +31 -0
- package/docs/components/maz-table.md +426 -0
- package/docs/components/maz-tabs-bar.md +43 -0
- package/docs/components/maz-tabs-content-item.md +27 -0
- package/docs/components/maz-tabs-content.md +27 -0
- package/docs/components/maz-tabs.md +308 -0
- package/docs/components/maz-textarea.md +255 -0
- package/docs/components/maz-ticker.md +427 -0
- package/docs/components/maz-timeline.md +304 -0
- package/docs/components/maz-ui-provider.md +26 -0
- package/docs/components/maz-window-mockup.md +182 -0
- package/docs/composables/use-aos.md +41 -0
- package/docs/composables/use-breakpoints.md +42 -0
- package/docs/composables/use-dialog.md +58 -0
- package/docs/composables/use-display-names.md +130 -0
- package/docs/composables/use-drag.md +185 -0
- package/docs/composables/use-form-validator.md +1123 -0
- package/docs/composables/use-idle-timeout.md +172 -0
- package/docs/composables/use-pull-to-refresh.md +86 -0
- package/docs/composables/use-reading-time.md +132 -0
- package/docs/composables/use-string-matching.md +41 -0
- package/docs/composables/use-swipe.md +171 -0
- package/docs/composables/use-timer.md +104 -0
- package/docs/composables/use-toast.md +50 -0
- package/docs/composables/use-user-visibility.md +127 -0
- package/docs/composables/use-wait.md +50 -0
- package/docs/composables/use-window-size.md +25 -0
- package/docs/directives/click-outside.md +182 -0
- package/docs/directives/fullscreen-img.md +83 -0
- package/docs/directives/lazy-img.md +182 -0
- package/docs/directives/tooltip.md +298 -0
- package/docs/directives/zoom-img.md +100 -0
- package/docs/ecosystem/eslint-config.md +289 -0
- package/docs/ecosystem/icons/icon-set.md +25 -0
- package/docs/ecosystem/icons/index.md +584 -0
- package/docs/ecosystem/mcp.md +165 -0
- package/docs/ecosystem/node/exec-promise.md +93 -0
- package/docs/ecosystem/node/index.md +53 -0
- package/docs/ecosystem/node/logger.md +152 -0
- package/docs/ecosystem/node/print-banner.md +101 -0
- package/docs/ecosystem/node/setup-agents.md +102 -0
- package/docs/ecosystem/nuxt.md +551 -0
- package/docs/ecosystem/stylelint-config.md +310 -0
- package/docs/ecosystem/themes.md +966 -0
- package/docs/ecosystem/translations.md +1173 -0
- package/docs/ecosystem/utils/camel-case.md +37 -0
- package/docs/ecosystem/utils/capitalize.md +37 -0
- package/docs/ecosystem/utils/check-availability.md +85 -0
- package/docs/ecosystem/utils/cookie.md +86 -0
- package/docs/ecosystem/utils/country-code-to-unicode-flag.md +128 -0
- package/docs/ecosystem/utils/currency.md +53 -0
- package/docs/ecosystem/utils/date.md +53 -0
- package/docs/ecosystem/utils/debounce-callback.md +44 -0
- package/docs/ecosystem/utils/debounce-id.md +75 -0
- package/docs/ecosystem/utils/debounce.md +71 -0
- package/docs/ecosystem/utils/fetch-locale-ip.md +39 -0
- package/docs/ecosystem/utils/format-json.md +39 -0
- package/docs/ecosystem/utils/format-phone-number.md +43 -0
- package/docs/ecosystem/utils/get-browser-locale.md +35 -0
- package/docs/ecosystem/utils/get-country-flag-url.md +67 -0
- package/docs/ecosystem/utils/get-error-message.md +45 -0
- package/docs/ecosystem/utils/idle-timeout.md +96 -0
- package/docs/ecosystem/utils/index.md +57 -0
- package/docs/ecosystem/utils/is-client.md +38 -0
- package/docs/ecosystem/utils/is-equal.md +44 -0
- package/docs/ecosystem/utils/is-ios.md +43 -0
- package/docs/ecosystem/utils/is-server.md +37 -0
- package/docs/ecosystem/utils/is-standalone-mode.md +49 -0
- package/docs/ecosystem/utils/kebab-case.md +42 -0
- package/docs/ecosystem/utils/normalize-string.md +83 -0
- package/docs/ecosystem/utils/number.md +51 -0
- package/docs/ecosystem/utils/pascal-case.md +41 -0
- package/docs/ecosystem/utils/prevent-ios-input-zoom.md +72 -0
- package/docs/ecosystem/utils/script-loader.md +85 -0
- package/docs/ecosystem/utils/sleep.md +65 -0
- package/docs/ecosystem/utils/snake-case.md +42 -0
- package/docs/ecosystem/utils/swipe-handler.md +97 -0
- package/docs/ecosystem/utils/textarea-autogrow.md +47 -0
- package/docs/ecosystem/utils/throttle-id.md +54 -0
- package/docs/ecosystem/utils/throttle.md +63 -0
- package/docs/ecosystem/utils/truthy-filter.md +37 -0
- package/docs/ecosystem/utils/types/deep-key-of.md +54 -0
- package/docs/ecosystem/utils/types/deep-partial.md +48 -0
- package/docs/ecosystem/utils/types/deep-required.md +45 -0
- package/docs/ecosystem/utils/types/flatten-object-keys.md +50 -0
- package/docs/ecosystem/utils/types/generic-instance-type.md +48 -0
- package/docs/ecosystem/utils/types/infer-maybe-ref.md +41 -0
- package/docs/ecosystem/utils/upper-first.md +38 -0
- package/docs/ecosystem/utils/user-visibility.md +75 -0
- package/docs/guide/ai-agents.md +237 -0
- package/docs/guide/browser-support.md +88 -0
- package/docs/guide/getting-started.md +191 -0
- package/docs/guide/global-defaults.md +103 -0
- package/docs/guide/maz-ui-provider.md +231 -0
- package/docs/guide/migration-v5.md +871 -0
- package/docs/guide/resolvers.md +650 -0
- package/docs/guide/tailwind.md +483 -0
- package/docs/guide/vue.md +286 -0
- package/docs/manifest.json +1 -0
- package/docs/plugins/aos.md +312 -0
- package/docs/plugins/dialog.md +269 -0
- package/docs/plugins/toast.md +221 -0
- package/docs/plugins/wait.md +78 -0
- package/docs/reference/icons.md +46 -0
- package/docs/reference/tailwind-tokens.md +191 -0
- package/docs/rules.md +57 -0
- package/package.json +31 -4
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "MazBackdrop"
|
|
3
|
+
description: "MazBackdrop is a flexible backdrop component that provides a foundation for modals, drawers, bottom sheets and any overlay content. It handles focus management, keyboard navigation, and animations automatically."
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/components/maz-backdrop"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# MazBackdrop
|
|
9
|
+
|
|
10
|
+
> MazBackdrop is a flexible backdrop component that provides a foundation for modals, drawers, bottom sheets and any overlay content. It handles focus management, keyboard navigation, and animations automatically.
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import MazBackdrop from 'maz-ui/components/MazBackdrop'`
|
|
14
|
+
- Nuxt: auto-imported by `@maz-ui/nuxt`, no import needed in a Nuxt app
|
|
15
|
+
- Web: https://maz-ui.com/components/maz-backdrop
|
|
16
|
+
|
|
17
|
+
> Before use it, you should install the MazUi plugin in your project, follow instructions in [Getting Started](../guide/getting-started.md)
|
|
18
|
+
|
|
19
|
+
**Tip:**
|
|
20
|
+
|
|
21
|
+
This component uses `<Teleport to="body">` and is the foundation for [MazDialog](./maz-dialog.md), [MazDrawer](./maz-drawer.md), and [MazBottomSheet](./maz-bottom-sheet.md)
|
|
22
|
+
|
|
23
|
+
## Basic usage
|
|
24
|
+
|
|
25
|
+
MazBackdrop creates a semi-transparent overlay that covers the entire screen. Think of it like a dark blanket that appears behind your content to make it stand out.
|
|
26
|
+
|
|
27
|
+
```vue
|
|
28
|
+
<script setup>
|
|
29
|
+
import MazBackdrop from 'maz-ui/components/MazBackdrop'
|
|
30
|
+
import { ref } from 'vue'
|
|
31
|
+
|
|
32
|
+
const basicOpen = ref(false)
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<MazBtn @click="basicOpen = true">
|
|
37
|
+
Open Backdrop
|
|
38
|
+
</MazBtn>
|
|
39
|
+
|
|
40
|
+
<MazBackdrop v-model="basicOpen" justify="center" align="center">
|
|
41
|
+
<div class="my-content">
|
|
42
|
+
<h3>Hello! I'm on top of the backdrop</h3>
|
|
43
|
+
<p>Click outside or press Escape to close</p>
|
|
44
|
+
<MazBtn @click="basicOpen = false">Close</MazBtn>
|
|
45
|
+
</div>
|
|
46
|
+
</MazBackdrop>
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<style lang="css" scoped>
|
|
50
|
+
.demo-content {
|
|
51
|
+
background: var(--maz-surface);
|
|
52
|
+
padding: 2rem;
|
|
53
|
+
border-radius: var(--maz-rounded-md);
|
|
54
|
+
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
|
|
55
|
+
max-width: 400px;
|
|
56
|
+
text-align: center;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.demo-content h3 {
|
|
60
|
+
margin-top: 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.demo-content p {
|
|
64
|
+
margin-bottom: 1.5rem;
|
|
65
|
+
color: var(--maz-muted);
|
|
66
|
+
}
|
|
67
|
+
</style>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Persistent backdrop
|
|
71
|
+
|
|
72
|
+
A persistent backdrop cannot be closed by clicking outside or pressing Escape. Perfect for important confirmations!
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<MazBackdrop v-model="persistentOpen" persistent align="center" justify="center">
|
|
76
|
+
<div class="my-content">
|
|
77
|
+
<h3>I'm persistent!</h3>
|
|
78
|
+
<p>You can only close me by clicking the button below</p>
|
|
79
|
+
<MazBtn @click="persistentOpen = false" color="destructive">
|
|
80
|
+
Force Close
|
|
81
|
+
</MazBtn>
|
|
82
|
+
</div>
|
|
83
|
+
</MazBackdrop>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Content positioning
|
|
87
|
+
|
|
88
|
+
You can control where your content appears using `justify` and `align` props. It's like choosing where to place a sticker on your screen!
|
|
89
|
+
|
|
90
|
+
```html
|
|
91
|
+
<!-- Top Left -->
|
|
92
|
+
<MazBackdrop v-model="topLeftOpen" justify="start" align="start" content-padding>
|
|
93
|
+
<div class="my-content">
|
|
94
|
+
<h3>I'm at the top left!</h3>
|
|
95
|
+
<MazBtn @click="topLeftOpen = false">Close</MazBtn>
|
|
96
|
+
</div>
|
|
97
|
+
</MazBackdrop>
|
|
98
|
+
|
|
99
|
+
<!-- Center -->
|
|
100
|
+
<MazBackdrop v-model="centerOpen" justify="center" align="center" content-padding>
|
|
101
|
+
<div class="my-content">
|
|
102
|
+
<h3>I'm perfectly centered!</h3>
|
|
103
|
+
<MazBtn @click="centerOpen = false">Close</MazBtn>
|
|
104
|
+
</div>
|
|
105
|
+
</MazBackdrop>
|
|
106
|
+
|
|
107
|
+
<!-- Bottom Right -->
|
|
108
|
+
<MazBackdrop v-model="bottomRightOpen" justify="end" align="end" content-padding>
|
|
109
|
+
<div class="my-content">
|
|
110
|
+
<h3>I'm at the bottom right!</h3>
|
|
111
|
+
<MazBtn @click="bottomRightOpen = false">Close</MazBtn>
|
|
112
|
+
</div>
|
|
113
|
+
</MazBackdrop>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Custom animations
|
|
117
|
+
|
|
118
|
+
MazBackdrop comes with built-in animations, but you can customize them with the `transition-name` prop.
|
|
119
|
+
|
|
120
|
+
```html
|
|
121
|
+
<MazBackdrop v-model="animatedOpen" transition-name="modal-anim">
|
|
122
|
+
<div class="my-content">
|
|
123
|
+
<h3>I slide and scale in!</h3>
|
|
124
|
+
<p>This uses the same animation as MazDialog</p>
|
|
125
|
+
<MazBtn @click="animatedOpen = false">Close</MazBtn>
|
|
126
|
+
</div>
|
|
127
|
+
</MazBackdrop>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Accessibility features
|
|
131
|
+
|
|
132
|
+
MazBackdrop automatically handles:
|
|
133
|
+
- **Focus trap**: Tab navigation stays within your content
|
|
134
|
+
- **Keyboard support**: Escape key to close (unless persistent)
|
|
135
|
+
- **Screen readers**: Proper ARIA attributes for accessibility
|
|
136
|
+
- **Scroll lock**: Prevents background scrolling when open
|
|
137
|
+
|
|
138
|
+
These features work automatically - you don't need to do anything extra!
|
|
139
|
+
|
|
140
|
+
## MazBackdrop API
|
|
141
|
+
|
|
142
|
+
`import MazBackdrop from 'maz-ui/components/MazBackdrop'`
|
|
143
|
+
|
|
144
|
+
### Props
|
|
145
|
+
|
|
146
|
+
- `model-value` (`boolean`, default: `false`, `v-model`): Modal's model value.
|
|
147
|
+
- `teleport-selector` (`string`, default: `"body"`): Teleport selector.
|
|
148
|
+
- `before-close` (`(() => void | Promise<void>)`): Function called before modal is close.
|
|
149
|
+
- `persistent` (`boolean`, default: `false`): Persistent dialog (not closable by clicking outside and remove close button).
|
|
150
|
+
- `close-on-escape` (`boolean`, default: `true`): Prevent close on escape key.
|
|
151
|
+
- `transition-name` (`string`, default: `"backdrop-anim"`): Transition name.
|
|
152
|
+
- `backdrop-class` (`ClassValue`): Backdrop class.
|
|
153
|
+
- `backdrop-content-class` (`ClassValue`): Backdrop content class.
|
|
154
|
+
- `content-padding` (`boolean`, default: `false`): Add padding to the content.
|
|
155
|
+
- `justify` (`"none" | "center" | "end" | "start" | "space-between" | "space-around"`, default: `"none"`): Justify content.
|
|
156
|
+
- `align` (`"none" | "center" | "end" | "start"`, default: `"none"`): Align content.
|
|
157
|
+
- `variant` (`"bottom-sheet" | "dialog" | "drawer"`): Variant.
|
|
158
|
+
- `aria-labelledby` (`string`): ID for aria-labelledby.
|
|
159
|
+
- `aria-describedby` (`string`): ID for aria-describedby.
|
|
160
|
+
|
|
161
|
+
### Events
|
|
162
|
+
|
|
163
|
+
- `@update:model-value` (payload: `value: boolean`): Emitted when modal is open or close
|
|
164
|
+
- `@open` (payload: `value?: void | undefined`): Emitted when modal is open
|
|
165
|
+
- `@close` (payload: `value?: void | undefined`): Emitted when modal is close
|
|
166
|
+
- `@before-close` (payload: `value?: void | undefined`): Emitted before modal is close
|
|
167
|
+
|
|
168
|
+
### Slots
|
|
169
|
+
|
|
170
|
+
- `#default`: Place your content here Bindings: `close: () => void` (close function).
|
|
171
|
+
|
|
172
|
+
### Exposed (template ref)
|
|
173
|
+
|
|
174
|
+
- `onBackdropAnimationLeave`: Animation leave event
|
|
175
|
+
- `close`: Close the backdrop
|
|
176
|
+
- `present`: The present state of the backdrop
|
|
177
|
+
- `toggleModal`: Toggle the backdrop
|
|
178
|
+
- `onKeyPress`: Key press event
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "MazBadge"
|
|
3
|
+
description: "MazBadge is a standalone component to show short text in colored container"
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/components/maz-badge"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# MazBadge
|
|
9
|
+
|
|
10
|
+
> MazBadge is a standalone component to show short text in colored container
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import MazBadge from 'maz-ui/components/MazBadge'`
|
|
14
|
+
- Nuxt: auto-imported by `@maz-ui/nuxt`, no import needed in a Nuxt app
|
|
15
|
+
- Web: https://maz-ui.com/components/maz-badge
|
|
16
|
+
|
|
17
|
+
> Before use it, you should install the MazUi plugin in your project, follow instructions in [Getting Started](../guide/getting-started.md)
|
|
18
|
+
|
|
19
|
+
## Basic usage
|
|
20
|
+
|
|
21
|
+
```vue
|
|
22
|
+
<script lang="ts" setup>
|
|
23
|
+
import MazBadge from 'maz-ui/components/MazBadge'
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<MazBadge>
|
|
28
|
+
Badge
|
|
29
|
+
</MazBadge>
|
|
30
|
+
</template>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Options
|
|
34
|
+
|
|
35
|
+
> See all options props here
|
|
36
|
+
|
|
37
|
+
### Colors
|
|
38
|
+
|
|
39
|
+
```vue
|
|
40
|
+
<script lang="ts" setup>
|
|
41
|
+
import MazBadge from 'maz-ui/components/MazBadge'
|
|
42
|
+
|
|
43
|
+
const colors = [
|
|
44
|
+
'primary',
|
|
45
|
+
'secondary',
|
|
46
|
+
'info',
|
|
47
|
+
'success',
|
|
48
|
+
'warning',
|
|
49
|
+
'destructive',
|
|
50
|
+
'contrast',
|
|
51
|
+
'accent',
|
|
52
|
+
'surface',
|
|
53
|
+
'transparent',
|
|
54
|
+
]
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<MazBadge v-for="color in color" :key="color" :color="color">
|
|
59
|
+
{{ color }}
|
|
60
|
+
</MazBadge>
|
|
61
|
+
</template>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Outlined
|
|
65
|
+
|
|
66
|
+
```vue
|
|
67
|
+
<script lang="ts" setup>
|
|
68
|
+
import MazBadge from 'maz-ui/components/MazBadge'
|
|
69
|
+
|
|
70
|
+
const colors = [
|
|
71
|
+
'primary',
|
|
72
|
+
'secondary',
|
|
73
|
+
'info',
|
|
74
|
+
'success',
|
|
75
|
+
'warning',
|
|
76
|
+
'destructive',
|
|
77
|
+
'contrast',
|
|
78
|
+
'accent',
|
|
79
|
+
'surface',
|
|
80
|
+
'transparent',
|
|
81
|
+
]
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<template>
|
|
85
|
+
<MazBadge v-for="color in color" :key="color" :color="color" outlined>
|
|
86
|
+
{{ color }}
|
|
87
|
+
</MazBadge>
|
|
88
|
+
</template>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Pastel
|
|
92
|
+
|
|
93
|
+
```vue
|
|
94
|
+
<script lang="ts" setup>
|
|
95
|
+
import MazBadge from 'maz-ui/components/MazBadge'
|
|
96
|
+
|
|
97
|
+
const colors = [
|
|
98
|
+
'primary',
|
|
99
|
+
'secondary',
|
|
100
|
+
'info',
|
|
101
|
+
'success',
|
|
102
|
+
'warning',
|
|
103
|
+
'destructive',
|
|
104
|
+
'contrast',
|
|
105
|
+
'accent',
|
|
106
|
+
'surface',
|
|
107
|
+
'transparent',
|
|
108
|
+
]
|
|
109
|
+
</script>
|
|
110
|
+
|
|
111
|
+
<template>
|
|
112
|
+
<MazBadge v-for="color in color" :key="color" :color="color" pastel>
|
|
113
|
+
{{ color }}
|
|
114
|
+
</MazBadge>
|
|
115
|
+
</template>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Size
|
|
119
|
+
|
|
120
|
+
The `size` prop accepts one of the standardized `MazSize` values (`'mini' | 'xs' | 'sm' | 'md' | 'lg' | 'xl'`). The default is `'md'`. Padding, line-height and dimensions all scale relative to the chosen font-size, so a single keyword controls the whole badge footprint.
|
|
121
|
+
|
|
122
|
+
```vue
|
|
123
|
+
<script lang="ts" setup>
|
|
124
|
+
import MazBadge from 'maz-ui/components/MazBadge'
|
|
125
|
+
|
|
126
|
+
const sizes = ['mini', 'xs', 'sm', 'md', 'lg', 'xl']
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<template>
|
|
130
|
+
<MazBadge v-for="size in sizes" :key="size" :size="size">
|
|
131
|
+
{{ size }}
|
|
132
|
+
</MazBadge>
|
|
133
|
+
</template>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Rounded sizes
|
|
137
|
+
|
|
138
|
+
```vue
|
|
139
|
+
<script lang="ts" setup>
|
|
140
|
+
import MazBadge from 'maz-ui/components/MazBadge'
|
|
141
|
+
|
|
142
|
+
const roundedSize = ['none', 'sm', 'md', 'lg', 'xl', 'full']
|
|
143
|
+
</script>
|
|
144
|
+
|
|
145
|
+
<template>
|
|
146
|
+
<MazBadge v-for="size in roundedSize" :key="size" :rounded-size="size">
|
|
147
|
+
{{ size }}
|
|
148
|
+
</MazBadge>
|
|
149
|
+
</template>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## MazBadge API
|
|
153
|
+
|
|
154
|
+
`import MazBadge from 'maz-ui/components/MazBadge'`
|
|
155
|
+
|
|
156
|
+
### Props
|
|
157
|
+
|
|
158
|
+
- `color` (`MazBadgeColor`, default: `"primary"`): Color of the badge. Values: `'primary'`, `'secondary'`, `'accent'`, `'info'`, `'success'`, `'warning'`, `'destructive'`, `'contrast'`, `'surface'` (non exhaustive).
|
|
159
|
+
- `size` (`"xs" | "sm" | "md" | "lg" | "xl" | "mini"`, default: `md`): Size of the badge - drives font-size; padding, line-height and dimensions scale relative to it via `em` units.
|
|
160
|
+
- `nowrap` (`boolean`, default: `true`): Will not wrap the text.
|
|
161
|
+
- `outlined` (`boolean`, default: `false`): Will add a border to the badge.
|
|
162
|
+
- `pastel` (`boolean`, default: `false`): Will add a pastel style to the badge.
|
|
163
|
+
- `rounded-size` (`MazBadgeRoundedSize`, default: `md`): Size radius of the component's border. Values: `'none'`, `'sm'`, `'md'`, `'lg'`, `'xl'`, `'full'` (non exhaustive).
|
|
164
|
+
|
|
165
|
+
### Slots
|
|
166
|
+
|
|
167
|
+
- `#default`: Badge content
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "MazBottomSheet"
|
|
3
|
+
description: "MazBottomSheet is a standalone component like a simple dialog but anchored at the bottom of the screen. Full-width on mobile and constrained/centered on desktop, with a header (icon, title, close button), a footer and many replaceable slots. Useful for mobile UX."
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/components/maz-bottom-sheet"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# MazBottomSheet
|
|
9
|
+
|
|
10
|
+
> MazBottomSheet is a standalone component like a simple dialog but anchored at the bottom of the screen. Full-width on mobile and constrained/centered on desktop, with a header (icon, title, close button), a footer and many replaceable slots. Useful for mobile UX.
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import MazBottomSheet from 'maz-ui/components/MazBottomSheet'`
|
|
14
|
+
- Nuxt: auto-imported by `@maz-ui/nuxt`, no import needed in a Nuxt app
|
|
15
|
+
- Web: https://maz-ui.com/components/maz-bottom-sheet
|
|
16
|
+
|
|
17
|
+
> Before use it, you should install the MazUi plugin in your project, follow instructions in [Getting Started](../guide/getting-started.md)
|
|
18
|
+
|
|
19
|
+
**Tip:**
|
|
20
|
+
|
|
21
|
+
This component uses the `<Teleport to="body">` with [MazBackdrop](./maz-backdrop.md), so you can implement this component anywhere and it inherits all its props (`persistent`, `closeOnEscape`, etc.)
|
|
22
|
+
|
|
23
|
+
## Basic usage
|
|
24
|
+
|
|
25
|
+
The sheet has a header (with the `title` and a close button) and an optional `footer` slot. It opens full-width on mobile and is constrained/centered on desktop (see Max width).
|
|
26
|
+
|
|
27
|
+
```vue
|
|
28
|
+
<script setup>
|
|
29
|
+
import MazBottomSheet from 'maz-ui/components/MazBottomSheet'
|
|
30
|
+
import { ref } from 'vue'
|
|
31
|
+
|
|
32
|
+
const basicOpened = ref(false)
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<MazBtn @click="basicOpened = true">
|
|
37
|
+
Open Bottom Sheet
|
|
38
|
+
</MazBtn>
|
|
39
|
+
|
|
40
|
+
<MazBottomSheet v-model="basicOpened" title="Bottom Sheet Title">
|
|
41
|
+
<p>Your content goes here.</p>
|
|
42
|
+
|
|
43
|
+
<template #footer="{ close }">
|
|
44
|
+
<MazBtn color="transparent" @click="close">
|
|
45
|
+
Cancel
|
|
46
|
+
</MazBtn>
|
|
47
|
+
<MazBtn @click="close">
|
|
48
|
+
Confirm
|
|
49
|
+
</MazBtn>
|
|
50
|
+
</template>
|
|
51
|
+
</MazBottomSheet>
|
|
52
|
+
</template>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Swipe to close (iOS-like)
|
|
56
|
+
|
|
57
|
+
By default a drag handle (grab bar) is shown at the top of the sheet, and you can **close the sheet by dragging that handle down** - the sheet follows your pointer and either dismisses (past the threshold) or snaps back. This works with both touch and mouse.
|
|
58
|
+
|
|
59
|
+
Disable it with `:swipe-to-close="false"` (the handle is then hidden too), or replace the handle with the `#handle` slot. A `persistent` sheet never dismisses on swipe: it snaps back instead.
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<!-- enabled by default -->
|
|
63
|
+
<MazBottomSheet v-model="swipeOpened" title="Drag me down">
|
|
64
|
+
<p>Grab the bar at the top and drag down to close.</p>
|
|
65
|
+
</MazBottomSheet>
|
|
66
|
+
|
|
67
|
+
<!-- disable the handle and the gesture -->
|
|
68
|
+
<MazBottomSheet v-model="swipeOpened" :swipe-to-close="false" title="No swipe" />
|
|
69
|
+
|
|
70
|
+
<!-- custom handle -->
|
|
71
|
+
<MazBottomSheet v-model="swipeOpened" title="Custom handle">
|
|
72
|
+
<template #handle>
|
|
73
|
+
<span class="h-1.5 w-12 rounded-full bg-primary" />
|
|
74
|
+
</template>
|
|
75
|
+
</MazBottomSheet>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Header with an icon
|
|
79
|
+
|
|
80
|
+
Pass an `icon` (an icon value or a full `MazIconProps` object) to display it on the left of the title.
|
|
81
|
+
|
|
82
|
+
```html
|
|
83
|
+
<MazBottomSheet v-model="iconOpened" title="Notifications" icon="/bell.svg">
|
|
84
|
+
<p>You have 3 new notifications.</p>
|
|
85
|
+
|
|
86
|
+
<template #footer="{ close }">
|
|
87
|
+
<MazBtn @click="close">Mark all as read</MazBtn>
|
|
88
|
+
</template>
|
|
89
|
+
</MazBottomSheet>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Replaceable slots
|
|
93
|
+
|
|
94
|
+
Everything in the header is replaceable: use `#icon` and `#title` to customize parts of the default header, or `#header` to replace the whole header (you get the `close` function as a binding).
|
|
95
|
+
|
|
96
|
+
```html
|
|
97
|
+
<MazBottomSheet v-model="slotsOpened">
|
|
98
|
+
<template #icon>
|
|
99
|
+
<MazAvatar src="/avatar.jpg" size="sm" />
|
|
100
|
+
</template>
|
|
101
|
+
|
|
102
|
+
<template #title>
|
|
103
|
+
<span class="text-primary">Custom title</span>
|
|
104
|
+
</template>
|
|
105
|
+
|
|
106
|
+
<p>The icon and the title slots are fully replaceable.</p>
|
|
107
|
+
</MazBottomSheet>
|
|
108
|
+
|
|
109
|
+
<!-- or replace the whole header -->
|
|
110
|
+
<MazBottomSheet v-model="slotsOpened">
|
|
111
|
+
<template #header="{ close }">
|
|
112
|
+
<div class="flex items-center justify-between p-4">
|
|
113
|
+
<strong>My header</strong>
|
|
114
|
+
<MazBtn size="sm" color="transparent" @click="close">Close</MazBtn>
|
|
115
|
+
</div>
|
|
116
|
+
</template>
|
|
117
|
+
</MazBottomSheet>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Max width
|
|
121
|
+
|
|
122
|
+
On mobile the sheet is always **full-width**. From the tablet breakpoint and up, it is **constrained** to `max-width` and centered horizontally. The default `max-width` is `35rem`; pass the `max-width` prop (a `MazSizeUnit`) to override it.
|
|
123
|
+
|
|
124
|
+
```html
|
|
125
|
+
<MazBottomSheet v-model="wideOpened" title="Wide sheet" max-width="60rem">
|
|
126
|
+
<p>This sheet is constrained to 60rem on desktop and full-width on mobile.</p>
|
|
127
|
+
</MazBottomSheet>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Without header
|
|
131
|
+
|
|
132
|
+
Hide the whole header with `hide-header`, or only the close button with `hide-close-button`.
|
|
133
|
+
|
|
134
|
+
```html
|
|
135
|
+
<MazBottomSheet v-model="noHeaderOpened" hide-header>
|
|
136
|
+
<div class="flex flex-col gap-3 text-center">
|
|
137
|
+
<p>No header here, you control the whole layout.</p>
|
|
138
|
+
<MazBtn @click="noHeaderOpened = false">Got it</MazBtn>
|
|
139
|
+
</div>
|
|
140
|
+
</MazBottomSheet>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Persistent
|
|
144
|
+
|
|
145
|
+
A `persistent` sheet cannot be closed by clicking outside or pressing escape, and the close button is removed. Provide your own action to close it.
|
|
146
|
+
|
|
147
|
+
```html
|
|
148
|
+
<MazBottomSheet v-model="persistentOpened" title="Action required" persistent>
|
|
149
|
+
<p>You must confirm before closing this sheet.</p>
|
|
150
|
+
|
|
151
|
+
<template #footer>
|
|
152
|
+
<MazBtn @click="persistentOpened = false">I understand</MazBtn>
|
|
153
|
+
</template>
|
|
154
|
+
</MazBottomSheet>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Full example
|
|
158
|
+
|
|
159
|
+
```vue
|
|
160
|
+
<script setup>
|
|
161
|
+
import MazBottomSheet from 'maz-ui/components/MazBottomSheet'
|
|
162
|
+
import { reactive, ref } from 'vue'
|
|
163
|
+
|
|
164
|
+
const isProductOpen = ref(false)
|
|
165
|
+
const quantity = ref(1)
|
|
166
|
+
const selectedOptions = reactive({ size: '', color: '' })
|
|
167
|
+
|
|
168
|
+
function openProductOptions() {
|
|
169
|
+
isProductOpen.value = true
|
|
170
|
+
}
|
|
171
|
+
</script>
|
|
172
|
+
|
|
173
|
+
<template>
|
|
174
|
+
<MazBtn color="primary" @click="openProductOptions">
|
|
175
|
+
Customize Options
|
|
176
|
+
</MazBtn>
|
|
177
|
+
|
|
178
|
+
<MazBottomSheet v-model="isProductOpen" title="Customize Your Shoes" icon="/cog.svg" :padding="false">
|
|
179
|
+
<div class="space-y-6 p-6">
|
|
180
|
+
<h4 class="mb-3 text-lg font-semibold">
|
|
181
|
+
Select Size
|
|
182
|
+
</h4>
|
|
183
|
+
<div class="grid grid-cols-4 gap-2">
|
|
184
|
+
<MazBtn
|
|
185
|
+
v-for="size in sizes"
|
|
186
|
+
:key="size"
|
|
187
|
+
:color="selectedOptions.size === size ? 'primary' : 'secondary'"
|
|
188
|
+
size="sm"
|
|
189
|
+
@click="selectedOptions.size = size"
|
|
190
|
+
>
|
|
191
|
+
{{ size }}
|
|
192
|
+
</MazBtn>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
<template #footer="{ close }">
|
|
197
|
+
<MazBtn color="transparent" @click="close">
|
|
198
|
+
Cancel
|
|
199
|
+
</MazBtn>
|
|
200
|
+
<MazBtn color="primary" @click="addToCart">
|
|
201
|
+
Add to Cart (${{ (129.99 * quantity).toFixed(2) }})
|
|
202
|
+
</MazBtn>
|
|
203
|
+
</template>
|
|
204
|
+
</MazBottomSheet>
|
|
205
|
+
</template>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Accessibility
|
|
209
|
+
|
|
210
|
+
The bottom sheet is a modal `dialog` labelled by its `title` and described by its content. The focus is trapped inside while it is open, Esc closes it, and the rest of the page is `inert` (except the toasts and the live regions).
|
|
211
|
+
|
|
212
|
+
## MazBottomSheet API
|
|
213
|
+
|
|
214
|
+
`import MazBottomSheet from 'maz-ui/components/MazBottomSheet'`
|
|
215
|
+
|
|
216
|
+
### Props
|
|
217
|
+
|
|
218
|
+
- `model-value` (`boolean`, `v-model`): Modal's model value.
|
|
219
|
+
- `title` (`string`): Title of the bottom sheet in the header.
|
|
220
|
+
- `icon` (`MazIconLike`): Icon displayed on the left of the header. Accepts an icon value or a full `MazIconProps` object.
|
|
221
|
+
- `max-width` (`` `${number}rem` | `${number}px` | `${number}em` | `${number}vw` | `${number}vh` | `${number}vmin` | `${number}vmax` | `${number}%` | `${number}ch` | `${number}cm` | `${number}mm` | `${number}in` | `${number}ex` | `${number}pc` | `${number... ``, default: `"40rem"`): Bottom sheet's max-width, applied from the tablet breakpoint and up (full-width below).
|
|
222
|
+
- `hide-close-button` (`boolean`, default: `false`): Remove the close button in the header.
|
|
223
|
+
- `hide-header` (`boolean`, default: `false`): Remove the whole header.
|
|
224
|
+
- `padding` (`boolean`, default: `true`): Add the padding on the content area.
|
|
225
|
+
- `persistent` (`boolean`): Persistent bottom sheet (not closable by clicking outside and remove close button) Persistent dialog (not closable by clicking outside and remove close button).
|
|
226
|
+
- `swipe-to-close` (`boolean`, default: `true`): Show the drag handle at the top and allow closing the sheet by swiping it down (iOS-like). The swipe never closes a `persistent` sheet (it snaps back instead).
|
|
227
|
+
- `teleport-selector` (`string`): Teleport selector.
|
|
228
|
+
- `before-close` (`(() => void | Promise<void>)`): Function called before modal is close.
|
|
229
|
+
- `close-on-escape` (`boolean`, default: `true`): Prevent close on escape key.
|
|
230
|
+
- `transition-name` (`string`): Transition name.
|
|
231
|
+
- `backdrop-class` (`ClassValue`): Backdrop class.
|
|
232
|
+
- `backdrop-content-class` (`ClassValue`): Backdrop content class.
|
|
233
|
+
- `content-padding` (`boolean`): Add padding to the content.
|
|
234
|
+
- `justify` (`"none" | "center" | "end" | "start" | "space-between" | "space-around"`): Justify content.
|
|
235
|
+
- `align` (`"none" | "center" | "end" | "start"`): Align content.
|
|
236
|
+
- `variant` (`"bottom-sheet" | "dialog" | "drawer"`): Variant.
|
|
237
|
+
- `aria-labelledby` (`string`): ID for aria-labelledby.
|
|
238
|
+
- `aria-describedby` (`string`): ID for aria-describedby.
|
|
239
|
+
|
|
240
|
+
### Events
|
|
241
|
+
|
|
242
|
+
- `@update:model-value` (payload: `value: boolean`): Emitted when the model value is updated
|
|
243
|
+
- `@open` (payload: `value?: void | undefined`): Emitted when the component is opened
|
|
244
|
+
- `@close` (payload: `value?: void | undefined`): Emitted when the component is closed
|
|
245
|
+
|
|
246
|
+
### Slots
|
|
247
|
+
|
|
248
|
+
- `#handle`: Drag handle (grab bar) displayed at the top when `swipeToClose` is enabled
|
|
249
|
+
- `#header`: Header slot Bindings: `close: () => void` (close function).
|
|
250
|
+
- `#icon`: Icon slot in the header
|
|
251
|
+
- `#title`: Title slot in the header
|
|
252
|
+
- `#default`: Default content Bindings: `close: () => void` (close function).
|
|
253
|
+
- `#footer`: Footer slot Bindings: `close: () => void` (close function).
|
|
254
|
+
|
|
255
|
+
### Exposed (template ref)
|
|
256
|
+
|
|
257
|
+
- `close`: Close the bottom sheet
|