Skip to content
ConsoleMonster
Cmdlet

New-ConsoleCollapsible

Module
ConsoleMonster
Outputs
ConsoleMonster.Interactive.Collapsible ConsoleMonster.Interactive.Accordion

Creates a collapsible section for Show-ConsoleApp, or an accordion of sections that keeps one open.

Syntax

New-ConsoleCollapsible
[-Content <Object>]
[-Disabled]
[-Expanded]
[-Key] <String>
[[-Label] <String>]
[-OnChange <ScriptBlock>]
[-Summary <String>]
[-TabIndex <Int32>]
[-ValidationMessage <String>]
[<CommonParameters>]
#
Parameter set: Section
New-ConsoleCollapsible
-Accordion
[-Content] <Object>
[<CommonParameters>]
#
Parameter set: Accordion

Description

A section is a focusable header row with its content below. Enter, Space, Left/Right and a click on the header fold and unfold it; while it is collapsed the header shows -Summary and the content's inputs leave the focus order. The final state holds whether each section is expanded. With -Accordion, -Content emits sections and opening one folds the others; + expands every section and - folds them all.

Examples

Example 1

Show-ConsoleApp -Content {
    New-ConsoleCollapsible -Accordion -Content {
        New-ConsoleCollapsible -Key Synopsis -Expanded -Content { 'Gets the services on a computer.' }
        New-ConsoleCollapsible -Key Examples -Summary '(2)' -Content {
            'Get-Service -Name win*'
            'Get-Service | Where-Object Status -eq Running'
        }
    }
}

Fold long sections of a help page and keep one open at a time.

Parameters

-Content Object required in Accordion
The section's widgets, text or a script block that emits them. With -Accordion, the sections of the group.
-Disabled SwitchParameter optionalsets: Section
Disables the header and removes it from keyboard focus traversal.
-Expanded SwitchParameter optionalsets: Section
Starts the section expanded.
-Key String requiredposition: 0sets: Section
Unique key in the application's state; the value is whether the section is expanded.
-Label String optionalposition: 1sets: Section
Header text; defaults to the key.
-OnChange ScriptBlock optionalsets: Section
Runs once each time the section folds or unfolds, on the owning input thread. Receives param($Value, $State) and injected $Value, $State and $Control. Output is discarded.
-Summary String optionalsets: Section
Muted text after the header while collapsed, such as a count.
-TabIndex Int32 optionalsets: Section
Keyboard focus order. Equal values preserve layout declaration order.
-ValidationMessage String optionalsets: Section
Validation text shown in the header.
-Accordion SwitchParameter requiredsets: Accordion
Groups the sections emitted by -Content so that opening one folds the others.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.