Skip to content

Conversation

rodja
Copy link
Member

@rodja rodja commented Oct 14, 2025

Motivation

The main page demos are often the first code examples new users see. The previous demos (Styling, Common UI Elements, and Value Binding) showed what was possible but didn't effectively communicate NiceGUI's new core paradigm: building SPAs with a root function as the single entry point. This is a fundamental pattern that users should grasp early, especially those transitioning from frameworks like Streamlit.
The old demos also introduced too many concepts at once without clear educational flow, making it harder for newcomers to form the right mental model.

Implementation

  • replace old intro-demos with two new demos (single page app & reactive transformations). I would have liked a third one which demonstrates global state but had no good idea yet. So I'll leave it for another PR.
  • changed @ui.page decorator in feature list with ui.sub_pages to establish SPA as the primary pattern.
  • some improved infrastructure

Progress

  • I chose a meaningful title that completes the sentence: "If applied, this PR will..."
  • The implementation is complete.
  • Pytests are not necessary.
  • Documentation has been updated.

@rodja rodja added this to the 3.1 milestone Oct 14, 2025
@rodja rodja requested a review from evnchn October 14, 2025 05:17
@rodja rodja added documentation Type/scope: Documentation, examples and website review Status: PR is open and needs review labels Oct 14, 2025
Copy link
Collaborator

@evnchn evnchn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally a good idea to re-work the docs. I wish we did it in 3.0 release but we are stretched back then.

Importantly, I don't think we can put sub-pages at the spotlight while the API is still warned to be subject-to-change in the documentations. It may give a bad impression.

Recommended course of action:

  1. Mark the sub-pages API as stable, then we can spotlight it.
  2. If not we will have to put @ui.page first and sub-pages second.
  3. Or it may be good to show both (maybe even alongside each other in 2 demos) considering there may be users coming from FastAPI / Flask, which uses decorators.

While we're at it can we also spotlight the new Event system? Phrase "Once part of RoSys, our robot system built on top of NiceGUI, the Event system ..." can help you plug a RoSys link as well.

@rodja
Copy link
Member Author

rodja commented Oct 14, 2025

Importantly, I don't think we can put sub-pages at the spotlight while the API is still warned to be subject-to-change in the documentations.

You are right. I just talked to @falkoschindler and we agreed to remove the warning. It's about time!

@rodja
Copy link
Member Author

rodja commented Oct 16, 2025

While we're at it can we also spotlight the new Event system?

Yes, I would really like that. But such a demo is blocked by #5231. Otherwise opening two tabs will have a high chance of not seeing the triggered events (because you land on another instance). Let's leave it for another PR.

@rodja rodja requested a review from evnchn October 16, 2025 03:40
@evnchn
Copy link
Collaborator

evnchn commented Oct 16, 2025

... spotlight the new Event system ... blocked by #5231

If the source of the events are not triggerable by user but come from hypothetical sources, we can easily get away with it.

Imagine a demo:

from nicegui import ui, app, Event

temperature_event = Event[int]()

@app.get('/temperature_sensor')
def temperature_sensor_webhook(temperature: float):
    temperature_event.emit(temperature)

@ui.page('/')
def temperature_dashboard():
    # some logic to subscribe to the temperature_event

We won't really expose /temperature_sensor in reality, though.

And then we mock the demo with fluctuating temperatures from 24 to 26 degree celsius.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Type/scope: Documentation, examples and website review Status: PR is open and needs review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants