Pressable

Access hover, pressed, and focus events for flexible, customizable button alternatives.
Installation
API Reference
Important Note
This is the documentation for gluestack-ui v2 (beta). For @gluestack-ui/themed (stable) documentation, refer to gluestack-ui v1.
This is an illustration of Pressable component.
<Pressable onPress={() => console.log("Hello")} className="p-5 bg-primary-500">
<Text className="text-typography-0">Press me</Text>
</Pressable>

Installation

Run the following command:

npx gluestack-ui add pressable

API Reference

To use this component in your project, include the following import statement in your file.
import { Pressable } from "@/components/ui/pressable"
export default () => <Pressable />

Component Props

This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.

Pressable

It inherits all the properties of React Native's Pressable component.

Examples

The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.

Pressable child elements according to its states

You can change the child elements according to the states of Pressable component.
<Pressable className="p-16 bg-primary-500">
{({ pressed }) => (
<Text className={pressed ? "text-pink-400" : "text-amber-400"}>
PRESSABLE
</Text>
)}
</Pressable>
Similarly, you can change the child elements according to other states of Pressable component and i.e. focus , hover , pressed , disabled and focusVisible.