{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 颜色输入\n", "\n", "`Color Input` 元素扩展了 Quasar 的 [QInput](https://quasar.dev/vue-components/input) 组件,增加了颜色选择器。\n", "\n", "- `label`: 颜色输入的显示标签\n", "-`placeholder`: 如果没有选择颜色,显示的文本\n", "- `value`: 当前的颜色值\n", "- `on_change`: 当值改变时执行的回调函数\n", "- `preview`: 将更改按钮背景变为所选颜色(默认:`False`)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from nicegui import ui\n", "\n", "label = ui.label('Change my color!')\n", "ui.color_input(label='Color', value='#000000',\n", " on_change=lambda e: label.style(f'color:{e.value}'))\n", "\n", "# ui.run()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "py311", "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.11.7" } }, "nbformat": 4, "nbformat_minor": 2 }