Box reference#
Box is a basic layout in Nelsie. It represents a rectangular area on the slide.
A new box is created by calling the .box()
method on an existing box or a slide. This will return a new box that will be a child of the element on which you call the box method.
Parameters of .box()
#
Step-related parameters#
show
- Defines the steps in which the box (its contents and children) is displayed. It only affects the drawing itself. The layout is always calculated, i.e. the space is reserved for the box, even in the steps where it is not painted. Takes the following types:bool
- the box is shown (True
) or hidden (False
) in all steps.int
- the box is shown only in the given stepstr
- a string may have the following format:"<number>"
- the box is shown only in the given step"<number>+"
- the box is shown in the given step and all following steps"<number>-<number>"
- the box is shown in the steps in the given range.- Comma separated list of the expression above. Then the box is shown in the union of steps defined by expressions. Example:
"1, 5, 20-30, 35+"
.
active
- Takes the same parameters asshow
but in steps when the box is not active, it is also removed from the layout, i.e. no space is reserved for the box.replace_steps
- TakesNone
or a dictionary that maps
Ordering parameters#
z_level
- An integer value used in painting order. Higher numbers are drawn later. If not set, the value is inherited from the parent box. The default value of the slide root box is0
.
Background parameters#
bg_color
- Sets a background color of the box. IfNone
, no background is drawn. Default:None
.border_radius
- A radius of the box's rounded corner. If0
then no border is not rounded. Default:0
.
Layout parameters#
x
-- X position of the boxy
-- Y position of the boxwidth
-- Width of the boxNone
- (default) Automatic size. Minimum size around the content ifflex-grow
/flex-shrink
is not set.int
orfloat
orstr
containing digits -- A fixed size given in pixels (example:20.5
, or"1.5"
)str
in format"X%"
whereX
is an integer -- A relative size to the parent box, in percent (example:"50%"
)LayoutExpr
-- A fixed size defined by a layout expression.
height
- Height of the box- The paramter takes the same values as
width
.
- The paramter takes the same values as
row
- IfTrue
then the box arranges its children horizontally; otherwise vertically. Default:False
reverse
- IfTrue
then child boxes are ordered in the reverse order; i.e. in bottom-up (or right-left ifrow
isTrue
) Default:False
.flex_wrap
-flex_grow
- Theflex_grow
parameter takes afloat
value. The default is0
. This attribute specifies how much of the remaining space of its parent box should be allocated to this box. The remaining space is the size of the box minus the size of all its children. If multiple sibling boxes have positiveflex_grow
values, it is distributed according to the ratio defined by their values. This property is equivalent to the CSS propertyflex-grow
.flex_shrink
- Theflex_grow
parameter takes afloat
value. The default is0
. If the size of all flex items is larger than the flex container, items shrink to fit according toflex_shrink
. This property is equivalent to the CSS propertyflex-grow
.align_items
-align_self
-justify_self
-align_content
-justify_content
-gap
-grid_template_rows
- Grid layout definition, see CSS grid for semanticsint
- Size of row in pixelsstr
"X"
if X is integer -- size in pixels"X%"
size in percent"X fr"
size in fractions
grid_template_columns
- Same asgrid_template_rows
grid_row
- Grid layout definition, see CSS grid for semantics."auto"
- Automatic position"span X"
- Span over more rowsint
- Specific row, indexed from 1, negative allowed(int, int)
- Spans over more rows; first number is start is starting row index, the second number is end row index(int, "span X")
- Spans over more rows; first number is start is starting row index, X is how many rows it spans over
grid_column
- Same asgrid_row
Padding parameters#
p_left
- Left paddingp_right
- Right paddingp_top
- Top paddingp_bottom
- Bottom paddingp_x
- Shortcut for settingp_left
andp_right
to the same valuep_y
- Shortcut for settingp_top
andp_bottom
to the same value
Margin parameters#
m_left
- Left marginm_right
- Right marginm_top
- Top marginm_bottom
- Bottom marginm_x
- Shortcut for settingm_left
andm_right
to the same valuem_y
- Shortcut for settingm_top
andm_bottom
to the same value
Debugging parameters#
name
- The name of the slide. It is displayed when the layout debugging view is enabled.debug_layout
- Enables/disables the layout debugging view for the box. IfTrue
then the view will be enabled with the view will be enabled with the default colour for this box. Ifstr
is given then the view is enabled and the string is interpreted as the colour of the debugging view (e.g.debug_view="green"
). IfFalse
then the debugging view is disabled for this box, even if the whole slide has the debugging view enabled.