1
0

flex.py 1.5 KB

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