Skip to Content

Selectable

A versatile wrapper that catches types of touches. It listens to Kivy touch events and triggers corresponding callbacks. While being hovered, a selectable will have a white inner shadow, then when the component has been successfully touched it will have an inner shadow corresponding to the type of touch, blue for primary, green for secondary and yellow for tertiary.

Import

import { Selectable } from 'kivy-hub/core';

Props

PropTypeDefaultDescription
enabledbooleantrueWhether the component accepts interaction events.
childrenReactNodeThe child components to render inside the selectable container.
refRefObject<HTMLDivElement>Optional ref to the root div element.
onPrimaryPress(e: TouchEvent) => voidCallback for primary-touch-down after delay.
onSecondaryPress(e: TouchEvent) => voidCallback for secondary-touch-down after delay.
onTertiaryPress(e: TouchEvent) => voidCallback for tertiary-touch-down after delay.
onPrimaryRelease(e: TouchEvent) => voidCallback for primary-touch-up if it matched the previous press.
onSecondaryRelease(e: TouchEvent) => voidCallback for secondary-touch-up if it matched the previous press.
onTertiaryRelease(e: TouchEvent) => voidCallback for tertiary-touch-up if it matched the previous press.
delaynumber500Delay in ms before a press event triggers.
forceSelectboolean(Unused in current code, reserved for future extension.)
stopPropagationbooleanfalseWhether to stop propagation of custom events.
showFeedbackbooleantrueWhether to show visual feedback (colored glow) during interaction.
…propsHTMLAttributes<HTMLDivElement>Any other valid div props (e.g., className, id, etc).

Usage

<Selectable onPrimaryPress={(e) => console.log('Primary pressed!', e)} onPrimaryRelease={(e) => console.log('Primary released!', e)} delay={300} > <div className="w-32 h-32 bg-gray-300">Touch Me</div> </Selectable>
Last updated on