blu.html

React HTML elements.

from blu.html import div, p

div(className='my-div')[
    p['Hello!'],
    p['Hi.'],
]
<div className='my-div'>
    <p>Hello!</p>
    <p>Hi.</p>
</div>
blu.html.__getattr__(import_name: str) HTMLElement

Creates a blu.HTMLElement with the given HTML tag name.

from blu.html import div, p

div(className='my-div')[
    p['Hello!'],
    p['Hi.'],
]
<div className='my-div'>
    <p>Hello!</p>
    <p>Hi.</p>
</div>

Use a trailing underscore to import tag names that are reserved words in Python (the trailing underscore won’t show up in the resulting html):

from blu.html import del_

del_['Hello, World!']
<del>Hello, World!</del>

Non-trailing underscores will be converted to dashes:

from blu.html import my_custom_element

my_custom_element['Hello!']
<my-custom-element>Hello!</my-custom-element>

For the rare case where your desired HTML tag name cannot be imported from blu.html, use blu.create_rare_html_element().

Parameters:

import_name – An HTML tag name.

Returns:

A blu.HTMLElement whose tag name is import_name with the last trailing underscore (if any) removed and any other underscores converted to dashes. The HTMLElement won’t have any props or children.