@shaquillehinds/react-native-svg-icons 0.0.1 → 0.0.2
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/README.md +375 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1,375 @@
|
|
|
1
|
-
#
|
|
1
|
+
#
|
|
2
|
+
|
|
3
|
+
A comprehensive, type-safe SVG icon library for React Native with 997+ icons in both filled and outline variants.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎨 **997+ Icons** - Extensive collection covering UI elements, social media, crypto, arrows, shapes, and more
|
|
8
|
+
- 🔒 **Fully Type-Safe** - TypeScript-first with auto-generated types ensuring icon names are validated at compile time
|
|
9
|
+
- 🎭 **Dual Variants** - Every icon available in both `filled` and `outline` styles
|
|
10
|
+
- ⚡ **Performance Optimized** - Tree-shakeable with efficient SVG rendering via `react-native-svg`
|
|
11
|
+
- 🎨 **Highly Customizable** - Control size, color, and pass custom SVG/Path props
|
|
12
|
+
- 🔧 **Zero Configuration** - Works out of the box with sensible defaults
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @shaquillehinds/react-native-svg-icons react-native-svg
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
or
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
yarn add @shaquillehinds/react-native-svg-icons react-native-svg
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Note:** This package requires `react-native-svg` as a peer dependency.
|
|
27
|
+
|
|
28
|
+
### iOS Setup
|
|
29
|
+
|
|
30
|
+
For iOS, you'll need to install pods:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
cd ios && pod install
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
### Basic Usage
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import { SvgIcon } from '@shaquillehinds/react-native-svg-icons';
|
|
42
|
+
|
|
43
|
+
function MyComponent() {
|
|
44
|
+
return <SvgIcon type="filled" name="Heart" size={24} color="#FF0000" />;
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### With Outline Variant
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
<SvgIcon type="outline" name="Heart" size={24} color="#000000" />
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Custom SVG Props
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
<SvgIcon
|
|
58
|
+
type="filled"
|
|
59
|
+
name="Star"
|
|
60
|
+
size={32}
|
|
61
|
+
color="#FFD700"
|
|
62
|
+
svgProps={{
|
|
63
|
+
opacity: 0.8,
|
|
64
|
+
style: { marginRight: 8 },
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Custom Path Props
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
<SvgIcon
|
|
73
|
+
type="outline"
|
|
74
|
+
name="User"
|
|
75
|
+
size={28}
|
|
76
|
+
color="#333"
|
|
77
|
+
pathProps={{
|
|
78
|
+
strokeWidth: 2,
|
|
79
|
+
strokeLinecap: 'round',
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## API Reference
|
|
85
|
+
|
|
86
|
+
### `<SvgIcon />`
|
|
87
|
+
|
|
88
|
+
The main component for rendering icons.
|
|
89
|
+
|
|
90
|
+
#### Props
|
|
91
|
+
|
|
92
|
+
| Prop | Type | Default | Description |
|
|
93
|
+
| ----------- | ----------------------------------- | ----------- | ------------------------------------------------ |
|
|
94
|
+
| `type` | `'filled' \| 'outline'` | Required | The icon variant to render |
|
|
95
|
+
| `name` | `FilledIconName \| OutlineIconName` | Required | The name of the icon (type-safe based on `type`) |
|
|
96
|
+
| `size` | `number` | `24` | The size of the icon in pixels |
|
|
97
|
+
| `color` | `string` | `'#000000'` | The color of the icon |
|
|
98
|
+
| `svgProps` | `SvgProps` | `undefined` | Additional props to pass to the SVG component |
|
|
99
|
+
| `pathProps` | `PathProps` | `undefined` | Additional props to pass to the Path component |
|
|
100
|
+
|
|
101
|
+
### Type Exports
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
import type {
|
|
105
|
+
FilledIconName, // Union type of all filled icon names
|
|
106
|
+
OutlineIconName, // Union type of all outline icon names
|
|
107
|
+
IconName, // Union of both filled and outline names
|
|
108
|
+
SvgIconType, // 'filled' | 'outline'
|
|
109
|
+
SvgIconProps, // Component props type
|
|
110
|
+
} from '@shaquillehinds/react-native-svg-icons';
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Available Icons
|
|
114
|
+
|
|
115
|
+
This library includes 997+ icons across various categories:
|
|
116
|
+
|
|
117
|
+
### Categories
|
|
118
|
+
|
|
119
|
+
- **UI Elements**: Add, Remove, Edit, Delete, Search, Filter, Menu, Close, etc.
|
|
120
|
+
- **Arrows & Navigation**: Arrow variations in all directions, chevrons, points, swaps
|
|
121
|
+
- **Social Media**: Facebook, Twitter, Instagram, YouTube, LinkedIn, etc.
|
|
122
|
+
- **Crypto**: Bitcoin, Ethereum, various altcoin logos
|
|
123
|
+
- **Shapes**: Circles, squares, triangles, hexagons, etc.
|
|
124
|
+
- **Media**: Play, Pause, Stop, Record, Camera, Video, Music
|
|
125
|
+
- **Communication**: Message, Call, Email, Notification, Chat
|
|
126
|
+
- **Files & Folders**: Document, Folder, Archive, Cloud, Download, Upload
|
|
127
|
+
- **Commerce**: Shopping bag, cart, wallet, card, tag
|
|
128
|
+
- **User & Profile**: User, Profile, Avatar, Account, Team
|
|
129
|
+
- **Time & Calendar**: Clock, Calendar, Timer, Alarm
|
|
130
|
+
- **Location**: Map, Location, GPS, Compass, Globe
|
|
131
|
+
- **Weather**: Sun, Moon, Cloud, Rain, Storm
|
|
132
|
+
- **Security**: Lock, Unlock, Shield, Key, Eye, Scan
|
|
133
|
+
- **Devices**: Mobile, Tablet, Desktop, Laptop, Watch
|
|
134
|
+
- **And many more...**
|
|
135
|
+
|
|
136
|
+
### Example Icon Names
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
// UI Elements
|
|
140
|
+
('Add',
|
|
141
|
+
'AddCircle',
|
|
142
|
+
'AddSquare',
|
|
143
|
+
'Remove',
|
|
144
|
+
'Edit',
|
|
145
|
+
'Delete',
|
|
146
|
+
'Search',
|
|
147
|
+
'Filter');
|
|
148
|
+
|
|
149
|
+
// Arrows
|
|
150
|
+
('ArrowUp',
|
|
151
|
+
'ArrowDown',
|
|
152
|
+
'ArrowLeft',
|
|
153
|
+
'ArrowRight',
|
|
154
|
+
'ArrowChevronUp',
|
|
155
|
+
'ArrowCircleDown');
|
|
156
|
+
|
|
157
|
+
// Social Media
|
|
158
|
+
('Facebook', 'Instagram', 'Twitter', 'Youtube', 'Linkedin', 'Tiktok');
|
|
159
|
+
|
|
160
|
+
// Crypto
|
|
161
|
+
('Bitcoin', 'Ethereum', 'Binance', 'Cardano', 'Polygon', 'Solana');
|
|
162
|
+
|
|
163
|
+
// Media
|
|
164
|
+
('Play',
|
|
165
|
+
'Pause',
|
|
166
|
+
'Stop',
|
|
167
|
+
'Record',
|
|
168
|
+
'VolumeUp',
|
|
169
|
+
'VolumeDown',
|
|
170
|
+
'Camera',
|
|
171
|
+
'Video');
|
|
172
|
+
|
|
173
|
+
// Communication
|
|
174
|
+
('Message',
|
|
175
|
+
'Messages',
|
|
176
|
+
'Call',
|
|
177
|
+
'Calling',
|
|
178
|
+
'Sms',
|
|
179
|
+
'Notification',
|
|
180
|
+
'NotificationBing');
|
|
181
|
+
|
|
182
|
+
// Files
|
|
183
|
+
('Document', 'Folder', 'FolderOpen', 'Archive', 'CloudAdd', 'CloudDownload');
|
|
184
|
+
|
|
185
|
+
// Commerce
|
|
186
|
+
('Bag',
|
|
187
|
+
'ShoppingBag',
|
|
188
|
+
'ShoppingCart',
|
|
189
|
+
'Wallet',
|
|
190
|
+
'Card',
|
|
191
|
+
'Tag',
|
|
192
|
+
'TicketDiscount');
|
|
193
|
+
|
|
194
|
+
// User
|
|
195
|
+
('User', 'Profile', 'ProfileCircle', 'People', 'UserAdd', 'UserRemove');
|
|
196
|
+
|
|
197
|
+
// Time
|
|
198
|
+
('Clock', 'Calendar', 'Timer', 'Alarm', 'Watch', 'TimeCircle');
|
|
199
|
+
|
|
200
|
+
// Location
|
|
201
|
+
('Location', 'Map', 'Gps', 'DirectionRight', 'GlobalSearch', 'RouteSquare');
|
|
202
|
+
|
|
203
|
+
// Security
|
|
204
|
+
('Lock', 'Unlock', 'Shield', 'ShieldTick', 'Eye', 'EyeSlash', 'Scan', 'Key');
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## TypeScript Support
|
|
208
|
+
|
|
209
|
+
This library is built with TypeScript and provides full type safety. Icon names are validated based on the selected type:
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
// ✅ Valid - 'Heart' exists in filled icons
|
|
213
|
+
<SvgIcon type="filled" name="Heart" />
|
|
214
|
+
|
|
215
|
+
// ✅ Valid - 'Heart' exists in outline icons
|
|
216
|
+
<SvgIcon type="outline" name="Heart" />
|
|
217
|
+
|
|
218
|
+
// ❌ TypeScript Error - 'InvalidIcon' doesn't exist
|
|
219
|
+
<SvgIcon type="filled" name="InvalidIcon" />
|
|
220
|
+
|
|
221
|
+
// Type-safe with generics
|
|
222
|
+
function IconWrapper<T extends SvgIconType>(props: SvgIconProps<T>) {
|
|
223
|
+
return <SvgIcon {...props} />;
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Examples
|
|
228
|
+
|
|
229
|
+
### Creating an Icon Button
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
import { TouchableOpacity } from 'react-native';
|
|
233
|
+
import { SvgIcon } from '@shaquillehinds/react-native-svg-icons';
|
|
234
|
+
|
|
235
|
+
function IconButton({ onPress }: { onPress: () => void }) {
|
|
236
|
+
return (
|
|
237
|
+
<TouchableOpacity onPress={onPress}>
|
|
238
|
+
<SvgIcon type="filled" name="Heart" size={24} color="#FF0000" />
|
|
239
|
+
</TouchableOpacity>
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Tab Bar Icons
|
|
245
|
+
|
|
246
|
+
```tsx
|
|
247
|
+
import { SvgIcon } from '@shaquillehinds/react-native-svg-icons';
|
|
248
|
+
|
|
249
|
+
function TabBarIcon({
|
|
250
|
+
focused,
|
|
251
|
+
name,
|
|
252
|
+
}: {
|
|
253
|
+
focused: boolean;
|
|
254
|
+
name: 'Home' | 'Search' | 'Profile';
|
|
255
|
+
}) {
|
|
256
|
+
return (
|
|
257
|
+
<SvgIcon
|
|
258
|
+
type={focused ? 'filled' : 'outline'}
|
|
259
|
+
name={name}
|
|
260
|
+
size={24}
|
|
261
|
+
color={focused ? '#007AFF' : '#8E8E93'}
|
|
262
|
+
/>
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Dynamic Icon List
|
|
268
|
+
|
|
269
|
+
```tsx
|
|
270
|
+
import { View } from 'react-native';
|
|
271
|
+
import { SvgIcon } from '@shaquillehinds/react-native-svg-icons';
|
|
272
|
+
import type { FilledIconName } from '@shaquillehinds/react-native-svg-icons';
|
|
273
|
+
|
|
274
|
+
function IconGrid() {
|
|
275
|
+
const icons: FilledIconName[] = ['Heart', 'Star', 'User', 'Setting', 'Home'];
|
|
276
|
+
|
|
277
|
+
return (
|
|
278
|
+
<View style={{ flexDirection: 'row', gap: 16 }}>
|
|
279
|
+
{icons.map((icon) => (
|
|
280
|
+
<SvgIcon key={icon} type="filled" name={icon} size={32} color="#000" />
|
|
281
|
+
))}
|
|
282
|
+
</View>
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Animated Icons
|
|
288
|
+
|
|
289
|
+
```tsx
|
|
290
|
+
import { Animated } from 'react-native';
|
|
291
|
+
import { SvgIcon } from '@shaquillehinds/react-native-svg-icons';
|
|
292
|
+
|
|
293
|
+
function AnimatedIcon() {
|
|
294
|
+
const scaleAnim = useRef(new Animated.Value(1)).current;
|
|
295
|
+
|
|
296
|
+
const handlePress = () => {
|
|
297
|
+
Animated.sequence([
|
|
298
|
+
Animated.timing(scaleAnim, {
|
|
299
|
+
toValue: 1.2,
|
|
300
|
+
duration: 150,
|
|
301
|
+
useNativeDriver: true,
|
|
302
|
+
}),
|
|
303
|
+
Animated.timing(scaleAnim, {
|
|
304
|
+
toValue: 1,
|
|
305
|
+
duration: 150,
|
|
306
|
+
useNativeDriver: true,
|
|
307
|
+
}),
|
|
308
|
+
]).start();
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
return (
|
|
312
|
+
<Animated.View style={{ transform: [{ scale: scaleAnim }] }}>
|
|
313
|
+
<SvgIcon type="filled" name="Heart" size={32} color="#FF0000" />
|
|
314
|
+
</Animated.View>
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## Performance Tips
|
|
320
|
+
|
|
321
|
+
1. **Avoid Inline Styles**: Define styles outside of render functions
|
|
322
|
+
2. **Memoize Icon Components**: Use `React.memo` for frequently re-rendered icons
|
|
323
|
+
3. **Use Appropriate Sizes**: Stick to common sizes (16, 20, 24, 32, 48) for better caching
|
|
324
|
+
4. **Tree Shaking**: Only imported icons are included in your bundle
|
|
325
|
+
|
|
326
|
+
```tsx
|
|
327
|
+
import { memo } from 'react';
|
|
328
|
+
import { SvgIcon } from '@shaquillehinds/react-native-svg-icons';
|
|
329
|
+
|
|
330
|
+
const MemoizedIcon = memo(SvgIcon);
|
|
331
|
+
|
|
332
|
+
// Use MemoizedIcon for better performance
|
|
333
|
+
<MemoizedIcon type="filled" name="Heart" size={24} color="#FF0000" />;
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Troubleshooting
|
|
337
|
+
|
|
338
|
+
### Icons not displaying
|
|
339
|
+
|
|
340
|
+
1. Ensure `react-native-svg` is properly installed and linked
|
|
341
|
+
2. For iOS, run `pod install` in the ios directory
|
|
342
|
+
3. Rebuild your app after installation
|
|
343
|
+
|
|
344
|
+
### TypeScript errors with icon names
|
|
345
|
+
|
|
346
|
+
1. Ensure you're using the correct icon name (check the available icons list)
|
|
347
|
+
2. Verify the icon exists for the specified type (`filled` or `outline`)
|
|
348
|
+
3. Update your TypeScript version if you see unexpected errors
|
|
349
|
+
|
|
350
|
+
### Size or color not applying
|
|
351
|
+
|
|
352
|
+
1. Verify you're passing valid numeric values for `size`
|
|
353
|
+
2. Ensure color values are valid CSS color strings
|
|
354
|
+
3. Check if parent components are overriding styles
|
|
355
|
+
|
|
356
|
+
## Contributing
|
|
357
|
+
|
|
358
|
+
Contributions are welcome! Please ensure:
|
|
359
|
+
|
|
360
|
+
- Icons follow the existing naming convention
|
|
361
|
+
- Both filled and outline variants are provided
|
|
362
|
+
- Types are auto-generated using the provided scripts
|
|
363
|
+
- Examples are updated if adding new categories
|
|
364
|
+
|
|
365
|
+
## License
|
|
366
|
+
|
|
367
|
+
MIT
|
|
368
|
+
|
|
369
|
+
## Credits
|
|
370
|
+
|
|
371
|
+
Icons curated and optimized for React Native. Built with TypeScript, VueSax and `react-native-svg`.
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
**Made with ❤️ for the React Native community**
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@shaquillehinds/react-native-svg-icons",
|
|
3
3
|
"description": "React Native SVG Icons",
|
|
4
4
|
"author": "Shaquille Hinds <shaqdulove@gmail.com> (https://github.com/shaquillehinds)",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.2",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"source": "./src/index.tsx",
|
|
8
8
|
"main": "./lib/commonjs/index.js",
|