import { Text } from 'react-native';
import {
SpatialNavigationRoot,
SpatialNavigationView,
SpatialNavigationFocusableView,
SpatialNavigationDeviceTypeProvider,
} from 'react-native-cross-elements';
export default function Example() {
return (
<SpatialNavigationDeviceTypeProvider>
<SpatialNavigationRoot>
{/* Row of focusable cards */}
<SpatialNavigationView direction="horizontal">
{['Card A', 'Card B', 'Card C'].map((label) => (
<SpatialNavigationFocusableView
key={label}
onSelect={() => console.log('selected', label)}
style={{ margin: 8, padding: 20, borderRadius: 12 }}
>
{({ isFocused }) => (
<Text
style={{
color: isFocused ? '#fff' : '#a1a1aa',
backgroundColor: isFocused ? '#6366f1' : '#18181b',
padding: 16,
borderRadius: 10,
}}
>
{label}
</Text>
)}
</SpatialNavigationFocusableView>
))}
</SpatialNavigationView>
</SpatialNavigationRoot>
</SpatialNavigationDeviceTypeProvider>
);
}