{"id":50217935,"url":"https://github.com/gfazioli/react-flip","last_synced_at":"2026-05-26T10:02:23.168Z","repository":{"id":358462470,"uuid":"1127708857","full_name":"gfazioli/react-flip","owner":"gfazioli","description":"A React component that wraps any two faces and animates a 3D rotation between them. Themeable via CSS variables, zero runtime dependencies, ~2 KB gzipped, TypeScript-first.","archived":false,"fork":false,"pushed_at":"2026-05-17T15:28:04.000Z","size":3655,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-17T15:43:32.994Z","etag":null,"topics":["3d","animation","card","css-modules","flip","react","react-component","transition","typescript"],"latest_commit_sha":null,"homepage":"https://gfazioli.github.io/react-flip/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gfazioli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"gfazioli"}},"created_at":"2026-01-04T12:50:18.000Z","updated_at":"2026-05-17T15:28:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/gfazioli/react-flip","commit_stats":null,"previous_names":["gfazioli/react-flip"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/gfazioli/react-flip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfazioli%2Freact-flip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfazioli%2Freact-flip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfazioli%2Freact-flip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfazioli%2Freact-flip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gfazioli","download_url":"https://codeload.github.com/gfazioli/react-flip/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfazioli%2Freact-flip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33514912,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T03:12:49.672Z","status":"ssl_error","status_checked_at":"2026-05-26T03:12:47.976Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["3d","animation","card","css-modules","flip","react","react-component","transition","typescript"],"created_at":"2026-05-26T10:02:17.812Z","updated_at":"2026-05-26T10:02:23.159Z","avatar_url":"https://github.com/gfazioli.png","language":"TypeScript","funding_links":["https://github.com/sponsors/gfazioli"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"./assets/logo.svg\" alt=\"\" width=\"240\" /\u003e\n\n# @gfazioli/react-flip\n\n**Two faces, one component. A 3D-rotation flip for React.**\n\n[![npm version](https://img.shields.io/npm/v/@gfazioli/react-flip?style=flat-square\u0026color=8b5cf6)](https://www.npmjs.com/package/@gfazioli/react-flip)\n[![bundle size](https://img.shields.io/bundlephobia/minzip/@gfazioli/react-flip?style=flat-square\u0026label=gzip\u0026color=8b5cf6)](https://bundlephobia.com/package/@gfazioli/react-flip)\n[![types](https://img.shields.io/npm/types/@gfazioli/react-flip?style=flat-square\u0026color=8b5cf6)](https://www.npmjs.com/package/@gfazioli/react-flip)\n[![downloads](https://img.shields.io/npm/dm/@gfazioli/react-flip?style=flat-square\u0026color=8b5cf6)](https://www.npmjs.com/package/@gfazioli/react-flip)\n[![license](https://img.shields.io/npm/l/@gfazioli/react-flip?style=flat-square\u0026color=8b5cf6)](./LICENSE)\n\n[**Live playground →**](https://gfazioli.github.io/react-flip/) ・\n[**Changelog**](./CHANGELOG.md)\n\n\u003c/div\u003e\n\n\u003cbr/\u003e\n\n\u003e Wrap any two faces and animate a 3D rotation between them. Themeable via CSS variables, controlled or uncontrolled, zero runtime dependencies, ~2 KB gzipped.\n\n- 🃏 **Two faces, one prop** — drop any two children inside `\u003cFlip\u003e`. Use `\u003cFlip.Target\u003e` to wire any element as a click trigger.\n- 🎛️ **Tunable** — `perspective`, `duration`, `easing`, `direction`, plus separate `directionFlipIn` / `directionFlipOut` for one-way coin-flip rotations.\n- 🎨 **Themeable via CSS variables** — every prop is mirrored as a `--rfp-*` custom property; override on any selector.\n- 📦 **Zero runtime dependencies** — only React as a peer dependency.\n- 🪶 **Tiny** — ~2 KB ESM gzipped, tree-shakeable, dual ESM + CJS.\n- ⌨️ **TypeScript-first** — full type declarations included.\n- ♿ **Reduced-motion aware** — respects `prefers-reduced-motion`.\n\n## Install\n\n```bash\nnpm install @gfazioli/react-flip\n# or\npnpm add @gfazioli/react-flip\n# or\nyarn add @gfazioli/react-flip\n```\n\nRequires React 18 or newer.\n\n## Usage\n\n```tsx\nimport { Flip } from \"@gfazioli/react-flip\";\nimport \"@gfazioli/react-flip/styles.css\";\n\nexport function Card() {\n  return (\n    \u003cFlip\u003e\n      \u003cFrontFace /\u003e\n      \u003cBackFace\u003e\n        \u003cFlip.Target\u003e\n          \u003cbutton type=\"button\"\u003eDone\u003c/button\u003e\n        \u003c/Flip.Target\u003e\n      \u003c/BackFace\u003e\n    \u003c/Flip\u003e\n  );\n}\n```\n\nThe stylesheet must be imported once in your app (root layout, entry file, or wherever you prefer). The component expects **exactly two children** — the first is the front, the second is the back.\n\n### Controlled\n\n```tsx\nconst [open, setOpen] = useState(false);\n\n\u003cFlip flipped={open} onChange={setOpen}\u003e\n  \u003cFront /\u003e\n  \u003cBack /\u003e\n\u003c/Flip\u003e;\n```\n\n### Uncontrolled with Flip.Target\n\n`Flip.Target` clones its single child element and wires `onClick` to toggle the flip — preserving any existing `onClick` you passed.\n\n```tsx\n\u003cFlip defaultFlipped={false} onChange={(next) =\u003e console.log(\"flipped:\", next)}\u003e\n  \u003carticle\u003e\n    \u003ch2\u003eFront\u003c/h2\u003e\n    \u003cFlip.Target\u003e\n      \u003cbutton type=\"button\"\u003eShow specs\u003c/button\u003e\n    \u003c/Flip.Target\u003e\n  \u003c/article\u003e\n  \u003carticle\u003e\n    \u003ch2\u003eBack\u003c/h2\u003e\n    \u003cFlip.Target\u003e\n      \u003cbutton type=\"button\"\u003eBack\u003c/button\u003e\n    \u003c/Flip.Target\u003e\n  \u003c/article\u003e\n\u003c/Flip\u003e\n```\n\n### Vertical flip\n\n```tsx\n\u003cFlip direction=\"vertical\"\u003e\n  \u003cFront /\u003e\n  \u003cBack /\u003e\n\u003c/Flip\u003e\n```\n\n### Coin flip (one-way rotation)\n\nBy default the component reverses the rotation direction when flipping back. Set `directionFlipIn` and `directionFlipOut` to the same value to keep spinning the same way:\n\n```tsx\n\u003cFlip directionFlipIn=\"negative\" directionFlipOut=\"negative\"\u003e\n  \u003cFront /\u003e\n  \u003cBack /\u003e\n\u003c/Flip\u003e\n```\n\n## Theming\n\nThree properties are mirrored as CSS custom properties on the root element. Override them on any selector to theme one boundary, a section, or the whole app:\n\n```css\n.my-card {\n  --rfp-perspective: 1400px;\n  --rfp-duration: 1.2s;\n  --rfp-easing: cubic-bezier(0.5, -0.25, 0.5, 1.4);\n}\n```\n\n| Variable | Default | Equivalent prop |\n|---|---|---|\n| `--rfp-perspective` | `1000px` | `perspective` |\n| `--rfp-duration` | `0.8s` | `duration` (number, in seconds) |\n| `--rfp-easing` | `ease-in-out` | `easing` |\n\n`direction` and the `directionFlipIn`/`directionFlipOut` pair are **not** exposed as CSS variables — they drive the rotation math directly because the back face must be pre-rotated on the inverse axis.\n\n## Props\n\n### `\u003cFlip\u003e`\n\n| Prop | Type | Default | Description |\n|---|---|---|---|\n| `children` | `[ReactNode, ReactNode]` | — | Exactly two children. First is front, second is back. |\n| `flipped` | `boolean` | — | Controlled flipped state. |\n| `defaultFlipped` | `boolean` | `false` | Uncontrolled initial state. |\n| `onChange` | `(flipped: boolean) =\u003e void` | — | Fires with the new boolean value on each flip. |\n| `onBack` | `() =\u003e void` | — | Fires when the back face becomes visible. |\n| `onFront` | `() =\u003e void` | — | Fires when the front face becomes visible. |\n| `perspective` | `string` | `\"1000px\"` | CSS perspective for the 3D rotation. |\n| `duration` | `number` | `0.8` | Animation duration, in **seconds**. |\n| `easing` | `CSS transitionTimingFunction` | `\"ease-in-out\"` | Easing function. |\n| `direction` | `\"horizontal\" \\| \"vertical\"` | `\"horizontal\"` | Rotation axis (Y for horizontal, X for vertical). |\n| `directionFlipIn` | `\"positive\" \\| \"negative\"` | `\"negative\"` | Rotation sign when showing the back. |\n| `directionFlipOut` | `\"positive\" \\| \"negative\"` | `\"positive\"` | Rotation sign when showing the front. |\n| `className`, `style` | — | — | Applied to the root wrapper. |\n\n`forwardRef` returns the underlying `HTMLDivElement`.\n\n### `\u003cFlip.Target\u003e`\n\n| Prop | Type | Description |\n|---|---|---|\n| `children` | `ReactElement` | A single React element. Strings, numbers, fragments, and arrays are not supported. |\n\nThe clone receives a `data-flipped` attribute mirroring the current state (useful for CSS styling), and an `onClick` that toggles the flip while preserving the original handler.\n\n## Other Undolog components\n\nSmall, accessible React components — same philosophy, same toolchain, zero runtime dependencies:\n\n- **[react-toggle-component](https://gfazioli.github.io/react-toggle/)** — an accessible toggle/switch with CSS-variable theming. ([npm](https://www.npmjs.com/package/react-toggle-component) · [GitHub](https://github.com/gfazioli/react-toggle))\n- **[react-amiga-guru-meditation](https://gfazioli.github.io/react-amiga-guru-meditation/)** — an error boundary that renders the iconic Amiga Guru Meditation screen. ([npm](https://www.npmjs.com/package/react-amiga-guru-meditation) · [GitHub](https://github.com/gfazioli/react-amiga-guru-meditation))\n- **[@gfazioli/react-tilt](https://gfazioli.github.io/react-tilt/)** — interactive 3D tilt cards with parallax, glare, light, shadow, gyroscope, and spring physics. ([npm](https://www.npmjs.com/package/@gfazioli/react-tilt) · [GitHub](https://github.com/gfazioli/react-tilt))\n\n## License\n\nMIT — © Giovambattista Fazioli\n\n## Sponsor\n\nIf this project saves you time, consider [sponsoring on GitHub](https://github.com/sponsors/gfazioli) — it directly supports continued maintenance and new releases.\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/sponsors/gfazioli\"\u003e\n    \u003cimg src=\"https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=%23fe8e86\" alt=\"Sponsor on GitHub\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgfazioli%2Freact-flip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgfazioli%2Freact-flip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgfazioli%2Freact-flip/lists"}