box.py 834 B

1234567891011121314151617181920212223242526272829303132
  1. """A box component that can contain other components."""
  2. from typing import Optional
  3. from reflex.components.chakra import ChakraComponent
  4. from reflex.components.tags import Tag
  5. from reflex.vars import Var
  6. class Box(ChakraComponent):
  7. """A generic container component that can contain other components."""
  8. tag = "Box"
  9. # The type element to render. You can specify an image, video, or any other HTML element such as iframe.
  10. element: Optional[Var[str]] = None
  11. # The source of the content.
  12. src: Optional[Var[str]] = None
  13. # The alt text of the content.
  14. alt: Optional[Var[str]] = None
  15. def _render(self) -> Tag:
  16. return (
  17. super()
  18. ._render()
  19. .add_props(
  20. **{
  21. "as": self.element,
  22. }
  23. )
  24. )