Text Array Input Showcase

Example

Component Documentation

Component Name

TextArrayInput

Builder Function Name

create_text_array_input_manager

Description

Builds an input for managing an array of text items. The user enters a string in a text field and clicks a button to add it to the array. They can reorder items (shift them up or down) or delete them. Optionally displayed in a popover when `is_popover` is true.

Use like example

Config

PropertyTypeDefaultDescription
valarray of strings or null

The initial list of text items.

labelstring or null

A label displayed above the text array input.

placeholderstring or null

Placeholder text for the single-line input used when adding new items.

is_no_spacesboolean

false

If true, replaces spaces with nothing (like a no-space validator).

max_lengthnumber

255

Maximum length allowed per item in the array.

is_disabledboolean

false

If true, prevents adding or removing items, shifting them, etc.

mlnumber

0

Margin left in rem.

mrnumber

0

Margin right in rem.

mtnumber

0

Margin top in rem.

mbnumber

0

Margin bottom in rem.

border_radiusnumber

1

Border radius (in rem) for the added item containers.

is_popoverboolean

false

If true, the text array input is displayed inside a popover. Otherwise, it's shown inline.

headerstring

Text Array Input

Popover header text if `is_popover` is true.

on_changefunction or null

Callback triggered whenever the array changes (items added, removed, or shifted). Receives the updated array.

on_finishfunction or null

Called when the user finalizes (clicks 'Finish' if in a popover). Receives the final array.

Methods

MethodDescriptionParametersReturns
init

Initializes state and managers. Called once with the config.

No Params

set_val

Sets the entire array of text items programmatically.

No Params

add_item

Adds the current text from `input_text_manager.val` to the array (if valid).

No Params

delete_item

Removes the item at a given index.

No Params

shift_item

Reorders items by moving one item up or down (the `shift_by` can be -1 or +1).

No Params

finish

Closes the popover (if used) and calls `on_finish` with the final array.

No Params

Returned Properties

PropertyTypeDescription
valarray of strings or null

The current list of items. Updated whenever items are added, deleted, or shifted.

input_text_managerobject

The text input manager for the single-line text field used to add items.

add_button_managerobject

Button manager for the 'add item' button.

val_preppedarray of objects

Metadata for each existing item in the array, including reorder and delete button managers.

popover_managerobject

If `is_popover` is true, controls the popover. You can open or close it with `manager.popover_manager.open()` or `manager.popover_manager.close()`.

finish_button_managerobject

Button manager for the 'Finish' button (only relevant when `is_popover` is true).

icon
Sponsored byContibase