8000 add element creation section · pyscript/docs@5bc1965 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5bc1965

Browse files
committed
add element creation section
1 parent c26760b commit 5bc1965

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/user-guide/dom.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,19 @@ pydom Element API.
298298
We welcome feedback and suggestions.
299299

300300

301+
#### Creating a new element
302+
303+
The element creation API provided by `pyweb.ui.elements` is focused on being simple
304+
and idiomatic. In fact, to create an element simply instantiate the type of element
305+
you need, providing all the properties supported by that element. Here's an example
306+
of creating a new button with a custom style
307+
308+
```python
309+
# This will change the text of all H1 elements in the page
310+
from pyweb.ui.elements import button
311+
btn_open_dialog = button("Open Dialog", title='open dialog button', draggable=True, style={margin: '5px'})
312+
```
313+
301314

302315
## Working with JavaScript
303316

0 commit comments

Comments
 (0)
0