Skip to content

Pressable example

pressable shares the same press state machine across every adapter, and on all five it is a bare host tag — there is no component body to call a children render function, so pressed never arrives that way. Every adapter mirrors it into its own local state off onPressIn/onPressOut instead. Angular’s press events are a real @Output().

import './Pressable.css';
import { useState } from 'react';
export function PressableLabel() {
const [pressed, setPressed] = useState(false);
return (
<pressable
onPress={() => console.log('pressed')}
onPressIn={() => setPressed(true)}
onPressOut={() => setPressed(false)}
>
<text className={pressed ? 'down' : 'up'}>{pressed ? 'Release' : 'Press me'}</text>
</pressable>
);
}
Pressable.css
.up { opacity: 1; }
.down { opacity: 0.55; }

React is the only adapter where pressable still exposes state through a children render function, children: (state) => ReactNode. The pressable tag on Vue, Angular, Svelte, and Solid has no render-prop channel for its children, so each one instead reads onPressIn/onPressOut directly and mirrors pressed into its own local reactive state, then derives a class or style from that: Vue’s @press-in/@press-out, Angular’s (pressIn)/(pressOut) @Output()s, Solid’s onPressIn/onPressOut props setting a signal, and Svelte’s onPressIn/onPressOut inside the p={{ … }} bag every event handler on a bare host tag needs. All five still read from the same shared press state machine underneath. StyleSheet.create works identically to a CSS class if you’d rather keep style objects inline — see the Styling guide.