Helper for creating tappable components.
npm install taplyHelper for creating tappable components.
It allows to handle pressed, hovered and focused states consistently
across different input methods - mouse, touch and keyboard.
- Fixes sticky hover and pressed state for touch
- Prevents focus when using mouse and touch, but still allows to focus using keyboard
```
npm install taply
`js
import Taply from 'taply'
const tappableElement = (
onChangeTapState={tapState => {
// tapState is an object with keys 'isHovered', 'isPressed' and 'isFocused'
this.setState(tapState)
}}
>
// Any component can be a child (React components should forward ref to inner DOM-element)
const tappableComponent = (
)
// Also, you can use function that takes tapState and returns element
const tappableFn = (
{(tapState, ref) => (
Tap me
)}
)
`
Tap state is an object with following properties:
isHovered, isPressed and isFocused.$3
Type: (event) => voidTap event handler.
$3
Type: (tapState) => voidHandler of state changes.
$3
Type: (tap: object) => void$3
Type: (tap: object) => void$3
Type: (event: object) => voidFocus event handler.
$3
Type: (event: object) => voidBlur event handler.
$3
Type: boolDisables events handling.
$3
Type: bool
Default: true$3
Type: string|number
Default: 0HTML
tabindex attribute.$3
Type: bool
Default: true$3
Type: bool
Default: trueTaply sets
tabIndex and disabled attributes on the html-element.
When you have multiple nested Taply` components, it is ambigious which one