Files
LCUI/lib/ui-router/README.md
Liu 58a9702316 refactor(ui-router): extract router widgets into a new lib
Create lib/ui-router/ as a thin UI binding layer between libui and librouter, exposing the router-link and router-view widgets under <ui_router/...>.

* Move src/widgets/router_{link,view}.c and the matching public headers into lib/ui-router/src and lib/ui-router/include.

* Drop include/LCUI/widgets/router_{link,view}.h and the corresponding entries in include/LCUI/widgets.h; src/lcui_widgets.c now pulls registrations from <ui_router.h>.

* Wire libui-router into the root xmake.lua add_includedirs and lcui add_deps chain; libui-router depends on yutil + libui + librouter only.

* tests/integration/test_router.c stays at the integration layer (router widgets exercise text inheritance and other libui internals); only its #include set is updated to use <ui_router.h>.

* Bump CHANGELOG and add bilingual lib/ui-router/README.
2026-05-24 17:56:24 +08:00

957 B

libui-router

(English/中文)

libui-router is the UI binding layer that connects librouter to libui widgets.

It ships two widgets:

  • router-link — a clickable widget that triggers navigation; mirrors <router-link> from Vue Router. Toggles router-link-active and router-link-exact-active classes based on the current route.
  • router-view — a route outlet that renders the matched component for the current route.

Usage

#include <ui.h>
#include <ui_router.h>

ui_init();
ui_register_router_link();
ui_register_router_view();

/* Now "router-link" and "router-view" widget types are available. */

When LCUI is used as a whole, lcui_init() already calls these registration functions through lcui_widgets_init(); this lib only needs to be called manually if you embed libui-router without the LCUI top-level shell.

License

MIT licensed.