Photonix

Collapse

Toggle visibility of content with a smooth transition.

Preview

The content stays in the document flow while the container animates between states.

Usage
"use client";

import { useState } from 'react';
import { Button, Collapse, Stack, Text } from '@photonix/ultimate';

export default function CollapseBasicExample() {
    const [isOpen, setIsOpen] = useState(true);

    return (
        <Stack gap="md">
            <Button variant="secondary" onClick={() => setIsOpen((value) => !value)}>
                {isOpen ? 'Hide details' : 'Show details'}
            </Button>
            <Collapse isOpen={isOpen}>
                <Text variant="body-md" color="secondary">
                    The content stays in the document flow while the container animates between states.
                </Text>
            </Collapse>
        </Stack>
    );
}

Component API

Collapse

Prop
Type
Default
Description
isOpen
boolean
-
Whether the content is visible
unmountOnExit
boolean
false
Whether to unmount the content when closed
defaultIsOpen
boolean
-
Whether to start in the open state (only useful if uncontrolled, but this component is controlled)
animateOpacity
boolean
true
Animation duration in ms (optional, driven by CSS but can be used for delays if needed)
children
React.ReactNode
-
Children elements

On this page

Preview
Component API
Photonix UI - React Components, Templates & Figma Design System