Skip to content

expandable

Displays its child elements in a collapsible area.

Expandable is a block control.

Properties

Name Type Default Description
title(★) str
dynamic

Title of this block element.

expanded bool
dynamic
True

If True, the block is expanded, and the content is displayed.
If False, the block is collapsed and its content is hidden.

partial Partial

A Partial object that holds the content of the block.
This should not be defined if page is set.

page str

The page name to show as the content of the block.
This should not be defined if partial is set.

id str

The identifier that will be assigned to the rendered HTML component.

properties dict[str, any]

Bound to a dictionary that contains additional properties for this element.

class_name str
dynamic

The list of CSS class names that will be associated with the generated HTML Element.
These class names will be added to the default taipy-<element_type>.

hover_text str
dynamic

The information that is displayed when the user hovers over this element.

on_change Callback

The name of a function that is triggered when the value is updated.
The parameters of that function are all optional:

  • state (State): the state instance.
  • var_name (str): the variable name.
  • value (any): the new value.

(★)title is the default property for this visual element.

Styling

All the expandable blocks are generated with the "taipy-expandable" CSS class. You can use this class name to select the expandable blocks on your page and apply style.

Usage

Defining a title and managing expanded state

The default property title defines the title shown when the visual element is collapsed.

Definition

<|Title|expandable|expand={expand}|>
<taipy:expandable expand="{expand}">Title</taipy:expandable>
import taipy.gui.builder as tgb
...
tgb.expandable("Title", expand="{expand}")

Content as block

The content of expandable can be specified as the block content.

Definition

<|Title|expandable|
    ...
    <|{some_content}|>
    ...
|>
<taipy:expandable title="Title">
    ...
    <taipy:text>{some_content}</taipy:text>
    ...
</taipy:expandable>
import taipy.gui.builder as tgb
...
with tgb.expandable("Title")
    tgb.text("{some_content}")

Expandable with page

The content of the expandable can be specified as an existing page name using the page property.

Definition

<|Title|expandable|page=page_name|>
<taipy:expandable page="page_name">Title</taipy:expandable>
import taipy.gui.builder as tgb
...
tgb.expandable("Title", page="page_name")

Expandable with partial

The content of the expandable can be specified as a Partial instance using the partial property.

Definition

<|Title|expandable|partial={partial}|>
<taipy:expandable partial="{partial}">Title</taipy:expandable>
import taipy.gui.builder as tgb
...
tgb.expandable("Title", partial="{partial}")