Skip to content

Commit aeaef39

Browse files
committed
Rename to Touchable
1 parent 46eba22 commit aeaef39

3 files changed

Lines changed: 41 additions & 37 deletions

File tree

packages/docs-gesture-handler/docs/components/clickable.mdx renamed to packages/docs-gesture-handler/docs/components/touchable.mdx

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,83 @@
11
---
2-
id: clickable
3-
title: Clickable
4-
sidebar_label: Clickable
2+
id: touchable
3+
title: Touchable
4+
sidebar_label: Touchable
55
---
66

77
import HeaderWithBadges from '@site/src/components/HeaderWithBadges';
88

9-
`Clickable` is a versatile new component introduced in Gesture Handler 3 to supersede previous button implementations. Designed for maximum flexibility, it provides a highly customizable interface for native touch handling while ensuring consistent behavior across platforms.
9+
:::note
10+
This section refers to new `Touchable` component, meant to replace both buttons and touchables. If you are looking for documentation for the deprecated touchable components, check out the [Legacy Touchables](/docs/components/legacy-touchables) section.
11+
:::
1012

11-
`Clickable` provides a simple interface for the common animations like opacity, underlay, and scale, implemented entirely on the platform. On Android, it also exposes the native ripple effect on press (turned off by default).
13+
`Touchable` is a versatile new component introduced in Gesture Handler 3 to supersede previous button implementations. Designed for maximum flexibility, it provides a highly customizable interface for native touch handling while ensuring consistent behavior across platforms.
1214

13-
If the provided animations are not sufficient, it's possible to use `Clickable` to create fully custom interactions using either [Reanimated](https://docs.swmansion.com/react-native-reanimated/) or [Animated API](https://reactnative.dev/docs/animated).
15+
`Touchable` provides a simple interface for the common animations like opacity, underlay, and scale, implemented entirely on the platform. On Android, it also exposes the native ripple effect on press (turned off by default).
16+
17+
If the provided animations are not sufficient, it's possible to use `Touchable` to create fully custom interactions using either [Reanimated](https://docs.swmansion.com/react-native-reanimated/) or [Animated API](https://reactnative.dev/docs/animated).
1418

1519
## Replacing old buttons
1620

