Skip to content

Accordion Card

The Accordion Card is a card with a header that the operator clicks to expand or collapse it. When it is expanded, it shows an embedded view below the header. Use it to keep a group of details out of the way until the operator needs them. It is found in the Embedding - OpenBridge section of the Perspective Component Palette as Accordion Card.

Accordion Card, expanded, with an icon, a description, a status label and an embedded view

The parts of the card:

  1. Header — the title, and optionally an icon, a description and a status label. See Header.
  2. Chevron — points down when the card is collapsed and up when it is expanded. See Expanding and Collapsing.
  3. Content — the view shown when the card is expanded. See Embedded View.

An Accordion Card dropped from the palette is collapsed, has the title Accordion Card and no view:

Accordion Card with default properties

The content of the card is another view, not components dropped onto the card: the Accordion Card is not a container. Set viewPath to the view to show, and viewParams to the parameters passed to it. The names in viewParams must match the parameters of that view. Design the content as an ordinary view, for example a Flex Container with the readouts that belong to the card.

Expanded card with a view of three readouts

With viewPath empty, the expanded card shows only an empty area under the header.

Note: The screenshots on this page show stand-in content, not a view loaded from a gateway.

The card is as wide as its box (the blue frame). Its height is the height of the header, plus the height of the view when it is expanded. The box does not change size when the card expands or collapses:

Collapsed, in a 320 × 48 box Collapsed card and its box
Expanded, in a box tall enough Expanded card and its box
Expanded, in the box of a new card (50 px) Expanded card growing out of its box

When the card expands in a box sized for the header, the card grows out of the box and is drawn over whatever lies below it: a component cannot resize its own box. The way to use it is in a Flex Container with the card’s position.basis set to auto, so the box follows the card’s height and the components below move down. Otherwise, make the box tall enough for the expanded card, or bind the height of the box to expanded.

Name Description Property Type
viewPath The view shown when the card is expanded. Default empty. value
viewParams Parameters passed to the view. The names must match the parameters of the view. Default {}. object

A click anywhere on the header toggles the card. The card writes the new state to expanded and fires onActionPerformed. Set or bind expanded to open or close the card from elsewhere.

The content slides open and closed, and the chevron turns with it. When the operator’s system is set to reduce motion, the card switches without the animation.

Collapsed Collapsed card
Expanded Expanded card

disabled greys the card out and ignores clicks on it: expanded is not changed and no event is fired. A disabled card keeps its state, so a card that is disabled while expanded stays expanded.

Disabled card

Note: A click writes expanded. In the Designer, a click in Preview Mode changes the property, and the change is saved with the view.

Name Description Property Type
expanded Whether the card is expanded. Written by the card when the operator clicks it. Default false. value
disabled Grey the card out and ignore clicks. Default false. value

The header always shows cardTitle. Three optional parts are each turned on with a has… property:

Part
Leading icon Card with an icon before the title
Status label Card with a status label

The description is shown only when size is large. size selects the height of the header:

size
single-line (default) Single-line header
large Large header with a description
Name Description Property Type
cardTitle The title. Default Accordion Card. value
size Height of the header: single-line or large. Default single-line. value
hasDescription Show a description under the title. Only drawn when size is large. Default false. value
description Text of the description. Only shown when hasDescription is true. value
hasStatusLabel Show a status label at the right of the header. Default false. value
statusLabel Text of the status label, for example Normal. Only shown when hasStatusLabel is true. value
hasLeadingIcon Show an icon before the title. Default false. value
leadingIcon The icon, chosen with the icon picker (leadingIcon.path). Only shown when hasLeadingIcon is true. object

To build a list of cards that look like one surface, stack Accordion Cards without a gap and set position on each: top for the first card, center for the cards in the middle and bottom for the last. position only changes which corners are rounded:

  • regular (default) — all corners rounded: a card on its own.
  • top — the bottom corners are square.
  • center — all corners are square.
  • bottom — the top corners are square.
top, center, bottom Three cards stacked as top, center and bottom
regular, with a gap Three separate cards

Each card expands on its own; expanding one does not collapse the others. To keep only one card open, see Example 2.

Name Description Property Type
position Corner rounding: regular, top, center or bottom. Default regular. value

Properties not covered in the sections above:

Name Description Property Type
style Standard Perspective style object. object
Event Description Event Object
onActionPerformed Fired when the operator expands or collapses the card, after expanded is written. Not fired when the card is disabled, nor when expanded is changed by a binding or a script. —

To act on the new state, read self.props.expanded in the event script.

  1. Create a view Fuel/Overview with a parameter group, and place the readouts for the tanks in that group in it.
  2. Drop an Accordion Card into a Flex Container (direction column). Set cardTitle to Fuel, viewPath to Fuel/Overview and viewParams to {"group": "day"}.
  3. Bind position.basis of the card to expanded, with a transform that returns "148px" when it is true and "48px" otherwise (adjust to the height of your view), so the components below move when the card expands.
  1. Stack three Accordion Cards in a Flex Container (direction column, no gap) and set position to top, center and bottom.

  2. Add a custom property openCard to the view (view.custom.openCard).

  3. On each card, bind expanded to an expression that compares it with the card’s own name, for example {view.custom.openCard} = "fuel" on the Fuel card.

  4. On each card’s onActionPerformed, add a script that writes the card’s name when the card was expanded, and clears it when it was collapsed:

    self.view.custom.openCard = "fuel" if self.props.expanded else ""

    Opening a card then closes the card that was open.

Built on the OpenBridge Design System