highlight.py 697 B

12345678910111213141516171819202122
  1. """A highlight component."""
  2. from typing import Dict, List, Optional
  3. from reflex.components.chakra import ChakraComponent
  4. from reflex.components.tags import Tag
  5. from reflex.vars import Var
  6. class Highlight(ChakraComponent):
  7. """Highlights a specific part of a string."""
  8. tag = "Highlight"
  9. # A query for the text to highlight. Can be a string or a list of strings.
  10. query: Optional[Var[List[str]]] = None
  11. # The style of the content.
  12. # Note: styles and style are different prop.
  13. styles: Var[Dict] = {"px": "2", "py": "1", "rounded": "full", "bg": "teal.100"} # type: ignore
  14. def _render(self) -> Tag:
  15. return super()._render().add_props(styles=self.style)