Live preview

Interactive example

Loading example…

Usage

Import the component and its manager, then make it your own.

ComponentTextArrayInput
Managercreate_text_array_input_manager

svelte

<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { TextArrayInput, create_text_array_input_manager } from "sveltekit-ui"

  const manager = create_text_array_input_manager({
    label: "Project tags",
    placeholder: "Add a tag",
    val: ["svelte", "design"],
    max_length: 24,
  })
</script>

<TextArrayInput {manager} />
<p>Tags: {(manager.val ?? []).join(", ")}</p>

API reference

Configure the manager, call its methods, and read its reactive state.

15 entries in configuration

PropertyTypeDefaultDescription
valarray of strings or null nullThe initial list of text items.
labelstring or null nullA label displayed above the text array input.
placeholderstring or null nullPlaceholder text for the single-line input used when adding new items.
is_no_spacesboolean falseIf true, replaces spaces with nothing (like a no-space validator).
max_lengthnumber 255Maximum length allowed per item in the array.
is_disabledboolean falseIf true, prevents adding or removing items, shifting them, etc.
mlnumber 0Margin left in rem.
mrnumber 0Margin right in rem.
mtnumber 0Margin top in rem.
mbnumber 0Margin bottom in rem.
border_radiusnumber 1Border radius (in rem) for the added item containers.
is_popoverboolean falseIf true, the text array input is displayed inside a popover. Otherwise, it's shown inline.
headerstring Text Array InputPopover 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.