WebComponent()
This class must be inherited by all web components.
In many operations where one web component encapsulates another one has
implemented a type check. If the received element is not
WebComponent
will be generated a
TypeError
. To ensure correct handling of your
custom component, do not forget to inherit the
WebComponent
class.
from bootwrap import WebComponent
class CustomHeader(WebComponent):
def __init__(self, title):
self.__title = title
sef __str__(self):
return f'''
<h1 id="{self.identifier}">
{self.__title}
</h1>
'''
Every
WebComponent
has a unique identifier (ex. cfe040e6-df5f-4a3a-
b96e-b0cefc31bbd9). This identifier is used for referencing between
components inside a page. This property returns this identifier as
str
.
When you create a custom
WebComponent
it is advisable to set its
tag attribute
id
equals to
identifier
.
header = CustomHeader('Hello World")
print(header.classes)
# Result: cfe040e6-df5f-4a3a-b96e-b0cefc31bbd9
ClassMixin()
The vast majority of web components in Bootwrap inherit this class. It allows a user to adjust web components look and feel.
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").add_classes("ms-1 me-1")
print(button.classes)
# Result: ms-1 me-1
add_classes(classes)
Name | Type | Description |
---|---|---|
classes |
str
|
The classes to add. The specified classes must be separated by white space. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
Note, the order of specified classes will be preserved during the component rendering.
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").add_classes("ms-1 me-1")
m(size)
Name | Type | Description |
---|---|---|
size |
int
|
Size of the margin to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").m(3)
mb(size)
Name | Type | Description |
---|---|---|
size |
int
|
Size of the margin to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").mb(3)
me(size)
Name | Type | Description |
---|---|---|
size |
int
|
Size of the margin to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").me(3)
ms(size)
Name | Type | Description |
---|---|---|
size |
int
|
Size of the margin to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").ms(3)
mt(size)
Name | Type | Description |
---|---|---|
size |
int
|
Size of the margin to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").mt(3)
mx(size)
Name | Type | Description |
---|---|---|
size |
int
|
Size of the margin to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").mx(3)
my(size)
Name | Type | Description |
---|---|---|
size |
int
|
Size of the margin to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").my(3)
p(size)
Name | Type | Description |
---|---|---|
size |
int
|
Size of the padding to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").p(3)
pb(size)
Name | Type | Description |
---|---|---|
size |
int
|
Size of the padding to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").pb(3)
pe(size)
Name | Type | Description |
---|---|---|
size |
int
|
Size of the padding to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").pe(3)
ps(size)
Name | Type | Description |
---|---|---|
size |
int
|
Size of the padding to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").ps(3)
pt(size)
Name | Type | Description |
---|---|---|
size |
int
|
Size of the padding to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").pt(3)
px(size)
Name | Type | Description |
---|---|---|
size |
int
|
Size of the padding to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").px(3)
py(size)
Name | Type | Description |
---|---|---|
size |
int
|
Size of the padding to set. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ClassMixin.
button = Button("Hello").py(3)
ActionMixin()
add_menu(*menu)
Name | Type | Description |
---|---|---|
*menu |
list
|
The list of dropdown menu actions. These actions
must be represented by
WebComponent
s instantiating
ActionMixin
class.
|
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ActionMixin.
button = Button('Portfolio').add_menu(
Button("Buy"),
Button("Sell"),
Button("Transfer")
)
dismiss()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Dialog, Button
# Note, that Button inherits ActionMixin.
dialog = Dialog(
...,
Button("Bye").dismiss()
)
link(target)
Name | Type | Description |
---|---|---|
target |
str|WebComponent
|
The URL to the linking web-page or
linking
WebComponent
.
|
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits ActionMixin.
button = Button("Search").link("https://www.google.com")
submit()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Form, Button
# Note, that Button inherits ActionMixin.
form = Form(
...,
Button("Send").submit()
)
toggle(target)
Name | Type | Description |
---|---|---|
target |
WebComponent
|
The web component to toggle. |
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button, Dialog
# Note, that Button inherits ActionMixin.
dialog = Dialog(...)
button = Button("Open").toggle(dialog)
AppearanceMixin()
as_danger()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits AppearanceMixin.
button = ("Danger").as_danger()
as_dark()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits AppearanceMixin.
button = ("Dark").as_dark()
as_info()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits AppearanceMixin.
button = ("Info").as_info()
as_light()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits AppearanceMixin.
button = ("Light").as_light()
as_primary()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits AppearanceMixin.
button = ("Primary").as_primary()
as_secondary()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits AppearanceMixin.
button = ("Secondary").as_secondary()
as_success()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits AppearanceMixin.
button = ("Success").as_success()
as_warning()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits AppearanceMixin.
button = ("Warning").as_warning()
OutlineMixin()
Usually
OutlineMixin
is used in conjunction with
AppearanceMixin
to
specify the border appearance.
as_outline()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits AppearanceMixin.
button = ("Primary").as_primary().as_outline()
AvailabilityMixin()
By default, every web component is enabled. The web components inheriting this class can be forced to be disabled.
as_disabled()
Name | Type | Description |
---|---|---|
obj |
self
|
The instance of this class. |
from bootwrap import Button
# Note, that Button inherits AppearanceMixin.
button = ("Primary").as_disabled()
Breakpoints are defined by Bootstrap and mostly based on minimum viewport widths and allow us to scale up elements as the viewport changes.