Skip to content

Commit 5ec4572

Browse files
authored
Add icon size and position props to button (#885)
1 parent 004a778 commit 5ec4572

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

packages/core/src/components/Button.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ type BaseProps = {
3333
delayLongPress?: number;
3434
hitSlop?: number;
3535
icon?: string;
36+
iconSize?: number;
37+
iconPosition?: "left" | "right";
3638
} & PressableProps &
3739
IconSlot;
3840

@@ -55,6 +57,8 @@ type Props = {
5557
function Base({
5658
Icon,
5759
icon,
60+
iconPosition = "left",
61+
iconSize = CONSTANTS.icon,
5862
title,
5963
loading,
6064
disabled,
@@ -117,15 +121,23 @@ function Base({
117121
{loading ? (
118122
<ActivityIndicator size="small" color={color} style={styles.loading} />
119123
) : null}
120-
{icon && !loading ? (
124+
{iconPosition === "left" && icon && !loading ? (
121125
<Icon
122126
name={icon}
123127
color={color as string}
124128
style={styles.icon}
125-
size={CONSTANTS.icon}
129+
size={iconSize}
126130
/>
127131
) : null}
128132
<Text style={titleStyles}>{title}</Text>
133+
{iconPosition === "right" && icon && !loading ? (
134+
<Icon
135+
name={icon}
136+
color={color as string}
137+
style={styles.icon}
138+
size={iconSize}
139+
/>
140+
) : null}
129141
</Pressable>
130142
);
131143
}

0 commit comments

Comments
 (0)