from awesome_panel_extensions.awesome_panel.notebook import Header
Header(folder="examples/reference/frameworks/fast", notebook="FastTextInput.ipynb")
The FastTextInput
widget is based on the fast-text-field web component and extends the built in Panel TextInput.
value
(str): A string value.name
(str): The label of the TextInput.disabled
(boolean): Whether or not the TextInput is disabled. Default is False.placeholder
(string): A placeholder string displayed when no value is entered.apperance
(string): Determines the appearance of the textinput. One of outline
or filled
. Defaults to outline
.autofocus
(bool): The autofocus attribute. Defaults to False
.type_of_text
(bool): The type of text input. One of email
, password
, tel
, text
, url
. Defaults to text
.readonly
(bool): Whether or not the TextInput is read only. Defaults to False
.The FastTextInput
has the same layout and styling parameters as most other widgets. For example width
and sizing_mode
.
Please note that you can only use the Fast components inside a custom Panel template that
javascript
library.<body>
html tag inside the fast-design-system-provider tag.We provide the FastTemplate
for easy usage.
You can also develop your own custom Panel template if you need something special. For example combining it with more fast.design web components and the Fluent Design System to create VS Code and Microsoft Office like experiences.
Please note that Fast components will not work in older, legacy browser like Internet Explorer.
Let's start by importing the dependencies
import param
import panel as pn
from awesome_panel_extensions.frameworks.fast import FastTemplate, FastTextInput
pn.config.sizing_mode = "stretch_width"
pn.extension()
Let's explore the parameters of the FastTextInput
.
textinput = FastTextInput(name="The label", sizing_mode="fixed", width=300, appearance="outline", placeholder="write something")
textinput_parameters = ["name", "value", "disabled", "placeholder", "appearance", "autofocus", "type_of_text", "readonly", "height", "width", "sizing_mode"]
app=pn.Row(
textinput
)
template=FastTemplate(main=[app])
template
settings_pane = pn.WidgetBox(pn.Param(textinput, parameters=textinput_parameters, show_name=False))
settings_pane
Let's verify that that FastTextInput
can be used as a widget by pn.Param
.
WIDGETS = {
"some_text": {
"type": FastTextInput, "sizing_mode": "fixed", "width": 400, "placeholder": "write some text!"
}
}
class ParameterizedApp(param.Parameterized):
some_text = param.String(default="This is some text", label="This is a label")
view = param.Parameter()
def __init__(self, **params):
super().__init__(**params)
self.view = pn.Param(self, parameters=["some_text"], widgets=WIDGETS)
parameterized_app = ParameterizedApp()
paremeterized_template = FastTemplate(main=[parameterized_app.view])
paremeterized_template
pn.Param(parameterized_app.param.some_text)
fast-text-field
web component has additional attributes (max_length
, min_length
, pattern
, size
, spellcheck
, required
) that does not seem to work. If you think they are important please upvote Fast Github Issue 3852.