Skip to content

Pressable example

Pressable shares the same press state machine across every adapter. They only differ in how they expose the transient pressed state to children, and in Angular’s case, that its press events are a real @Output().

import './Pressable.css';
import { Pressable, Text } from '@symbiote-native/react';
export function PressableLabel() {
return (
<Pressable onPress={() => console.log('pressed')}>
{({ pressed }) => (
<Text className={pressed ? 'down' : 'up'}>{pressed ? 'Release' : 'Press me'}</Text>
)}
</Pressable>
);
}
Pressable.css
.up { opacity: 1; }
.down { opacity: 0.55; }

React uses children: (state) => ReactNode. Vue uses a scoped default slot: v-slot="{ pressed }". Svelte uses a parameterized named snippet prop: {#snippet children({ pressed })} — Svelte has no bind: sugar for a component prop like this, so the snippet is the whole mechanism, not shorthand over something more explicit. Angular has no scoped-slot equivalent for <ng-content>, so a consumer tracks pressed itself off the real (pressIn)/(pressOut) @Output()s instead of receiving it from Pressable directly. All four 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.