Slide
A slide is a dynamic element that transitions in from the edges of the screen, typically used to present content in an engaging way. The direction prop controls which of the screen the transition starts from.
import {QSlide} from "@qui/react"
Examples
Showcase
The component's mountOnEnter prop prevents the child component from being mounted until in is true. This prevents the relatively positioned component from scrolling into view from its off-screen position. Similarly, the unmountOnExit prop removes the component from the DOM after it has been transition off-screen.
import {ReactNode, useState} from "react"import {ThumbsUp} from "lucide-react"import {QButton, QIcon, QSlide} from "@qui/react"export default function Showcase(): ReactNode {const [show, setShow] = useState(false)const toggle = () => {setShow((prevState) => !prevState)}return (<div className="grid justify-center"><div className="flex h-[180px] flex-col items-center"><QButton className="mb-4" onClick={toggle} variant="outline">{show ? "Hide" : "Show"}</QButton><QSlide direction="up" in={show} mountOnEnter unmountOnExit><QIcon icon={ThumbsUp} size="xl" /></QSlide></div></div>)}
API
Props
This component extends the Transition
component from react-transition-group.
Name & Description | Option(s) | Default |
---|---|---|
React Children |
| |
Direction the child node will enter from. |
| |
Add a custom transition end trigger. Called with the transitioning DOM
node and a done callback. Allows for more fine-grained transition end
logic. Note: Timeouts are still used as a fallback if provided. |
| |
Whether to show the animation when the component is first mounted. |
| |
Class applied to the root element. |
| |
An HTML element, or a function that returns one.
It's used to set the container the Slide is transitioning from. |
| |
The transition timing function. You may specify a single easing or an object
containing independent values for enter and exit. |
| |
Show the component; triggers the enter or exit states |
| |
By default, the child component is mounted immediately along with the
parent Transition component. If you want to "lazy mount" the component on
the first in = true you can set mountOnEnter. After the
first enter transition the component will stay mounted, even on "exited",
unless you also specify unmountOnExit. |
| |
A React reference to DOM element that need to transition. example.
When nodeRef prop is used, node is not passed to callback functions (e.g.
onEnter) because user already has direct access to the node. When changing
key prop of Transition in a TransitionGroup a new nodeRef needs to be
provided to Transition with changed key prop. see also. |
| |
Callback fired before the "entering" status is applied. An extra
parameter isAppearing is supplied to indicate if the enter stage is
occurring on the initial mount |
| |
Callback fired after the "entered" status is applied. An extra parameter
isAppearing is supplied to indicate if the enter stage is occurring on
the initial mount |
| |
Callback fired after the "entering" status is applied. An extra parameter
isAppearing is supplied to indicate if the enter stage is occurring on
the initial mount |
| |
Callback fired before the "exiting" status is applied. |
| |
Callback fired after the "exited" status is applied. |
| |
Callback fired after the "exiting" status is applied. |
| |
Inline styles | CSSProperties | |
The duration of the transition, in milliseconds. Required unless
addEndListener is provided. You may specify a single timeout for all transitions:
or individually:
appear defaults to the value of enter .
enter defaults to 0 .
exit defaults to 0 . |
| |
By default, the child component stays mounted after it reaches the
'exited' state. Set unmountOnExit if you'd prefer to unmount the
component after it finishes exiting. |
|
Type
ReactElement
Description
React Children
Type
| 'down'| 'left'| 'up'| 'right'
Description
Direction the child node will enter from.
Type
(node: HTMLElement | object,done: () => void,) => void
Description
Add a custom transition end trigger. Called with the transitioning DOM
node and a done callback. Allows for more fine-grained transition end
logic. Note: Timeouts are still used as a fallback if provided.
Type
boolean
Description
Whether to show the animation when the component is first mounted.
Type
string
Description
Class applied to the root element.
Type
| Element| ((element: Element,) => Element)
Description
An HTML element, or a function that returns one.
It's used to set the container the Slide is transitioning from.
Type
| string| {enter: stringexit: string}
Description
The transition timing function. You may specify a single easing or an object
containing independent values for enter and exit.
Type
boolean
Description
Show the component; triggers the enter or exit states
Type
boolean
Description
By default, the child component is mounted immediately along with the
parent Transition component. If you want to "lazy mount" the component on
the first in =
true
you can set mountOnEnter. After the
first enter transition the component will stay mounted, even on "exited",
unless you also specify unmountOnExit.Type
Ref<HTMLElement>
Description
A React reference to DOM element that need to transition. example.
When
nodeRef
prop is used, node is not passed to callback functions (e.g.
onEnter) because user already has direct access to the node. When changing
key
prop of Transition
in a TransitionGroup
a new nodeRef
needs to be
provided to Transition
with changed key
prop. see also.Type
(node: HTMLElement | object,isAppearing: boolean,) => void
Description
Callback fired before the "entering" status is applied. An extra
parameter
isAppearing
is supplied to indicate if the enter stage is
occurring on the initial mountType
(node: HTMLElement | object,isAppearing: boolean,) => void
Description
Callback fired after the "entered" status is applied. An extra parameter
isAppearing is supplied to indicate if the enter stage is occurring on
the initial mount
Type
(node: HTMLElement | object,isAppearing: boolean,) => void
Description
Callback fired after the "entering" status is applied. An extra parameter
isAppearing is supplied to indicate if the enter stage is occurring on
the initial mount
Type
(node: HTMLElement | object,) => void
Description
Callback fired before the "exiting" status is applied.
Type
(node: HTMLElement | object,) => void
Description
Callback fired after the "exited" status is applied.
Type
(node: HTMLElement | object,) => void
Description
Callback fired after the "exiting" status is applied.
Type
CSSProperties
Description
Inline styles
Type
| number| {appear?: numberenter?: numberexit?: number}
Description
The duration of the transition, in milliseconds. Required unless
addEndListener is provided.
You may specify a single timeout for all transitions:
or individually:
appear defaults to the value of
You may specify a single timeout for all transitions:
timeout={500}
or individually:
timeout={{appear: 500,enter: 300,exit: 500,}}
appear defaults to the value of
enter
.
enter defaults to 0
.
exit defaults to 0
.Type
boolean
Description
By default, the child component stays mounted after it reaches the
'exited' state. Set
unmountOnExit
if you'd prefer to unmount the
component after it finishes exiting.