Class WebComponent

A web component base class.
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.

Example
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>
        '''

Property identifier

A unique web component identifier.

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 .

Example
header = CustomHeader('Hello World")
print(header.classes)

# Result: cfe040e6-df5f-4a3a-b96e-b0cefc31bbd9

Class ClassMixin

Mixin for a web component which class can be amended.
ClassMixin()

The vast majority of web components in Bootwrap inherit this class. It allows a user to adjust web components look and feel.

Property classes

The web component classes.
Example
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

Method add_classes

Adds other classes.
add_classes(classes)
Arguments
Name Type Description
classes str The classes to add. The specified classes must be separated by white space.
Returns
Name Type Description
obj self The instance of this class.

Note, the order of specified classes will be preserved during the component rendering.

Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").add_classes("ms-1 me-1")

Method m

Sets margin for all four sides to the specified size.
m(size)
Arguments
Name Type Description
size int Size of the margin to set.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").m(3)

Method mb

Sets margin for the bottom side the specified size.
mb(size)
Arguments
Name Type Description
size int Size of the margin to set.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").mb(3)

Method me

Sets margin for the end(right-side) to the specified size.
me(size)
Arguments
Name Type Description
size int Size of the margin to set.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").me(3)

Method ms

Sets margin for the start(left-side) to the specified size.
ms(size)
Arguments
Name Type Description
size int Size of the margin to set.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").ms(3)

Method mt

Sets margin for the top side to the specified size.
mt(size)
Arguments
Name Type Description
size int Size of the margin to set.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").mt(3)

Method mx

Sets margin for left and right sides to the specified size.
mx(size)
Arguments
Name Type Description
size int Size of the margin to set.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").mx(3)

Method my

Sets margin for top and bottom sides to the specified size.
my(size)
Arguments
Name Type Description
size int Size of the margin to set.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").my(3)

Method p

Sets padding for all four sides to the specified size.
p(size)
Arguments
Name Type Description
size int Size of the padding to set.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").p(3)

Method pb

Sets padding for the bottom side the specified size.
pb(size)
Arguments
Name Type Description
size int Size of the padding to set.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").pb(3)

Method pe

Sets padding for the end(right-side) to the specified size.
pe(size)
Arguments
Name Type Description
size int Size of the padding to set.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").pe(3)

Method ps

Sets padding for the start(left-side) to the specified size.
ps(size)
Arguments
Name Type Description
size int Size of the padding to set.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").ps(3)

Method pt

Sets padding for the top side to the specified size.
pt(size)
Arguments
Name Type Description
size int Size of the padding to set.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").pt(3)

Method px

Sets padding for left and right sides to the specified size.
px(size)
Arguments
Name Type Description
size int Size of the padding to set.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").px(3)

Method py

Sets padding for top and bottom sides to the specified size.
py(size)
Arguments
Name Type Description
size int Size of the padding to set.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ClassMixin.
button = Button("Hello").py(3)

Class ActionMixin

Mixin for a web component which able to perform an action.
ActionMixin()

Method add_menu

Adds dropdown menu.
add_menu(*menu)
Arguments
Name Type Description
*menu list The list of dropdown menu actions. These actions must be represented by WebComponent s instantiating ActionMixin class.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ActionMixin.
button = Button('Portfolio').add_menu(
    Button("Buy"),
    Button("Sell"),
    Button("Transfer")
)

Method dismiss

Performes a dismiss action.
dismiss()
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Dialog, Button

# Note, that Button inherits ActionMixin.
dialog = Dialog(
    ...,
    Button("Bye").dismiss()
)

Method link

Links to the web-resource.
link(target)
Arguments
Name Type Description
target str|WebComponent The URL to the linking web-page or linking WebComponent .
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits ActionMixin.
button = Button("Search").link("https://www.google.com")

Method submit

Performes a submit action.
submit()
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Form, Button

# Note, that Button inherits ActionMixin.
form = Form(
    ...,
    Button("Send").submit()
)

Method toggle

Toggles an other web component.
toggle(target)
Arguments
Name Type Description
target WebComponent The web component to toggle.
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button, Dialog

# Note, that Button inherits ActionMixin.
dialog = Dialog(...)
button = Button("Open").toggle(dialog)

Class AppearanceMixin

Mixin for a web component which appearance can be associated with predefined categories.
AppearanceMixin()

Method as_danger

Makes the 'danger' look to a web components.
as_danger()
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits AppearanceMixin.
button = ("Danger").as_danger()

Method as_dark

Makes the 'dark' look to a web components.
as_dark()
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits AppearanceMixin.
button = ("Dark").as_dark()

Method as_info

Makes the 'info' look to a web components.
as_info()
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits AppearanceMixin.
button = ("Info").as_info()

Method as_light

Makes the 'light' look to a web components.
as_light()
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits AppearanceMixin.
button = ("Light").as_light()

Method as_primary

Makes the 'primary' look to a web components.
as_primary()
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits AppearanceMixin.
button = ("Primary").as_primary()

Method as_secondary

Makes the 'secondary' look to a web components.
as_secondary()
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits AppearanceMixin.
button = ("Secondary").as_secondary()

Method as_success

Makes the 'success' look to a web components.
as_success()
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits AppearanceMixin.
button = ("Success").as_success()

Method as_warning

Makes the 'warning' look to a web components.
as_warning()
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits AppearanceMixin.
button = ("Warning").as_warning()

Class OutlineMixin

Mixin for a web component that can be surrounded by a border.
OutlineMixin()

Usually OutlineMixin is used in conjunction with AppearanceMixin to specify the border appearance.

Method as_outline

Makes the web component surrounded by a border.
as_outline()
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits AppearanceMixin.
button = ("Primary").as_primary().as_outline()

Class AvailabilityMixin

Mixin for a web component which can be enabled or disabled.
AvailabilityMixin()

By default, every web component is enabled. The web components inheriting this class can be forced to be disabled.

Method as_disabled

Disables a web component.
as_disabled()
Returns
Name Type Description
obj self The instance of this class.
Example
from bootwrap import Button

# Note, that Button inherits AppearanceMixin.
button = ("Primary").as_disabled()

Class Breakpoint

The breakpoint constants.

Breakpoints are defined by Bootstrap and mostly based on minimum viewport widths and allow us to scale up elements as the viewport changes.

See for more information.

Breakpoint. LG
Breakpoint. MD
Breakpoint. SM
Breakpoint. XL
Breakpoint. XS

Class Action

The action constants.
Action. DISMISS
Action. LINK
Action. SUBMIT
Action. TOGGLE