Collapse
Conditionally hide or show content with a collapse animation.
import {QCollapse} from "@qui/react"
Examples
Expand from the start edge of the child element.
I'm a collapsible section
import {ReactNode, useState} from "react"import {QButton, QCollapse} from "@qui/react"export default function Showcase(): ReactNode {const [showing, setShowing] = useState(true)const toggle = () => {setShowing((prevState) => !prevState)}return (<div className="flex flex-col items-center"><QCollapse className="q-body-s" in={showing}>I'm a collapsible section</QCollapse><QButton className="mt-4" color="primary" onClick={toggle} variant="fill">Click me to {showing ? "Hide" : "Show"}</QButton></div>)}
API
Props
This component extends the Transition
component from react-transition-group.
Name & Description | Option(s) | Default |
---|---|---|
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. |
| |
React Children | ReactNode | |
Class applied to the root element. |
| |
Minimum size of the component. If supplied as a number, the value will be
converted into pixels. |
| |
The transition timing function. You may specify a single easing or an object
containing independent values for enter and exit. |
| |
If true, the component will also fade in and out. |
| |
Show the component; triggers the enter or exit states |
| |
Props for the element that wraps the children. |
| |
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. If supplied as 'auto', the
duration will be computed based on the height of the component's child element. |
| |
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
(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
| string| number
Description
Minimum size of the component. If supplied as a number, the value will be
converted into pixels.
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
If true, the component will also fade in and out.
Type
boolean
Description
Show the component; triggers the enter or exit states
Type
Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>,HTMLDivElement>>
Description
Props for the element that wraps the children.
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| 'auto'| {appear?: numberenter?: numberexit?: number}
Description
The duration of the transition, in milliseconds. If supplied as 'auto', the
duration will be computed based on the height of the component's child element.
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.