1
0

flex.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. """Declarative layout and common spacing props."""
  2. from __future__ import annotations
  3. from typing import ClassVar, Literal
  4. from reflex.components.core.breakpoints import Responsive
  5. from reflex.components.el import elements
  6. from reflex.components.radix.themes.base import (
  7. LiteralAlign,
  8. LiteralJustify,
  9. LiteralSpacing,
  10. RadixThemesComponent,
  11. )
  12. from reflex.vars.base import Var
  13. LiteralFlexDirection = Literal["row", "column", "row-reverse", "column-reverse"]
  14. LiteralFlexWrap = Literal["nowrap", "wrap", "wrap-reverse"]
  15. class Flex(elements.Div, RadixThemesComponent):
  16. """Component for creating flex layouts."""
  17. tag = "Flex"
  18. # Change the default rendered element for the one passed as a child, merging their props and behavior.
  19. as_child: Var[bool]
  20. # How child items are laid out: "row" | "column" | "row-reverse" | "column-reverse"
  21. direction: Var[Responsive[LiteralFlexDirection]]
  22. # Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch"
  23. align: Var[Responsive[LiteralAlign]]
  24. # Alignment of children along the cross axis: "start" | "center" | "end" | "between"
  25. justify: Var[Responsive[LiteralJustify]]
  26. # Whether children should wrap when they reach the end of their container: "nowrap" | "wrap" | "wrap-reverse"
  27. wrap: Var[Responsive[LiteralFlexWrap]]
  28. # Gap between children: "0" - "9"
  29. spacing: Var[Responsive[LiteralSpacing]]
  30. # Reflex maps the "spacing" prop to "gap" prop.
  31. _rename_props: ClassVar[dict[str, str]] = {"spacing": "gap"}
  32. flex = Flex.create