Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ant design collapse - open all

Tags:

reactjs

I'm new to React and Ant Design. Ant design's collapse widget allows all items to be open, but there is no way pre-baked way to set the items to be all open by default - you can only set a single collapse unit to be default opened with

defaultActiveKey={['1']}

How would I default open all?

like image 434
Deborah Avatar asked Oct 23 '25 17:10

Deborah


2 Answers

You can use defaultActiveKey for that case.

As you see below it will accept an Array(also number and string)

defaultActiveKey?: Array<string | number> | string | number;

So you can do:

defaultActiveKey={['1', '2', '3', '4', '5']}

But do not use activeKey, because can not close the panels unless you want to force open them all panels without any option to be closed.

like image 60
Alireza Avatar answered Oct 26 '25 08:10

Alireza


you should use activeKey property

activeKey={['1','2','3']}
like image 29
guleryuz Avatar answered Oct 26 '25 08:10

guleryuz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!