Skip to content

Styles

API

counterweight.styles.Style

layout class-attribute instance-attribute

layout: Flex = Field(default=Flex())

span class-attribute instance-attribute

span: Span = Field(default=Span())

margin class-attribute instance-attribute

margin: Margin = Field(default=Margin())

border class-attribute instance-attribute

border: Border | None = Field(default=None)

padding class-attribute instance-attribute

padding: Padding = Field(default=Padding())

content class-attribute instance-attribute

content: Content = Field(default=Content())

typography class-attribute instance-attribute

typography: Typography = Field(default=Typography())

counterweight.styles.Flex

type class-attribute instance-attribute

type: Literal['flex'] = 'flex'

direction class-attribute instance-attribute

direction: Literal['row', 'column'] = 'row'

position class-attribute instance-attribute

position: Relative | Absolute | Fixed = Field(
    default=Relative(), discriminator="type"
)

weight class-attribute instance-attribute

weight: PositiveInt | None = 1

z class-attribute instance-attribute

z: int = 0

align_self class-attribute instance-attribute

align_self: Literal[
    "none", "start", "center", "end", "stretch"
] = "none"

justify_children class-attribute instance-attribute

justify_children: Literal[
    "start",
    "center",
    "end",
    "space-between",
    "space-around",
    "space-evenly",
] = "start"

align_children class-attribute instance-attribute

align_children: Literal[
    "start", "center", "end", "stretch"
] = "start"

gap_children class-attribute instance-attribute

gap_children: NonNegativeInt = 0

counterweight.styles.Span

width class-attribute instance-attribute

width: int | Literal['auto'] = Field(default='auto')

height class-attribute instance-attribute

height: int | Literal['auto'] = Field(default='auto')

counterweight.styles.Margin

top class-attribute instance-attribute

top: int = Field(default=0)

bottom class-attribute instance-attribute

bottom: int = Field(default=0)

left class-attribute instance-attribute

left: int = Field(default=0)

right class-attribute instance-attribute

right: int = Field(default=0)

color class-attribute instance-attribute

color: Color = Field(default=from_name('black'))

counterweight.styles.Border

kind class-attribute instance-attribute

kind: BorderKind = Field(default=Light)

style class-attribute instance-attribute

style: CellStyle = Field(default=CellStyle())

edges class-attribute instance-attribute

edges: frozenset[BorderEdge] = frozenset(
    {Top, Bottom, Left, Right}
)

contract class-attribute instance-attribute

contract: int = Field(default=0)

counterweight.styles.Padding

top class-attribute instance-attribute

top: int = Field(default=0)

bottom class-attribute instance-attribute

bottom: int = Field(default=0)

left class-attribute instance-attribute

left: int = Field(default=0)

right class-attribute instance-attribute

right: int = Field(default=0)

color class-attribute instance-attribute

color: Color = Field(default=from_name('black'))

counterweight.styles.Typography

style class-attribute instance-attribute

style: CellStyle = Field(default=CellStyle())

justify class-attribute instance-attribute

justify: Literal['left', 'center', 'right'] = 'left'

wrap class-attribute instance-attribute

wrap: Literal['none', 'paragraphs'] = 'none'

counterweight.styles.Color

red instance-attribute

red: int

green instance-attribute

green: int

blue instance-attribute

blue: int

hex property

hex: str

from_name classmethod

from_name(name: str) -> Color

from_hex cached classmethod

from_hex(hex: str) -> Color

blend

blend(other: Color, alpha: float) -> Color

counterweight.styles.CellStyle

foreground class-attribute instance-attribute

foreground: Color = Field(default=from_name('white'))

background class-attribute instance-attribute

background: Color = Field(default=from_name('black'))

bold class-attribute instance-attribute

bold: bool = False

dim class-attribute instance-attribute

dim: bool = False

italic class-attribute instance-attribute

italic: bool = False

underline class-attribute instance-attribute

underline: bool = False

strikethrough class-attribute instance-attribute

strikethrough: bool = False

counterweight.styles.Relative

Relative positioning is relative to the parent element's content box. Elements occupy space and are laid out next to their siblings according to the parent's layout direction.

type class-attribute instance-attribute

type: Literal['relative'] = 'relative'

x class-attribute instance-attribute

x: int = 0

y class-attribute instance-attribute

y: int = 0

counterweight.styles.Absolute

Absolute positioning is relative to the parent element's content box, but the element does not occupy space in the layout.

The inset property determines which corner of the parent element's content box this element is positioned relative to.

type class-attribute instance-attribute

type: Literal['absolute'] = 'absolute'

x class-attribute instance-attribute

x: int = 0

y class-attribute instance-attribute

y: int = 0

inset class-attribute instance-attribute

inset: Inset = Field(default=Inset())

counterweight.styles.Fixed

Fixed positioning is relative to the screen's top-left corner (0, 0).

type class-attribute instance-attribute

type: Literal['fixed'] = 'fixed'

x class-attribute instance-attribute

x: int = 0

y class-attribute instance-attribute

y: int = 0