Collapse

Displays content that can be revealed or hidden with an animation.

Basic

Basic usage of the Collapse component to show and hide content with animation.

Loading demo…

import

 

{

 

Block

,

 

Button

,

 

Collapse

,

 

Text

 

}

 

from

 

'@platform-blocks/react-ui-library'

;

import

 

{

useState

}

 

from

 

'react'

;

export

 

function

 

Demo

(

)

 

{

  

const

 

[

isCollapsed

,

setIsCollapsed

]

 

=

 

useState

(

false

)

;

  

return

 

(

    

<Block

>

      

<Button

 

onPress

=

{

(

)

 

=>

 

setIsCollapsed

(

!

isCollapsed

)

}

>

        

{

isCollapsed

?

 

'Show'

 

:

 

'Hide'

}

      

</Button

>

      

<Collapse

 

isCollapsed

=

{

isCollapsed

}

>

        

<Text

>

          

This

is some content inside the

Collapse

component

.

 

It

will be shown or hidden based on the isCollapsed prop

.

        

</Text

>

      

</Collapse

>

    

</Block

>

  

)

;

}

Scan to open this page on your phonereact-ui-library.com/components/Collapse

</>

react-ui-library

100+ accessible, themeable components that work seamlessly across iOS, Android, and Web.

A Platform Blocks product.