Skip to content

Commit 6f93327

Browse files
authored
feat: all exported icon components are now suffixed with "Icon" (#76)
It's to follow @phosphor-icons/react release 2.1.8
1 parent f767d0b commit 6f93327

File tree

11 files changed

+3372
-4898
lines changed

11 files changed

+3372
-4898
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ Simply import the icons you need, and add them anywhere in your render method. P
3535
```tsx
3636
import React from 'react';
3737
import { View } from 'react-native';
38-
import { Horse, Heart, Cube } from 'phosphor-react-native';
38+
import { HorseIcon, HeartIcon, CubeIcon } from 'phosphor-react-native';
3939

4040
const App = () => {
4141
return (
4242
<View>
43-
<Horse />
44-
<Heart color="#AE2983" weight="fill" size={32} />
45-
<Cube color="teal" weight="duotone" />
43+
<HorseIcon />
44+
<HeartIcon color="#AE2983" weight="fill" size={32} />
45+
<CubeIcon color="teal" weight="duotone" />
4646
</View>
4747
);
4848
};
@@ -85,7 +85,7 @@ Phosphor takes advantage of React Context to make applying a default style to al
8585
```tsx
8686
import React from 'react';
8787
import { View } from 'react-native';
88-
import { IconContext, Horse, Heart, Cube } from 'phosphor-react-native';
88+
import { IconContext, HorseIcon, HeartIcon, CubeIcon } from 'phosphor-react-native';
8989

9090
const App = () => {
9191
return (
@@ -97,9 +97,9 @@ const App = () => {
9797
}}
9898
>
9999
<View>
100-
<Horse /> {/* I'm lime-green, 32px, and bold! */}
101-
<Heart /> {/* Me too! */}
102-
<Cube /> {/* Me three :) */}
100+
<HorseIcon /> {/* I'm lime-green, 32px, and bold! */}
101+
<HeartIcon /> {/* Me too! */}
102+
<CubeIcon /> {/* Me three :) */}
103103
</View>
104104
</IconContext.Provider>
105105
);
@@ -115,22 +115,22 @@ You may wish to import all icons at once for use in your project, though dependi
115115
```tsx
116116
import * as Icon from "phosphor-react-native";
117117
...
118-
<Icon.Smiley />
119-
<Icon.Folder weight="thin" />
120-
<Icon.BatteryHalf size="24px" />
121-
<Icon.AirplaneTakeoff size="24px" mirrored={true} />
118+
<Icon.SmileyIcon />
119+
<Icon.FolderIcon weight="thin" />
120+
<Icon.BatteryHalfIcon size="24px" />
121+
<Icon.AirplaneTakeoffIcon size="24px" mirrored={true} />
122122
```
123123

124124
In cases where tree shaking does not work (resulting in large bundle size), you can import icons individually in this format:
125125

126126
```tsx
127127
// Javascript
128-
import Star from "phosphor-react-native/lib/commonjs/icons/Star";
128+
import { StarIcon } from "phosphor-react-native/lib/commonjs/icons/Star";
129129

130130
// Typescript
131-
import Star from 'phosphor-react-native/src/icons/Star';
131+
import { StarIcon } from 'phosphor-react-native/src/icons/Star';
132132

133-
<Star size="24px" />
133+
<StarIcon size="24px" />
134134
```
135135

136136
## Related Projects

core

example/app/(tabs)/_layout.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { Tabs } from 'expo-router';
22
import React from 'react';
33

4-
import List from '@/components/icons/icons/List';
5-
import TestTube from '@/components/icons/icons/TestTube';
4+
import { ListIcon, TestTubeIcon } from '@/components/icons';
65
import { Colors } from '@/constants/Colors';
76
import { useColorScheme } from '@/hooks/useColorScheme';
87

@@ -21,7 +20,7 @@ export default function TabLayout() {
2120
options={{
2221
title: 'All icons',
2322
tabBarIcon: ({ color, focused }) => (
24-
<List weight={focused ? 'fill' : 'light'} color={color} />
23+
<ListIcon weight={focused ? 'fill' : 'light'} color={color} />
2524
),
2625
}}
2726
/>
@@ -30,7 +29,7 @@ export default function TabLayout() {
3029
options={{
3130
title: 'Test Lab',
3231
tabBarIcon: ({ color, focused }) => (
33-
<TestTube weight={focused ? 'fill' : 'light'} color={color} />
32+
<TestTubeIcon weight={focused ? 'fill' : 'light'} color={color} />
3433
),
3534
}}
3635
/>
@@ -39,7 +38,7 @@ export default function TabLayout() {
3938
options={{
4039
title: 'Single',
4140
tabBarIcon: ({ color, focused }) => (
42-
<TestTube weight={focused ? 'fill' : 'light'} color={color} />
41+
<TestTubeIcon weight={focused ? 'fill' : 'light'} color={color} />
4342
),
4443
}}
4544
/>

example/components/home.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable react-native/no-inline-styles */
21
/* eslint-disable @typescript-eslint/no-explicit-any */
32

43
import { useCallback, useState, useMemo } from 'react';
@@ -15,6 +14,8 @@ import { SafeAreaView } from 'react-native-safe-area-context';
1514
import * as IconPack from '@/components/icons';
1615
import PhosphorLogo from '@/assets/images/phosphor-mark-tight-yellow.png';
1716

17+
console.log(IconPack);
18+
1819
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1920
const { IconContext, ...Icons } = IconPack;
2021

example/components/single-imports.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable react-native/no-inline-styles */
2-
31
import { useCallback, useState } from 'react';
42

53
import {
@@ -13,12 +11,12 @@ import {
1311
} from 'react-native';
1412
import { SafeAreaView } from 'react-native-safe-area-context';
1513
import PhosphorLogo from '@/assets/images/phosphor-mark-tight-yellow.png';
16-
import Swap from '@/components/icons/icons/Swap';
17-
import Acorn from '@/components/icons/icons/Acorn';
18-
import Palette from '@/components/icons/icons/Palette';
14+
import { SwapIcon } from '@/components/icons/icons/Swap';
15+
import { AcornIcon } from '@/components/icons/icons/Acorn';
16+
import { PaletteIcon } from '@/components/icons/icons/Palette';
1917
const weights = ['thin', 'light', 'regular', 'bold', 'fill', 'duotone'];
20-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
21-
const singleIcons = [Acorn, Palette, Swap]
18+
19+
const singleIcons = [AcornIcon, PaletteIcon, SwapIcon];
2220
export default function SingleImportsScreen() {
2321
const [toggleActive, setToggleActive] = useState(false);
2422

@@ -51,7 +49,7 @@ export default function SingleImportsScreen() {
5149
</Text>
5250
</View>
5351
<TouchableOpacity style={styles.weightSelect} onPress={handleToggle}>
54-
<Swap color="#FFF" weight={'regular'} />
52+
<SwapIcon color="#FFF" weight={'regular'} />
5553
</TouchableOpacity>
5654
</View>
5755
</SafeAreaView>

example/components/test-lab.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable react-native/no-inline-styles */
2-
31
import { useCallback, useState } from 'react';
42

53
import {

example/package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,31 @@
1313
"@react-navigation/bottom-tabs": "^7.2.0",
1414
"@react-navigation/native": "^7.0.14",
1515
"@react-navigation/native-stack": "^7.2.0",
16-
"expo": "^52.0.27",
17-
"expo-constants": "~17.0.4",
18-
"expo-linking": "~7.0.4",
19-
"expo-router": "~4.0.17",
20-
"expo-splash-screen": "~0.29.21",
21-
"expo-status-bar": "~2.0.1",
22-
"expo-system-ui": "~4.0.7",
23-
"react": "18.3.1",
24-
"react-dom": "18.3.1",
25-
"react-native": "0.76.6",
26-
"react-native-gesture-handler": "~2.20.2",
27-
"react-native-reanimated": "~3.16.1",
28-
"react-native-safe-area-context": "4.12.0",
29-
"react-native-screens": "~4.4.0",
30-
"react-native-svg": "15.8.0",
31-
"react-native-web": "~0.19.13"
16+
"expo": "^53.0.0",
17+
"expo-constants": "~17.1.6",
18+
"expo-linking": "~7.1.5",
19+
"expo-router": "~5.1.0",
20+
"expo-splash-screen": "~0.30.9",
21+
"expo-status-bar": "~2.2.3",
22+
"expo-system-ui": "~5.0.9",
23+
"react": "19.0.0",
24+
"react-dom": "19.0.0",
25+
"react-native": "0.79.4",
26+
"react-native-gesture-handler": "~2.24.0",
27+
"react-native-reanimated": "~3.17.4",
28+
"react-native-safe-area-context": "5.4.0",
29+
"react-native-screens": "~4.11.1",
30+
"react-native-svg": "15.11.2",
31+
"react-native-web": "^0.20.0"
3232
},
3333
"devDependencies": {
3434
"@babel/core": "^7.24.0",
3535
"@eslint/js": "^9.9.0",
36-
"@types/react": "~18.3.12",
36+
"@types/react": "~19.0.10",
3737
"eslint": "9.x",
3838
"eslint-plugin-react": "^7.35.0",
3939
"globals": "^15.9.0",
40-
"typescript": "~5.3.3",
40+
"typescript": "~5.8.3",
4141
"typescript-eslint": "^8.0.1"
4242
},
4343
"private": true

0 commit comments

Comments
 (0)