17-
If you were using `RectButton` or `BorderlessButton` in your app, you should replace them with `Clickable`. Check out the full code in the [example](#example) section below.
21+
If you were using `RectButton` or `BorderlessButton` in your app, you should replace them with `Touchable`. Check out the full code in the [example](#example) section below.
1822

1923
### RectButton
2024

21-
To replace `RectButton` with `Clickable`, simply add `activeUnderlayOpacity={0.105}` to your `Clickable`. This will animate the underlay when the button is pressed.
25+
To replace `RectButton` with `Touchable`, simply add `activeUnderlayOpacity={0.105}` to your `Touchable`. This will animate the underlay when the button is pressed.
2226

2327
```tsx
24-
<Clickable
28+
<Touchable
2529
...
2630
activeUnderlayOpacity={0.105}/>
2731
```
2832

2933
### BorderlessButton
3034

31-
Replacing `BorderlessButton` with `Clickable` is as easy as replacing `RectButton`. Just add `activeOpacity={0.3}` to your `Clickable`. This will animate the whole component when the button is pressed.
35+
Replacing `BorderlessButton` with `Touchable` is as easy as replacing `RectButton`. Just add `activeOpacity={0.3}` to your `Touchable`. This will animate the whole component when the button is pressed.
3236

3337
```tsx
34-
<Clickable
38+
<Touchable
3539
...
3640
activeOpacity={0.3}/>
3741
```
3842

3943
## Replacing deprecated Touchables
4044

41-
If you were using the deprecated [`Touchable`](/docs/components/touchables) components, you can replace them with `Clickable` as well.
45+
If you were using the deprecated [`Touchables`](/docs/components/touchables), you can replace them with new `Touchable` as well.
4246

4347
### TouchableOpacity
4448

45-
To replace `TouchableOpacity` with `Clickable`, add `activeOpacity={0.2}`.
49+
To replace `TouchableOpacity` with `Touchable`, add `activeOpacity={0.2}`.
4650

4751
```tsx
48-
<Clickable
52+
<Touchable
4953
...
5054
activeOpacity={0.2}/>
5155
```
5256

5357
### TouchableHighlight
5458

55-
To replace `TouchableHighlight` with `Clickable`, add `activeUnderlayOpacity={1}`.
59+
To replace `TouchableHighlight` with `Touchable`, add `activeUnderlayOpacity={1}`.
5660

5761
```tsx
58-
<Clickable
62+
<Touchable
5963
...
6064
activeUnderlayOpacity={1}/>
6165
```
6266

6367
### TouchableWithoutFeedback
6468

65-
To replace `TouchableWithoutFeedback`, use a plain `Clickable`.
69+
To replace `TouchableWithoutFeedback`, use a plain `Touchable`.
6670

6771
```tsx
68-
<Clickable ... />
72+
<Touchable ... />
6973
```
7074

7175
### TouchableNativeFeedback
7276

7377
To replace `TouchableNativeFeedback`, use the [`androidRipple`](#androidripple) prop. Make sure to set `foreground={true}`.
7478

7579
```tsx
76-
<Clickable
80+
<Touchable
7781
...
7882
androidRipple={{
7983
foreground: true,
@@ -82,7 +86,7 @@ To replace `TouchableNativeFeedback`, use the [`androidRipple`](#androidripple)
8286

8387
## Example
8488

85-
In this example we will demonstrate how to recreate `RectButton` and `BorderlessButton` effects using the `Clickable` component.
89+
In this example we will demonstrate how to recreate `RectButton` and `BorderlessButton` effects using the `Touchable` component.
8690

8791
<CollapsibleCode
8892
label="Show full example"
@@ -93,37 +97,37 @@ import React from 'react';
9397
import { StyleSheet, Text } from 'react-native';
9498
import {
9599
GestureHandlerRootView,
96-
Clickable,
100+
Touchable,
97101
} from 'react-native-gesture-handler';
98102
99-
export default function ClickableExample() {
103+
export default function TouchableExample() {
100104
return (
101105
<GestureHandlerRootView style={styles.container}>
102-
<Clickable
106+
<Touchable
103107
onPress={() => {
104-
console.log('BaseButton built with Clickable');
108+
console.log('BaseButton built with Touchable');
105109
}}
106110
style={[styles.button, { backgroundColor: '#7d63d9' }]}>
107111
<Text style={styles.buttonText}>BaseButton</Text>
108-
</Clickable>
112+
</Touchable>
109113
110-
<Clickable
114+
<Touchable
111115
onPress={() => {
112-
console.log('RectButton built with Clickable');
116+
console.log('RectButton built with Touchable');
113117
}}
114118
style={[styles.button, { backgroundColor: '#4f9a84' }]}
115119
activeUnderlayOpacity={0.105}>
116120
<Text style={styles.buttonText}>RectButton</Text>
117-
</Clickable>
121+
</Touchable>
118122
119-
<Clickable
123+
<Touchable
120124
onPress={() => {
121-
console.log('BorderlessButton built with Clickable');
125+
console.log('BorderlessButton built with Touchable');
122126
}}
123127
style={[styles.button, { backgroundColor: '#5f97c8' }]}
124128
activeOpacity={0.3}>
125129
<Text style={styles.buttonText}>BorderlessButton</Text>
126-
</Clickable>
130+
</Touchable>
127131
</GestureHandlerRootView>
128132
);
129133
}

packages/docs-gesture-handler/docs/components/touchables.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
id: touchables
3-
title: Touchables
4-
sidebar_label: Touchables
2+
id: legacy-touchables
3+
title: Legacy Touchables
4+
sidebar_label: Legacy Touchables
55
---
66

77
:::warning
8-
Touchables will be removed in the future version of Gesture Handler. Use [`Pressable`](/docs/components/pressable) instead.
8+
Touchables will be removed in the future version of Gesture Handler. Use [`Touchable`](/docs/components/touchable) instead.
99
:::
1010

1111
Gesture Handler library provides an implementation of RN's touchable components that are based on [native buttons](buttons.mdx) and do not rely on the JS responder system utilized by RN. Our touchable implementation follows the same API and aims to be a drop-in replacement for touchables available in React Native.

skills/gesture-handler-3-migration/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ The implementation of buttons has been updated, resolving most button-related is
170170

171171
`PureNativeButton` has been removed. If encountered, inform the user that it has been removed and let them decide how to handle that case. They can achieve similar functionality with other buttons.
172172

173-
When migrating buttons, you should use `Clickable` component instead. To replace `BaseButton` use `Clickable` with default props, to replace `RectButton` use `Clickable` with `activeUnderlayOpacity={0.105}` and to replace `BorderlessButton` use `Clickable` with `activeOpacity={0.3}`.
173+
When migrating buttons, you should use new `Touchable` component instead. To replace `BaseButton` use `Touchable` with default props, to replace `RectButton` use `Touchable` with `activeUnderlayOpacity={0.105}` and to replace `BorderlessButton` use `Touchable` with `activeOpacity={0.3}`.
174174

175-
Touchables from Gesture Handler are also deprecated and should be replaced with `Clickable`. To replace `TouchableOpacity` use `Clickable` with `activeOpacity={0.2}` and to replace `TouchableHighlight` use `Clickable` with `activeUnderlayOpacity={1}`. To replace `TouchableWithoutFeedback` use a plain `Clickable`. `TouchableNativeFeedback` can be replaced with `Clickable` by setting `androidRipple` property. At minimum, it should be set to `{foregroud: true}`, to mimic `TouchableNativeFeedback` ripple effect.
175+
Legacy Touchables (`TouchableOpacity`, `TouchableHighlight`, `TouchableWithoutFeedback`, `TouchableNativeFeedback`) from Gesture Handler are also deprecated and should be replaced with `Touchable`. To replace `TouchableOpacity` use `Touchable` with `activeOpacity={0.2}` and to replace `TouchableHighlight` use `Touchable` with `activeUnderlayOpacity={1}`. To replace `TouchableWithoutFeedback` use a plain `Touchable`. `TouchableNativeFeedback` can be replaced with `Touchable` by setting `androidRipple` property. At minimum, it should be set to `{foregroud: true}`, to mimic `TouchableNativeFeedback` ripple effect.
176176

177177
Other components have also been internally rewritten using the new hook API but are exported under their original names, so no changes are necessary on your part. However, if you need to use the previous implementation for any reason, the legacy components are also available and are prefixed with `Legacy`, e.g., `ScrollView` is now available as `LegacyScrollView`.
178178

0 commit comments

Comments
 (0)