{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from awesome_panel_extensions.awesome_panel.notebook import Header\n",
"Header(folder=\"examples/reference/frameworks/fast\", notebook=\"FastCheckbox.ipynb\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Fast Checkbox - Reference Guide\n",
"\n",
"The `FastCheckbox` widget is based on the [fast-checkbox](https://explore.fast.design/components/fast-checkbox) web component and extends the built in [Panel Checkbox](https://panel.holoviz.org/reference/widgets/Checkbox.html).\n",
"\n",
"
\n",
" \n",
" | \n",
"
\n",
"
\n",
"\n",
"\n",
"#### Parameters:\n",
"\n",
"* **``name``** (str): The label of the Checkbox.\n",
"* **``value``** (boolean): Whether or not the Checkbox is checked. Defaults to False.\n",
"* **``disabled``** (boolean): Whether or not the Checkbox is disabled. Defaults to False.\n",
"\n",
"\n",
"* **``readonly``** (boolean): Whether or not the Checkbox is readonly. Defaults to False.\n",
"\n",
"\n",
"The `FastCheckbox` has the same layout and styling parameters as most other widgets. For example `width` and `sizing_mode`.\n",
"\n",
"Please note that you can only use the Fast components inside a custom Panel template that\n",
"\n",
"- Loads the [Fast `javascript` library](https://www.fast.design/docs/components/getting-started#from-cdn).\n",
"- Wraps the content of the `` html tag inside the [fast-design-system-provider](https://www.fast.design/docs/components/getting-started#add-components) tag.\n",
"\n",
"We provide the `FastTemplate` for easy usage. \n",
"\n",
"You can also develop your own custom [Panel template](https://panel.holoviz.org/user_guide/Templates.html) if you need something special. For example combining it with more [fast.design](https://fast.design/) web components and the [Fluent Design System](https://www.microsoft.com/design/fluent/#/) to create **VS Code** and **Microsoft Office** like experiences.\n",
"\n",
"Please note that Fast components will not work in older, legacy browser like Internet Explorer.\n",
"\n",
"___\n",
"\n",
"Let's start by importing the dependencies"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import param\n",
"import panel as pn\n",
"from awesome_panel_extensions.frameworks.fast import FastTemplate, FastCheckbox\n",
"\n",
"pn.config.sizing_mode = \"stretch_width\"\n",
"pn.extension()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Parameters\n",
"\n",
"Let's explore the parameters of the `FastCheckbox`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"checkbox = FastCheckbox(name=\"Click me\", sizing_mode=\"fixed\", width=200, value=True)\n",
"\n",
"app=pn.Row(\n",
" checkbox\n",
")\n",
"template=FastTemplate(main=[app])\n",
"template"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"checkbox_parameters = [\"name\", \"value\", \"disabled\", \"readonly\", \"width\", \"height\", \"sizing_mode\"]\n",
"settings_pane = pn.WidgetBox(pn.Param(checkbox, parameters=checkbox_parameters, show_name=False))\n",
"settings_pane"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## pn.Param\n",
"\n",
"Let's verify that that `FastCheckbox` can be used as a widget by `pn.Param`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"WIDGETS = {\n",
" \"panel_is_awesome\": FastCheckbox\n",
"}\n",
"\n",
"class ParameterizedApp(param.Parameterized):\n",
" panel_is_awesome = param.Boolean(default=True, label=\"Panel is awesome\")\n",
" view = param.Parameter()\n",
" \n",
" \n",
" def __init__(self, **params):\n",
" super().__init__(**params)\n",
" \n",
" self.view = pn.Param(self, parameters=[\"panel_is_awesome\"], widgets=WIDGETS, name=\"Parameterized Checkbox App\")\n",
" \n",
"parameterized_app = ParameterizedApp()\n",
"paremeterized_template = FastTemplate(main=[parameterized_app.view])\n",
"paremeterized_template"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Resources\n",
"\n",
"- [fast.design](https://fast.design/)\n",
"- [fast-checkbox](https://explore.fast.design/components/fast-checkbox)\n",
"\n",
"## Known Issues\n",
"\n",
"- None so far.\n",
"\n",
"\n",
" \n",
" | \n",
"
\n",
"
"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}