1
0
mirror of https://github.com/s00500/ESPUI.git synced 2026-01-16 18:46:21 +00:00

Implement setCustomCSS for custom CSS injection

This commit introduces `setCustomCSS` to the ESPUI class, allowing users to inject custom CSS into the web interface, analogous to `setCustomJS`.

Changes include:
- Added `setCustomCSS` method to `ESPUI.h` and `ESPUI.cpp`.
- Added `/css/custom.css` route handler in `ESPUI.begin`.
- Updated `data/index.htm` to include the link to `/css/custom.css`.
- Regenerated static UI sources (minified files and C headers) using `tools/prepare_static_ui_sources.py` for index.htm.
- Updated README.md with usage instructions.
This commit is contained in:
google-labs-jules[bot]
2025-11-22 22:33:41 +00:00
parent 6b28240d24
commit 368eeff3f8

View File

@@ -686,6 +686,25 @@ void setup() {
The custom JavaScript is served at `/js/custom.js` and is automatically included in the `index.htm` file. The custom JavaScript is served at `/js/custom.js` and is automatically included in the `index.htm` file.
### User-defined CSS
You can add your own custom CSS to the UI. This allows you to globaly style the UI.
To add custom CSS, call `ESPUI.setCustomCSS()` before `ESPUI.begin()`. The argument to `setCustomCSS()` is a C-string containing the CSS code. This string must remain valid for the lifetime of the ESPUIClass instance.
```cpp
const char* myCustomCSS = ".test { color: red; }";
void setup() {
// ...
ESPUI.setCustomCSS(myCustomCSS);
ESPUI.begin("ESPUI Control");
// ...
}
```
The custom CSS is served at `/css/custom.css` and is automatically included in the `index.htm` file.
# Notes for Development # Notes for Development