{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "import panel as pn\n",
    "pn.extension()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The ``TextAreaInput`` allows entering any multiline string using a text input box. Lines are joined with the newline character ``\\n``.\n",
    "\n",
    "Discover more on using widgets to add interactivity to your applications in the [how-to guides on interactivity](../../how_to/interactivity/index.md). Alternatively, learn [how to set up callbacks and (JS-)links between parameters](../../how_to/links/index.md) or [how to use them as part of declarative UIs with Param](../../how_to/param/index.md).\n",
    "\n",
    "#### Parameters:\n",
    "\n",
    "For details on other options for customizing the component see the [layout](../../how_to/layout/index.md) and [styling](../../how_to/styling/index.md) how-to guides.\n",
    "\n",
    "##### Core\n",
    "\n",
    "* **``value``** (str): The current value updated when the widget loses focus because the user clicks away or presses the tab key.\n",
    "* **``value_input``** (str): The current value updated on every key press.\n",
    "\n",
    "##### Display\n",
    "\n",
    "* **`auto_grow`** (boolean, default=False): Whether the TextArea should automatically grow in height to fit the content.\n",
    "* **`cols`** (int, default=2): The number of columns in the text input field. \n",
    "* **`disabled`** (boolean, default=False): Whether the widget is editable\n",
    "* **`max_length`** (int, default=5000): Max character length of the input field. Defaults to 5000\n",
    "* **`max_rows`** (int, default=None): The maximum number of rows in the text input field when `auto_grow=True`. \n",
    "* **`name`** (str): The title of the widget\n",
    "* **`placeholder`** (str): A placeholder string displayed when no value is entered\n",
    "* **`rows`** (int, default=2): The number of rows in the text input field. \n",
    "* **`resizable`** (boolean | str, default='both'): Whether the layout is interactively resizable, and if so in which dimensions: `width`, `height`, or `both`.\n",
    "\n",
    "___"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "text_area_input = pn.widgets.TextAreaInput(name='Text Area Input', placeholder='Enter a string here...')\n",
    "text_area_input"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "``TextAreaInput.value`` returns a string type that can be read out and set like other widgets:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "text_area_input.value"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "An auto-growing `TextAreaInput` will grow (and shrink) in height to accommodate the entered text. Setting `rows` together with `auto_grow` will set a lower bound on the number of rows and setting `max_rows` will provide an upper bound:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pn.widgets.TextAreaInput(name='Growing TextArea', auto_grow=True, max_rows=10, rows=6, value=\"\"\"\\\n",
    "This text area will grow when newlines are added to the text:\n",
    "\n",
    "1. Foo\n",
    "2. Bar\n",
    "3. Baz\n",
    "\"\"\", width=500)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you only want the text area to be resizable in the vertical direction, you can set the resizeable parameter to 'height':"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pn.widgets.TextAreaInput(name=\"Vertical Adjustable TextArea\", resizable=\"height\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Controls\n",
    "\n",
    "The `TextAreaInput` widget exposes a number of options which can be changed from both Python and Javascript. Try out the effect of these parameters interactively:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pn.Row(text_area_input.controls(jslink=True), text_area_input)"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
