I have two text style cells as shown in the picture (second one is hidden). Is it possible to add an interactive button so that if someone clicks on that button/text then the second cell's can be toggled between open and hidden?

Alternatively, it is also fine if a mouse-over on a button/text brings up a message saying that there is a hidden cell nearby but I would really prefer to have the toggle thing if it is possible in Mathematica.

Desired Output :- When someone clicks on expand the cell below then the hidden cell is set to open and when it is clicked again then the cell is again hidden.

You could use a button like this:

Button["Toggle cell below", SetOptions[NextCell[], CellOpen -> ! CurrentValue[NextCell[], CellOpen]]]

• You could also make the button label dynamic: Button[Dynamic[If[CurrentValue[NextCell[], CellOpen], "Less", "More"]], SetOptions[NextCell[], CellOpen -> ! CurrentValue[NextCell[], CellOpen]]] – Bob Hanlon Jun 13 at 14:59
• Both of these work very well. Thank you :) – Nitin Jun 13 at 15:47

You can set the option "ShowGroupOpener" to True for the first cell of a cell group to add an Opener to open/close the cell groups. Alternatively, set the option "WholeCellGroupOpener" to True to make the whole cell a behave like a toggler button.

You can do this in two ways:

Manually: Right-click the cell bracket and select Properties to open the Option Inspector notebook. ClickCell Options >> Display Options and change the setting for "ShowGroupOpener".

Programatically: In the first cell of the notebook, using some identifying text for the cells to be modified ("comments" in the example below), execute

SetOptions[NotebookFind[EvaluationNotebook[], "comments", All],
"ShowGroupOpener" -> True]


• This is absolutely perfect. I hope you don't mind that I keep the other answer as the accepted one because that was posted earlier and the contributor is new. – Nitin Jun 14 at 15:27