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.

@rodja
Copy link
Member Author

rodja commented Oct 16, 2025

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

Great idea. I also like that it would demonstrate the integration with FastAPI RESTful APIs!

@evnchn
Copy link
Collaborator

evnchn commented Oct 17, 2025

8fcfbad

Did not wound up adding a link to RoSys since the rest of the demo text is so short.

@rodja
Copy link
Member Author

rodja commented Oct 18, 2025

Thanks @evnchn. I replaced the log with an echart to squeeze in some data visualization. Even if the demo is a bit longer that way, I think its worth it.

@rodja rodja mentioned this pull request Oct 18, 2025
4 tasks
@evnchn
Copy link
Collaborator

evnchn commented Oct 18, 2025

more "wow"

A good idea in general because some of the examples are too simple, really.

Going forward I envision a "level select" for any demo's technical depth, possibly from "basic", "advanced" to "expert".

See if that's considerable. If so can go to NiceGUI Wishlist (may need designer's help to elegantly put a selector in the existing demo)

@rodja
Copy link
Member Author

rodja commented Oct 18, 2025

Going forward I envision a "level select" for any demo's technical depth, possibly from "basic", "advanced" to "expert".

I'm not sure if that is a good idea. It would add quite a bit of complexity. I think the intro-demos should be a a mix of 33% "nice", 33% "wow" and 33% "aha". We have the in-depth examples for advanced and expert users.

Copy link
Contributor

@falkoschindler falkoschindler left a comment

Choose a reason for hiding this comment

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

As discussed with @rodja, I filled the SPA with a ui.table and a ui.leaflet map to make it visually more interesting. At the same time I tried to keep the code short and simple. The generic "row-click" event is a bit tricky, but I think it's good enough for now.

Let's merge this and further improve on a separate PR.

@falkoschindler falkoschindler merged commit 712d056 into main Oct 20, 2025
9 checks passed
@falkoschindler falkoschindler deleted the better-intro branch October 20, 2025 15:16
@falkoschindler falkoschindler mentioned this pull request Oct 26, 2025
4 tasks
rodja pushed a commit that referenced this pull request Oct 27, 2025
### Motivation

I noticed that some demos like
https://nicegui.io/documentation/button#await_button_click are currently
broken.
This is because PR #5275 started evaluating the return value of demo
functions, but removed the handling of async demo functions.

### Implementation

This PR restores the check `helpers.is_coroutine_function(f)` while
processing the result of `f()` as in PR #5275.

### Progress

- [x] I chose a meaningful title that completes the sentence: "If
applied, this PR will..."
- [x] The implementation is complete.
- [x] Pytests are not necessary.
- [x] Documentation is not necessary.
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.

4 participants