base-ui icon indicating copy to clipboard operation
base-ui copied to clipboard

[docs] Tabs examples with motion

Open mj12albert opened this issue 8 months ago • 1 comments

https://github.com/mui/base-ui/issues/1494 https://github.com/mui/base-ui/issues/1486

Demo: https://deploy-preview-1613--base-ui.netlify.app/experiments/tabs/motion

  • Used mode="wait" on AnimatePresence, the entering child waits until the exiting child has animated out, other modes should be possible, though extra display/positioning styles would be required (set via motion) to prevent overlap: Screenshot 2025-03-29 at 1 41 42 AM (3)
  • If using Tailwind v4, setting hidden={undefined} on Tabs.Panel is required to ensure the panel is visible during the exit animation (same workaround as Collapsible)
  • Replicating the indicator transition from the docs styles with motion turns out to be tricker than the panel, it can't seem to transition the same CSS variable that changes value:
// doesn't work even with the entries repeated in `initial`/`exit`
<Tabs.Indicator render={
  <motion.div
    animate={{
      translate: 'var(--active-tab-left) -50%',
      width: 'var(--active-tab-width)',
    }}
  />
}

mj12albert avatar Mar 28 '25 16:03 mj12albert

Deploy Preview for base-ui ready!

Name Link
Latest commit 6692c292c2585175c14080a0c62afe562c1c22bb
Latest deploy log https://app.netlify.com/sites/base-ui/deploys/67ebb9e814ff670008af9c57
Deploy Preview https://deploy-preview-1613--base-ui.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Mar 28 '25 16:03 netlify[bot]

Closing this since motion has examples now

mj12albert avatar Sep 05 '25 14:09 mj12albert