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 the expandable block.

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 assigned to the rendered HTML component.
This can be used in callbacks or to target the element for styling.

properties dict[str, Any]

A dictionary of additional properties that can be set to the element.

class_name str
dynamic

A space-separated list of CSS class names to be applied to the generated HTML element.
These classes are added to the default taipy-expandable class.

hover_text str
dynamic

The text that is displayed when the user hovers over the element.

on_change Union[str, Callable]

A function or the name of a function that is triggered when the value changes.
The callback function receives the following parameters:

  • state (State): the state instance.
  • var_name (str): the bound variable name.
  • value (Any): the updated 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.