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,584 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Icons"
|
|
3
|
+
description: ""
|
|
4
|
+
package: "@maz-ui/icons"
|
|
5
|
+
url: "https://maz-ui.com/ecosystem/icons/"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Icons
|
|
9
|
+
|
|
10
|
+
>
|
|
11
|
+
|
|
12
|
+
- Package: `@maz-ui/icons`
|
|
13
|
+
- Import: `import { MazCheck } from '@maz-ui/icons/static/MazCheck'` or `import { MazIconsResolver } from '@maz-ui/icons/resolvers'`
|
|
14
|
+
- Web: https://maz-ui.com/ecosystem/icons/
|
|
15
|
+
|
|
16
|
+
A comprehensive collection of **860 beautiful SVG icons** ready for use in your Vue.js applications. Built with performance and flexibility in mind, these icons are optimized for modern web development.
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- **860+ icons** - All icons are available [in the icon set page](./icon-set.md)
|
|
21
|
+
- **Three component variants** - `static` (eager Vue component, default), `lazy` (async Vue component), and `raw` ✨ **(new in v5)** raw SVG strings for inlining without a Vue component or async chunk
|
|
22
|
+
- **Multiple usage patterns** - Vue components, raw SVG strings, direct SVG files, or auto-import
|
|
23
|
+
- **TypeScript support** - Full type definitions included
|
|
24
|
+
- **Tree-shakeable** - Import only the icons you need
|
|
25
|
+
- **Customizable** - Easy to style with CSS
|
|
26
|
+
- **Optimized SVGs** - Clean, minimal markup for best performance
|
|
27
|
+
- **Auto-import resolver** - Seamless integration with unplugin-vue-components
|
|
28
|
+
- **Build tool integration** - Works perfectly with Vite and vite-svg-loader
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
### Basic Installation
|
|
33
|
+
|
|
34
|
+
```bash [npm]
|
|
35
|
+
npm install @maz-ui/icons
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```bash [yarn]
|
|
39
|
+
yarn add @maz-ui/icons
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```bash [pnpm]
|
|
43
|
+
pnpm add @maz-ui/icons
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### With Auto-import Support (Recommended)
|
|
47
|
+
|
|
48
|
+
For the best developer experience with auto-imports:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install @maz-ui/icons unplugin-vue-components
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### With vite-svg-loader Integration
|
|
55
|
+
|
|
56
|
+
To use SVG files as Vue components:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm install @maz-ui/icons vite-svg-loader
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Usage Methods
|
|
63
|
+
|
|
64
|
+
### Method 1: Vue Components (Recommended)
|
|
65
|
+
|
|
66
|
+
Import and use icons as Vue components. Icons are available in two variants:
|
|
67
|
+
|
|
68
|
+
- **Static** (default) - eagerly loaded, rendered immediately with no async overhead
|
|
69
|
+
- **Lazy** - loaded on demand via `defineAsyncComponent`, ideal for optimizing bundle size
|
|
70
|
+
|
|
71
|
+
#### Static Icons (default)
|
|
72
|
+
|
|
73
|
+
```vue
|
|
74
|
+
<script setup lang="ts">
|
|
75
|
+
import { MazCheck, MazHeart, MazUser } from '@maz-ui/icons'
|
|
76
|
+
// Or import from the static sub-path:
|
|
77
|
+
// import { MazCheck } from '@maz-ui/icons/static'
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<template>
|
|
81
|
+
<div>
|
|
82
|
+
<MazCheck class="text-green-500" />
|
|
83
|
+
<MazUser class="w-6 h-6" />
|
|
84
|
+
<MazHeart class="text-red-500 hover:scale-110 transition-transform" />
|
|
85
|
+
</div>
|
|
86
|
+
</template>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Lazy Icons
|
|
90
|
+
|
|
91
|
+
Lazy icons are prefixed with `Lazy` and use `defineAsyncComponent` under the hood. Use them when you want to reduce your initial bundle size:
|
|
92
|
+
|
|
93
|
+
```vue
|
|
94
|
+
<script setup lang="ts">
|
|
95
|
+
import { MazCheck } from '@maz-ui/icons/lazy/MazCheck'
|
|
96
|
+
import { MazHeart } from '@maz-ui/icons/lazy/MazHeart'
|
|
97
|
+
import { MazUser } from '@maz-ui/icons/lazy/MazUser'
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
<template>
|
|
101
|
+
<div>
|
|
102
|
+
<LazyMazCheck class="text-green-500" />
|
|
103
|
+
<LazyMazUser class="w-6 h-6" />
|
|
104
|
+
<LazyMazHeart class="text-red-500 hover:scale-110 transition-transform" />
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Tip: Sub-path imports for better tree-shaking**
|
|
110
|
+
|
|
111
|
+
You can also import individual icons directly for optimal tree-shaking:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
// Static Vue component (individual file)
|
|
115
|
+
import { MazCheck } from '@maz-ui/icons/static/MazCheck'
|
|
116
|
+
|
|
117
|
+
// Lazy Vue component (individual file)
|
|
118
|
+
import { MazCheck } from '@maz-ui/icons/lazy/MazCheck'
|
|
119
|
+
|
|
120
|
+
// Raw SVG string (individual file) - new in v5
|
|
121
|
+
import { MazCheck } from '@maz-ui/icons/raw/MazCheck'
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### Raw SVG strings (new in v5)
|
|
125
|
+
|
|
126
|
+
Each icon is also exported as a **raw SVG string** under the `raw/` subpath. Pass it to `<MazIcon :icon="…" />` to inline the SVG without paying the cost of a Vue component or an async chunk - useful for icons rendered hundreds of times on a page (lists, tables) or for one-off `innerHTML` use.
|
|
127
|
+
|
|
128
|
+
```vue
|
|
129
|
+
<script setup lang="ts">
|
|
130
|
+
import MazIcon from 'maz-ui/components/MazIcon'
|
|
131
|
+
import { MazStar } from '@maz-ui/icons/raw/MazStar'
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<template>
|
|
135
|
+
<MazIcon :icon="MazStar" />
|
|
136
|
+
</template>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**When to use which variant:**
|
|
140
|
+
|
|
141
|
+
| Variant | Bundle cost | Use case |
|
|
142
|
+
| --- | --- | --- |
|
|
143
|
+
| `static` | Vue component, eager | Default. Few icons per page, simplest path. |
|
|
144
|
+
| `lazy` | Vue component, async chunk | Many icons but most off-screen at first paint. |
|
|
145
|
+
| `raw` | Inline SVG string | Same icon repeated many times in a list/table; or you want zero component overhead. |
|
|
146
|
+
|
|
147
|
+
**Benefits:**
|
|
148
|
+
|
|
149
|
+
- ✅ Tree-shaking - Only bundled icons are included
|
|
150
|
+
- ✅ TypeScript support with full IntelliSense
|
|
151
|
+
- ✅ Static icons render immediately, lazy icons optimize bundle size
|
|
152
|
+
- ✅ Easy to style with CSS classes
|
|
153
|
+
|
|
154
|
+
### Method 2: Auto-import with Resolver
|
|
155
|
+
|
|
156
|
+
Never worry about imports again with automatic component resolution.
|
|
157
|
+
|
|
158
|
+
#### Setup unplugin-vue-components
|
|
159
|
+
|
|
160
|
+
**Warning: Troubleshooting**
|
|
161
|
+
|
|
162
|
+
If your are already using [`MazComponentsResolver`](../../guide/resolvers.md#mazcomponentsresolver), you should place `MazIconsResolver` before `MazComponentsResolver` in the `resolvers` array.
|
|
163
|
+
|
|
164
|
+
`vite.config.ts`
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
import { MazIconsResolver } from '@maz-ui/icons/resolvers'
|
|
168
|
+
import Components from 'unplugin-vue-components/vite'
|
|
169
|
+
import { defineConfig } from 'vite'
|
|
170
|
+
|
|
171
|
+
export default defineConfig({
|
|
172
|
+
plugins: [
|
|
173
|
+
Components({
|
|
174
|
+
resolvers: [
|
|
175
|
+
MazIconsResolver() // Auto-import Maz UI icons
|
|
176
|
+
]
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
})
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### Usage (No Imports Required!)
|
|
183
|
+
|
|
184
|
+
```vue
|
|
185
|
+
<script setup lang="ts">
|
|
186
|
+
// No imports needed! Icons are auto-imported
|
|
187
|
+
</script>
|
|
188
|
+
|
|
189
|
+
<template>
|
|
190
|
+
<div class="navigation">
|
|
191
|
+
<!-- Static icons (eagerly loaded) -->
|
|
192
|
+
<MazHome class="nav-icon" />
|
|
193
|
+
<MazUser class="nav-icon" />
|
|
194
|
+
<MazSettings class="nav-icon" />
|
|
195
|
+
|
|
196
|
+
<!-- Lazy icons (async loaded) - prefix with "Lazy" -->
|
|
197
|
+
<LazyMazLogout class="nav-icon" />
|
|
198
|
+
</div>
|
|
199
|
+
</template>
|
|
200
|
+
|
|
201
|
+
<style scoped>
|
|
202
|
+
@reference "../../.vitepress/theme/main.css";
|
|
203
|
+
.nav-icon {
|
|
204
|
+
@apply w-6 h-6 text-gray-600 hover:text-blue-500 transition-colors cursor-pointer;
|
|
205
|
+
}
|
|
206
|
+
</style>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The resolver automatically resolves:
|
|
210
|
+
- `MazXxx` → static icon from `@maz-ui/icons/MazXxx`
|
|
211
|
+
- `LazyMazXxx` → lazy icon from `@maz-ui/icons/lazy/MazXxx`
|
|
212
|
+
|
|
213
|
+
**Benefits:**
|
|
214
|
+
|
|
215
|
+
- ✅ Zero import boilerplate
|
|
216
|
+
- ✅ Full TypeScript support
|
|
217
|
+
- ✅ Tree-shaking still works
|
|
218
|
+
- ✅ Both static and lazy variants supported
|
|
219
|
+
- ✅ IntelliSense for all available icons
|
|
220
|
+
|
|
221
|
+
### Method 3: With vite-svg-loader
|
|
222
|
+
|
|
223
|
+
Transform SVG files into Vue components at build time:
|
|
224
|
+
|
|
225
|
+
#### Vite Configuration
|
|
226
|
+
|
|
227
|
+
`vite.config.ts`
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
import svgLoader from 'vite-svg-loader'
|
|
231
|
+
|
|
232
|
+
export default defineConfig({
|
|
233
|
+
plugins: [
|
|
234
|
+
svgLoader({
|
|
235
|
+
defaultImport: 'component' // Import as Vue component by default
|
|
236
|
+
})
|
|
237
|
+
]
|
|
238
|
+
})
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
#### Usage in Components
|
|
242
|
+
|
|
243
|
+
```vue
|
|
244
|
+
<script setup lang="ts">
|
|
245
|
+
// Import SVGs as Vue components
|
|
246
|
+
import CheckIcon from '@maz-ui/icons/svg/check.svg?component'
|
|
247
|
+
import HeartIcon from '@maz-ui/icons/svg/heart.svg?component'
|
|
248
|
+
import UserIcon from '@maz-ui/icons/svg/user.svg?component'
|
|
249
|
+
</script>
|
|
250
|
+
|
|
251
|
+
<template>
|
|
252
|
+
<div class="flex items-center gap-2">
|
|
253
|
+
<CheckIcon class="w-5 h-5 text-green-600" />
|
|
254
|
+
<UserIcon class="w-6 h-6 text-blue-500" />
|
|
255
|
+
<HeartIcon class="w-4 h-4 text-red-500 animate-pulse" />
|
|
256
|
+
</div>
|
|
257
|
+
</template>
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Benefits:**
|
|
261
|
+
|
|
262
|
+
- ✅ Build-time optimization
|
|
263
|
+
- ✅ Full Vue component features (props, slots, etc.)
|
|
264
|
+
- ✅ Better performance than runtime imports
|
|
265
|
+
- ✅ Automatic TypeScript declarations
|
|
266
|
+
|
|
267
|
+
### Method 4: Direct SVG Files
|
|
268
|
+
|
|
269
|
+
Access SVG files directly for maximum flexibility:
|
|
270
|
+
|
|
271
|
+
```vue
|
|
272
|
+
<script setup lang="ts">
|
|
273
|
+
import { onMounted, ref } from 'vue'
|
|
274
|
+
|
|
275
|
+
const checkSvg = ref('')
|
|
276
|
+
|
|
277
|
+
onMounted(async () => {
|
|
278
|
+
const response = await fetch('/node_modules/@maz-ui/icons/svg/check.svg')
|
|
279
|
+
checkSvg.value = await response.text()
|
|
280
|
+
})
|
|
281
|
+
</script>
|
|
282
|
+
|
|
283
|
+
<template>
|
|
284
|
+
<div>
|
|
285
|
+
<!-- Using img tag -->
|
|
286
|
+
<img src="@maz-ui/icons/svg/check.svg" alt="Check" class="w-6 h-6">
|
|
287
|
+
|
|
288
|
+
<!-- Inline SVG with fetch -->
|
|
289
|
+
<div class="text-blue-500" v-html="checkSvg" />
|
|
290
|
+
</div>
|
|
291
|
+
</template>
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Benefits:**
|
|
295
|
+
|
|
296
|
+
- ✅ Direct file access
|
|
297
|
+
- ✅ Smallest possible bundle size
|
|
298
|
+
- ✅ Can be used in any context (not just Vue)
|
|
299
|
+
- ✅ Easy to embed in CSS or other assets
|
|
300
|
+
|
|
301
|
+
## Styling Icons
|
|
302
|
+
|
|
303
|
+
Icons inherit the current text color and can be styled like any other element:
|
|
304
|
+
|
|
305
|
+
```vue
|
|
306
|
+
<template>
|
|
307
|
+
<div class="icon-examples">
|
|
308
|
+
<!-- Size control -->
|
|
309
|
+
<MazStar class="w-4 h-4" />
|
|
310
|
+
<MazStar class="w-8 h-8" />
|
|
311
|
+
<MazStar class="text-2xl" />
|
|
312
|
+
|
|
313
|
+
<!-- Colors -->
|
|
314
|
+
<MazHeart class="text-red-500" />
|
|
315
|
+
<MazLeaf class="text-green-600" />
|
|
316
|
+
<MazSky class="text-blue-400" />
|
|
317
|
+
|
|
318
|
+
<!-- Interactive states -->
|
|
319
|
+
<MazBtn class="hover:text-blue-500 transition-colors cursor-pointer" />
|
|
320
|
+
|
|
321
|
+
<!-- Animations -->
|
|
322
|
+
<MazSpinner class="animate-spin" />
|
|
323
|
+
<MazHeart class="hover:scale-110 transition-transform" />
|
|
324
|
+
|
|
325
|
+
<!-- With background -->
|
|
326
|
+
<MazCheck class="p-2 bg-green-100 text-green-600 rounded-full" />
|
|
327
|
+
</div>
|
|
328
|
+
</template>
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### CSS Custom Properties
|
|
332
|
+
|
|
333
|
+
All icons support CSS custom properties for advanced styling:
|
|
334
|
+
|
|
335
|
+
```css
|
|
336
|
+
.custom-icon {
|
|
337
|
+
--icon-size: 1.5rem;
|
|
338
|
+
--icon-color: theme('colors.blue.500');
|
|
339
|
+
--icon-hover-color: theme('colors.blue.600');
|
|
340
|
+
|
|
341
|
+
width: var(--icon-size);
|
|
342
|
+
height: var(--icon-size);
|
|
343
|
+
color: var(--icon-color);
|
|
344
|
+
transition: color 0.2s ease;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.custom-icon:hover {
|
|
348
|
+
color: var(--icon-hover-color);
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
## Available Icons
|
|
353
|
+
|
|
354
|
+
The library includes **860+ carefully** covering all common use cases:
|
|
355
|
+
|
|
356
|
+
### Icon Naming Convention
|
|
357
|
+
|
|
358
|
+
All icons follow a consistent naming pattern:
|
|
359
|
+
|
|
360
|
+
- Static Vue components: `Maz` + PascalCase (e.g., `MazUserCircle`)
|
|
361
|
+
- Lazy Vue components: `LazyMaz` + PascalCase (e.g., `LazyMazUserCircle`)
|
|
362
|
+
- SVG files: kebab-case (e.g., `user-circle.svg`)
|
|
363
|
+
|
|
364
|
+
```typescript
|
|
365
|
+
// Static component imports (eagerly loaded)
|
|
366
|
+
import {
|
|
367
|
+
MazArrowRight, // arrow-right.svg
|
|
368
|
+
MazChatBubbleLeft, // chat-bubble-left.svg
|
|
369
|
+
MazShoppingCart, // shopping-cart.svg
|
|
370
|
+
MazUserCircle // user-circle.svg
|
|
371
|
+
} from '@maz-ui/icons'
|
|
372
|
+
|
|
373
|
+
// Lazy component imports (async loaded)
|
|
374
|
+
import {
|
|
375
|
+
LazyMazArrowRight,
|
|
376
|
+
LazyMazUserCircle
|
|
377
|
+
} from '@maz-ui/icons'
|
|
378
|
+
|
|
379
|
+
// Or import lazy icons without the Lazy prefix from the sub-path
|
|
380
|
+
import { MazArrowRight } from '@maz-ui/icons/lazy'
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
You can search icons on [Heroicons](https://heroicons.com/) and copy the name of the icon to use it in your project.
|
|
384
|
+
|
|
385
|
+
## Advanced Configuration
|
|
386
|
+
|
|
387
|
+
### Custom Icon Loading
|
|
388
|
+
|
|
389
|
+
Create your own icon loading utility:
|
|
390
|
+
|
|
391
|
+
```typescript
|
|
392
|
+
// utils/iconLoader.ts
|
|
393
|
+
import type { Component } from 'vue'
|
|
394
|
+
import { defineAsyncComponent } from 'vue'
|
|
395
|
+
|
|
396
|
+
interface IconComponents {
|
|
397
|
+
[key: string]: Component
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export function createIconLoader(iconNames: string[]): IconComponents {
|
|
401
|
+
const icons: IconComponents = {}
|
|
402
|
+
|
|
403
|
+
iconNames.forEach((name) => {
|
|
404
|
+
const componentName = `Maz${name.split('-').map(
|
|
405
|
+
word => word.charAt(0).toUpperCase() + word.slice(1)
|
|
406
|
+
).join('')}`
|
|
407
|
+
|
|
408
|
+
icons[componentName] = defineAsyncComponent(
|
|
409
|
+
() => import(`@maz-ui/icons/svg/${name}.svg?component`)
|
|
410
|
+
)
|
|
411
|
+
})
|
|
412
|
+
|
|
413
|
+
return icons
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// Usage
|
|
417
|
+
const icons = createIconLoader(['check', 'user', 'heart'])
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### Dynamic Icon Loading
|
|
421
|
+
|
|
422
|
+
Load icons dynamically based on runtime conditions:
|
|
423
|
+
|
|
424
|
+
```vue
|
|
425
|
+
<script setup lang="ts">
|
|
426
|
+
import { computed, defineAsyncComponent } from 'vue'
|
|
427
|
+
|
|
428
|
+
interface Props {
|
|
429
|
+
name: string
|
|
430
|
+
size?: 'sm' | 'md' | 'lg'
|
|
431
|
+
color?: string
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
435
|
+
size: 'md',
|
|
436
|
+
color: 'currentColor'
|
|
437
|
+
})
|
|
438
|
+
|
|
439
|
+
const iconComponent = computed(() => {
|
|
440
|
+
return defineAsyncComponent(
|
|
441
|
+
() => import(`@maz-ui/icons/svg/${props.name}.svg?component`)
|
|
442
|
+
)
|
|
443
|
+
})
|
|
444
|
+
|
|
445
|
+
const iconClass = computed(() => {
|
|
446
|
+
const sizes = {
|
|
447
|
+
sm: 'w-4 h-4',
|
|
448
|
+
md: 'w-6 h-6',
|
|
449
|
+
lg: 'w-8 h-8'
|
|
450
|
+
}
|
|
451
|
+
return `${sizes[props.size]} text-${props.color}`
|
|
452
|
+
})
|
|
453
|
+
|
|
454
|
+
function handleClick() {
|
|
455
|
+
console.log(`Clicked ${props.name} icon`)
|
|
456
|
+
}
|
|
457
|
+
</script>
|
|
458
|
+
|
|
459
|
+
<template>
|
|
460
|
+
<component
|
|
461
|
+
:is="iconComponent"
|
|
462
|
+
:class="iconClass"
|
|
463
|
+
@click="handleClick"
|
|
464
|
+
/>
|
|
465
|
+
</template>
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Build-time Icon Optimization
|
|
469
|
+
|
|
470
|
+
Optimize icons at build time with custom Vite plugin:
|
|
471
|
+
|
|
472
|
+
```typescript
|
|
473
|
+
// vite-plugin-icon-optimizer.ts
|
|
474
|
+
import type { Plugin } from 'vite'
|
|
475
|
+
import { readFileSync } from 'node:fs'
|
|
476
|
+
import { optimize } from 'svgo'
|
|
477
|
+
|
|
478
|
+
export function iconOptimizer(): Plugin {
|
|
479
|
+
return {
|
|
480
|
+
name: 'icon-optimizer',
|
|
481
|
+
transform(code, id) {
|
|
482
|
+
if (id.includes('@maz-ui/icons/svg') && id.endsWith('.svg')) {
|
|
483
|
+
const svgContent = readFileSync(id.replace('?component', ''), 'utf-8')
|
|
484
|
+
const optimized = optimize(svgContent, {
|
|
485
|
+
plugins: [
|
|
486
|
+
'removeDoctype',
|
|
487
|
+
'removeComments',
|
|
488
|
+
'removeEmptyElements',
|
|
489
|
+
'mergePaths'
|
|
490
|
+
]
|
|
491
|
+
})
|
|
492
|
+
|
|
493
|
+
return `export default ${JSON.stringify(optimized.data)}`
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
## Integration Examples
|
|
501
|
+
|
|
502
|
+
### With Tailwind CSS
|
|
503
|
+
|
|
504
|
+
```vue
|
|
505
|
+
<template>
|
|
506
|
+
<div class="flex items-center space-x-4">
|
|
507
|
+
<MazHome class="w-5 h-5 text-gray-500 hover:text-blue-500 transition-colors" />
|
|
508
|
+
<MazUser class="w-6 h-6 text-indigo-600" />
|
|
509
|
+
<MazSettings class="w-4 h-4 text-gray-400 hover:text-gray-600" />
|
|
510
|
+
</div>
|
|
511
|
+
</template>
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
### With Pinia Store
|
|
515
|
+
|
|
516
|
+
```typescript
|
|
517
|
+
import type { Component } from 'vue'
|
|
518
|
+
// stores/icons.ts
|
|
519
|
+
import { defineStore } from 'pinia'
|
|
520
|
+
|
|
521
|
+
export const useIconStore = defineStore('icons', () => {
|
|
522
|
+
const loadedIcons = ref<Map<string, Component>>(new Map())
|
|
523
|
+
|
|
524
|
+
async function loadIcon(name: string): Promise<Component> {
|
|
525
|
+
if (loadedIcons.value.has(name)) {
|
|
526
|
+
return loadedIcons.value.get(name)!
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
const icon = await import(`@maz-ui/icons/svg/${name}.svg?component`)
|
|
530
|
+
loadedIcons.value.set(name, icon.default)
|
|
531
|
+
return icon.default
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
return { loadIcon }
|
|
535
|
+
})
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
## Troubleshooting
|
|
539
|
+
|
|
540
|
+
### Common Issues
|
|
541
|
+
|
|
542
|
+
**Icons not displaying:**
|
|
543
|
+
|
|
544
|
+
- Ensure SVG files are properly served by your build tool
|
|
545
|
+
- Check if CSS `currentColor` is being inherited correctly
|
|
546
|
+
- Verify vite-svg-loader configuration if using component imports
|
|
547
|
+
|
|
548
|
+
**TypeScript errors:**
|
|
549
|
+
|
|
550
|
+
- Add `vite-svg-loader` types to your `tsconfig.json`:
|
|
551
|
+
|
|
552
|
+
```json
|
|
553
|
+
{
|
|
554
|
+
"compilerOptions": {
|
|
555
|
+
"types": ["vite-svg-loader"]
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
**Auto-import not working:**
|
|
561
|
+
|
|
562
|
+
- Verify `unplugin-vue-components` is properly configured
|
|
563
|
+
- Check that `MazIconsResolver` is included in resolvers array
|
|
564
|
+
- Ensure icon names match the exact component names
|
|
565
|
+
|
|
566
|
+
## Bundle Size
|
|
567
|
+
|
|
568
|
+
| Usage Method | Bundle Impact | Best For |
|
|
569
|
+
| -------------------- | ------------- | ------------------------------------- |
|
|
570
|
+
| Static components | Tree-shaken | Immediate rendering, critical UI |
|
|
571
|
+
| Lazy components | Code-split | Non-critical icons, large icon sets |
|
|
572
|
+
| Direct SVG | Minimal | Static usage, minimal bundles |
|
|
573
|
+
| Auto-import | Tree-shaken | Development experience |
|
|
574
|
+
| vite-svg-loader | Optimized | Build-time optimization |
|
|
575
|
+
|
|
576
|
+
## Related Packages
|
|
577
|
+
|
|
578
|
+
- [Heroicons](https://heroicons.com/) - Tailwind CSS icons
|
|
579
|
+
- [`unplugin-vue-components`](https://github.com/antfu/unplugin-vue-components) - Auto-import components
|
|
580
|
+
- [`vite-svg-loader`](https://github.com/jpkleemans/vite-svg-loader) - Load SVG as Vue components
|
|
581
|
+
|
|
582
|
+
---
|
|
583
|
+
|
|
584
|
+
**Need help?** Check out our [GitHub discussions](https://github.com/LouisMazel/maz-ui/discussions) or open an [issue](https://github.com/LouisMazel/maz-ui/issues).
|