@primeicons/angular 8.0.0-alpha.4 → 8.0.0-alpha.5

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.
Files changed (2) hide show
  1. package/README.md +297 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,297 @@
1
+ # @primeicons/angular
2
+
3
+ PrimeIcons for Angular - 300+ customizable SVG icons as Angular standalone components.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @primeicons/angular
9
+ # or
10
+ pnpm add @primeicons/angular
11
+ # or
12
+ yarn add @primeicons/angular
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Import Icons in Standalone Components
18
+
19
+ ```typescript
20
+ import { Component } from '@angular/core';
21
+ import { Search, Home, User, Cog } from '@primeicons/angular';
22
+
23
+ @Component({
24
+ selector: 'app-root',
25
+ standalone: true,
26
+ imports: [Search, Home, User, Cog],
27
+ template: `
28
+ <svg data-p-icon="search"></svg>
29
+ <svg data-p-icon="home" [size]="32"></svg>
30
+ <svg data-p-icon="user" color="blue"></svg>
31
+ <svg data-p-icon="cog" size="2rem" color="#ff0000"></svg>
32
+ `
33
+ })
34
+ export class AppComponent {}
35
+ ```
36
+
37
+ ### Import Individual Icons (Tree-Shakeable)
38
+
39
+ ```typescript
40
+ import { Component } from '@angular/core';
41
+ import { Search } from '@primeicons/angular/search';
42
+ import { Home } from '@primeicons/angular/home';
43
+
44
+ @Component({
45
+ selector: 'app-root',
46
+ standalone: true,
47
+ imports: [Search, Home],
48
+ template: `
49
+ <svg data-p-icon="search" [size]="24"></svg>
50
+ <svg data-p-icon="home" [size]="24" color="green"></svg>
51
+ `
52
+ })
53
+ export class AppComponent {}
54
+ ```
55
+
56
+ ## Inputs
57
+
58
+ All icon components accept the following inputs:
59
+
60
+ | Input | Type | Default | Description |
61
+ | ------- | ------------------ | -------------- | ---------------------------- |
62
+ | `size` | `number \| string` | `24` | Icon size (width and height) |
63
+ | `color` | `string` | `currentColor` | Icon color |
64
+
65
+ ## Examples
66
+
67
+ ### Basic Usage
68
+
69
+ ```typescript
70
+ import { Component } from '@angular/core';
71
+ import { Heart, Star, Bell } from '@primeicons/angular';
72
+
73
+ @Component({
74
+ selector: 'app-icons',
75
+ standalone: true,
76
+ imports: [Heart, Star, Bell],
77
+ template: `
78
+ <svg data-p-icon="heart"></svg>
79
+ <svg data-p-icon="star" [size]="32"></svg>
80
+ <svg data-p-icon="bell" color="red"></svg>
81
+ `
82
+ })
83
+ export class IconsComponent {}
84
+ ```
85
+
86
+ ### With Signal Inputs
87
+
88
+ ```typescript
89
+ import { Component, signal } from '@angular/core';
90
+ import { Search } from '@primeicons/angular';
91
+
92
+ @Component({
93
+ selector: 'app-search',
94
+ standalone: true,
95
+ imports: [Search],
96
+ template: `
97
+ <svg data-p-icon="search" [size]="iconSize()" [color]="iconColor()"></svg>
98
+ <button (click)="toggleSize()">Toggle Size</button>
99
+ `
100
+ })
101
+ export class SearchComponent {
102
+ iconSize = signal(24);
103
+ iconColor = signal('#007bff');
104
+
105
+ toggleSize() {
106
+ this.iconSize.update((s) => (s === 24 ? 32 : 24));
107
+ }
108
+ }
109
+ ```
110
+
111
+ ### Dynamic Icon Component
112
+
113
+ For dynamic icon rendering, you can create a wrapper component:
114
+
115
+ ```typescript
116
+ import { Component, input, ViewContainerRef, effect, inject, Type } from '@angular/core';
117
+ import { CoreIcon } from '@primeicons/angular/core';
118
+ import * as Icons from '@primeicons/angular';
119
+
120
+ @Component({
121
+ selector: 'p-icon',
122
+ standalone: true,
123
+ template: ''
124
+ })
125
+ export class PIcon {
126
+ private vcr = inject(ViewContainerRef);
127
+
128
+ name = input.required<string>();
129
+ size = input<number | string>(24);
130
+ color = input<string | undefined>(undefined);
131
+
132
+ constructor() {
133
+ effect(() => {
134
+ this.vcr.clear();
135
+ const IconComponent = (Icons as Record<string, Type<CoreIcon>>)[this.toPascalCase(this.name())];
136
+ if (IconComponent) {
137
+ const ref = this.vcr.createComponent(IconComponent);
138
+ ref.setInput('size', this.size());
139
+ if (this.color()) {
140
+ ref.setInput('color', this.color());
141
+ }
142
+ }
143
+ });
144
+ }
145
+
146
+ private toPascalCase(str: string): string {
147
+ return str
148
+ .split('-')
149
+ .map((s) => s.charAt(0).toUpperCase() + s.slice(1))
150
+ .join('');
151
+ }
152
+ }
153
+ ```
154
+
155
+ ### With Button
156
+
157
+ ```typescript
158
+ import { Component } from '@angular/core';
159
+ import { Search, Plus, Trash } from '@primeicons/angular';
160
+
161
+ @Component({
162
+ selector: 'app-buttons',
163
+ standalone: true,
164
+ imports: [Search, Plus, Trash],
165
+ template: `
166
+ <button><svg data-p-icon="search" [size]="16"></svg> Search</button>
167
+
168
+ <button><svg data-p-icon="plus" [size]="16"></svg> Add Item</button>
169
+
170
+ <button class="danger"><svg data-p-icon="trash" [size]="16" color="red"></svg> Delete</button>
171
+ `
172
+ })
173
+ export class ButtonsComponent {}
174
+ ```
175
+
176
+ ## TypeScript
177
+
178
+ Full TypeScript support:
179
+
180
+ ```typescript
181
+ import { Component } from '@angular/core';
182
+ import { Search } from '@primeicons/angular';
183
+ import type { IconProps } from '@primeicons/core';
184
+
185
+ @Component({
186
+ selector: 'app-typed-icon',
187
+ standalone: true,
188
+ imports: [Search],
189
+ template: `<svg data-p-icon="search" [size]="config.size" [color]="config.color"></svg>`
190
+ })
191
+ export class TypedIconComponent {
192
+ config: IconProps = {
193
+ size: 24,
194
+ color: 'blue'
195
+ };
196
+ }
197
+ ```
198
+
199
+ ## CSS Classes
200
+
201
+ Each icon automatically includes these CSS classes:
202
+
203
+ - `p-icon` - Base class for all icons
204
+ - `p-icon-{name}` - Specific class for each icon (e.g., `p-icon-search`)
205
+
206
+ ```css
207
+ /* Style all icons */
208
+ :host ::ng-deep .p-icon {
209
+ transition: color 0.2s;
210
+ }
211
+
212
+ /* Style specific icon */
213
+ :host ::ng-deep .p-icon-heart:hover {
214
+ color: red;
215
+ }
216
+ ```
217
+
218
+ Or using global styles:
219
+
220
+ ```css
221
+ /* styles.css */
222
+ .p-icon {
223
+ transition: color 0.2s;
224
+ }
225
+
226
+ .p-icon-heart:hover {
227
+ color: red;
228
+ }
229
+ ```
230
+
231
+ ## Metadata & Icon Lookup
232
+
233
+ Icon metadata is managed by the `@primeicons/metadata` package and re-exported here for convenience:
234
+
235
+ ```typescript
236
+ import { ICON_MAP, ICON_MAP_BY_NAME, findIcons } from '@primeicons/metadata/angular';
237
+
238
+ // Find icon by name (kebab-case)
239
+ const iconData = ICON_MAP_BY_NAME['check'];
240
+ const CheckIcon = iconData.component; // Already lazy-loaded component
241
+
242
+ // Search and use
243
+ const results = findIcons('arrow');
244
+ results.forEach((icon) => {
245
+ const Component = icon.component;
246
+ // Use Component in imports: imports: [Component]
247
+ });
248
+ ```
249
+
250
+ Alternatively, import directly from the metadata package:
251
+
252
+ ```typescript
253
+ import { ICON_MAP, findIcons } from '@primeicons/metadata/angular';
254
+ ```
255
+
256
+ ### Metadata API
257
+
258
+ | Variable | Type | Description |
259
+ | ----------------------- | ----------------------------------- | -------------------------------------------- |
260
+ | `ICON_MAP` | `IconMetadataEntry[]` | All icons as array |
261
+ | `ICON_MAP_BY_NAME` | `Record<string, IconMetadataEntry>` | Indexed by kebab-case name |
262
+ | `ICON_MAP_BY_COMPONENT` | `Record<string, IconMetadataEntry>` | Indexed by component name (with Icon suffix) |
263
+ | `ICON_MAP_BY_CAMEL` | `Record<string, IconMetadataEntry>` | Indexed by camelCase name |
264
+ | `TOTAL_ICONS` | `number` | Total icon count |
265
+ | `PACKAGE_INFO` | `object` | Package metadata |
266
+
267
+ | Function | Returns | Description |
268
+ | --------------------- | --------------------- | -------------------------------------- |
269
+ | `getIconNames()` | `string[]` | All kebab-case icon names |
270
+ | `getComponentNames()` | `string[]` | All component names (with Icon suffix) |
271
+ | `findIcons(query)` | `IconMetadataEntry[]` | Search icons by partial match |
272
+
273
+ ### JSON Metadata
274
+
275
+ Access the raw JSON metadata directly:
276
+
277
+ ```typescript
278
+ import metadata from '@primeicons/metadata/angular.json';
279
+
280
+ console.log(manifest.icons[0]); // { name: 'address-book', component: 'AddressBookIcon', ... }
281
+ ```
282
+
283
+ ## Icon List
284
+
285
+ The library includes 300+ icons including:
286
+
287
+ - Navigation: `ArrowLeft`, `ArrowRight`, `ChevronUp`, `ChevronDown`
288
+ - Actions: `Search`, `Plus`, `Minus`, `Check`, `Times`
289
+ - Objects: `Home`, `User`, `Cog`, `File`, `Folder`
290
+ - Social: `Facebook`, `Twitter`, `Github`, `Linkedin`
291
+ - And many more...
292
+
293
+ View the complete list at [primeicons.org](https://primeicons.org).
294
+
295
+ ## License
296
+
297
+ MIT - Copyright (c) PrimeTek Informatics
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primeicons/angular",
3
- "version": "8.0.0-alpha.4",
3
+ "version": "8.0.0-alpha.5",
4
4
  "author": "PrimeTek Informatics",
5
5
  "homepage": "https://primeicons.org/",
6
6
  "description": "PrimeIcons for Angular - 300+ customizable SVG icons as Angular components",
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@primeuix/utils": "^0.6.4",
30
30
  "tslib": "^2",
31
- "@primeicons/core": "8.0.0-alpha.4"
31
+ "@primeicons/core": "8.0.0-alpha.5"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@angular/core": ">=21"