{"id":13632614,"url":"https://github.com/bmcmahen/touchable-hook","last_synced_at":"2026-03-16T19:04:12.230Z","repository":{"id":57378365,"uuid":"184496437","full_name":"bmcmahen/touchable-hook","owner":"bmcmahen","description":"a react hook that emulates native touch behaviour for things like buttons, list items, and more","archived":false,"fork":false,"pushed_at":"2019-05-21T21:48:42.000Z","size":1144,"stargazers_count":35,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T05:18:35.922Z","etag":null,"topics":["hooks","hover","react","touch"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bmcmahen.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-01T23:49:45.000Z","updated_at":"2022-03-17T16:09:37.000Z","dependencies_parsed_at":"2022-09-26T16:41:31.444Z","dependency_job_id":null,"html_url":"https://github.com/bmcmahen/touchable-hook","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmcmahen%2Ftouchable-hook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmcmahen%2Ftouchable-hook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmcmahen%2Ftouchable-hook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmcmahen%2Ftouchable-hook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmcmahen","download_url":"https://codeload.github.com/bmcmahen/touchable-hook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248824693,"owners_count":21167345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hooks","hover","react","touch"],"created_at":"2024-08-01T22:03:08.869Z","updated_at":"2026-03-16T19:04:12.202Z","avatar_url":"https://github.com/bmcmahen.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \n# touchable-hook\n  \n[![npm package](https://img.shields.io/npm/v/touchable-hook/latest.svg)](https://www.npmjs.com/package/touchable-hook)\n[![Follow on Twitter](https://img.shields.io/twitter/follow/benmcmahen.svg?style=social\u0026logo=twitter)](\nhttps://twitter.com/intent/follow?screen_name=benmcmahen\n)\n\n\u003c/div\u003e\n\n`touchable-hook` provides a react hook that emulates native touch behaviour for building performant, customizable interactive widgets like buttons, list items, etc. It's a limited implementation of the touchable interface found in [react-native-web](https://github.com/necolas/react-native-web/). It provides the basic touchable behaviour for [Sancho-UI](https://github.com/bmcmahen/sancho) and is built using [react-gesture-responder](https://github.com/bmcmahen/react-gesture-responder).\n\n## Why?\n\nWhen building mobile web apps it's challenging to get interactive elements to **feel** just right. Using this hook makes it easier:\n\n- **hover state is provided only when using a mouse**.\n- **active state is available after a configurable delay**. This is useful for avoiding highlighting list elements when scrolling, but providing immediate visual feedback on elements like buttons.\n- **mouse and touch support**.\n- **keyboard support** which emulates both button and anchor behaviour.\n- **long press support**\n\n## Install\n\nInstall both `touchable-hook` and `react-gesture-responder` using yarn or npm.\n\n```\nyarn add touchable-hook react-gesture-responder\n```\n\n```js\nimport { useTouchable } from \"touchable-hook\";\n\nfunction TouchableHighlight({ onPress, onLongPress }) {\n  const { bind, active, hover } = useTouchable({\n    onPress,\n    onLongPress,\n    behavior: \"button\" // or 'link'\n  });\n\n  return (\n    \u003cdiv role=\"button\" tabIndex={0} {...bind}\u003e\n      This is a touchable highlight\n    \u003c/div\u003e\n  );\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmcmahen%2Ftouchable-hook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmcmahen%2Ftouchable-hook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmcmahen%2Ftouchable-hook/lists"}