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.

page str

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

partial taipy.gui.Partial

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

id str

The identifier that is 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 are associated with the generated HTML Element.
These class names are added to the default taipy-expandable class name.

hover_text str
dynamic

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

on_change Union[str, Callable]

A function or the name of a function that is triggered when the value is updated.
This function is invoked with the following parameters:

  • 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.

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}")

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.