@avent-ui/page-transition
Version:
Page Transition with React Router Dom
61 lines (45 loc) • 1.8 kB
Markdown
The **Page Transition** context allows for easier implementation of page transition with **react-router-dom**. Pass the transition animation as a composite component in the TransitionProp
```jsx
npm install @avent-ui/page-transition
```
AventUI is built on top of Tailwind CSS, so you need to install Tailwind CSS first. You can follow the official [installation guide](https://tailwindcss.com/docs/installation) to install Tailwind CSS. Then you need to add the following code to your tailwind.config.js file:
```jsx
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
// make sure it's pointing to the ROOT node_module
"./node_modules/@avent-ui/magneto/dist/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
};
```
```jsx
import { PageTransitionContext } from "@avent-ui/magneto";
```
Make sure to add **Key** and **location** to your Routes in order to let the context understand the Componenet Tree Structure
```jsx
const location = useLocation();
return (
<PageTransitionContext>
<Routes key={location.pathname} location={location}>
<Route path="/" element={<App />} />
<Route path="home" element={<Home />} />
</Routes>
</PageTransitionContext>
);
```
| Prop | Type | Description | Default |
| ---------------- | :-------------------: | ----------------------- | ---------------: |
| `TransitionProp` | `Composite ReactNode` | Type Of Page Transition | SimpleTransition |