NiceGUI Component Extraction¶
Extract one user-selected component from the output of the JSFiddle Page Layout prompt and implement it as a reusable NiceGUI component in the target repository.
Supplied Inputs¶
component: {{component}}source_layout: {{source_layout}}target_location: {{target_location}}behavior_requirements: {{behavior_requirements}}
Inputs¶
component: required visible label, semantic role, or selector identifying the component to extractsource_layout: optional HTML and CSS; when omitted, use the latest applicable JSFiddle page layout output in the conversationtarget_location: optional target page, module, or package; infer it from the repository when omittedbehavior_requirements: optional interactions, state, callbacks, or content variations
If the selected component or source layout cannot be identified unambiguously, ask one concise clarification question before editing.
Required References¶
Apply these references before implementation:
- Package boundaries, dependency direction, and page or component ownership: NiceGUI Application Architecture
- Responsive layout, Quasar props, Tailwind utilities, and shared CSS: NiceGUI Styling and Customization
- Typed UI state, propagation, mutable defaults, binding strictness, and version checks: Binding Dataclasses Deep Dive
Workflow¶
- Locate the selected region in the source HTML and CSS, including its responsive rules, states, and dependencies on surrounding layout.
- Inspect the target repository's NiceGUI version, package structure, component conventions, shared CSS loading, and nearest page call site.
- Define the smallest reusable API for the component:
- name the public function
render_<component_name>using snake_case - accept content, typed state, and event callbacks as explicit parameters
- keep business rules, persistence, and service access outside the component
- preserve an established return-value convention; otherwise return the component's root NiceGUI element
- Translate semantic HTML into native NiceGUI and Quasar elements. Do not embed the original page wholesale with
ui.htmlwhen standard components express the structure. - Recreate only the CSS needed by the extracted component:
- use Quasar props for component appearance and behavior
- use NiceGUI classes and Tailwind utilities for spacing, sizing, alignment, and responsive layout
- use scoped shared CSS only where props and utilities are insufficient
- do not override Quasar field internals or duplicate globally loaded styles
- Model editable or shared component state with a typed
@binding.bindable_dataclassonly when binding improves the interaction: - use
field(default_factory=...)for mutable defaults - scope state to the appropriate page, client, or user
- keep binding transforms pure and inexpensive
- assign updated collections back to bound fields instead of relying on in-place mutation
- Integrate the render function at the nearest target page or call site without moving unrelated page composition or domain logic into the component.
- Preserve accessibility, focus behavior, text wrapping, stable dimensions, and the source layout's visual hierarchy.
- Run the narrowest available tests, lint, and type checks for the changed files. For visual components, verify representative mobile, landscape desktop, and portrait desktop viewports when browser tooling is available.
Output Contract¶
Complete the implementation in the target repository, then report:
- Files created or updated.
- The
render_*function signature and its state or callback contract. - Any deliberate visual or interaction differences from the JSFiddle source.
- Validation commands and outcomes, including viewport checks when performed.
Quality Rules¶
- Extract exactly the requested component and its necessary local dependencies.
- Prefer the target repository's established patterns over introducing a new abstraction style.
- Keep the component presentation-focused and reusable across pages with compatible data.
- Do not add a bindable dataclass for static content or event-local state that is clearer as ordinary parameters.
- Do not create a second component tree for mobile; use responsive classes and stable layout constraints.
- Keep custom CSS tokenized, scoped to the component, and loaded once by the application's composition layer.