From ea2a5904f28c51c9ba08dfa7585120c6726622e6 Mon Sep 17 00:00:00 2001 From: Alek Petuskey Date: Wed, 7 Feb 2024 18:53:59 -0800 Subject: [PATCH] Text default as p (#2551) --- reflex/components/radix/themes/typography/text.py | 6 +++++- reflex/components/radix/themes/typography/text.pyi | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/reflex/components/radix/themes/typography/text.py b/reflex/components/radix/themes/typography/text.py index c0783bf92..4ed426d15 100644 --- a/reflex/components/radix/themes/typography/text.py +++ b/reflex/components/radix/themes/typography/text.py @@ -4,6 +4,8 @@ https://www.radix-ui.com/themes/docs/theme/typography """ from __future__ import annotations +from typing import Literal + from reflex import el from reflex.vars import Var @@ -18,6 +20,8 @@ from .base import ( LiteralTextWeight, ) +LiteralType = Literal["p", "label", "div", "span"] + class Text(el.Span, RadixThemesComponent): """A foundational text primitive based on the element.""" @@ -28,7 +32,7 @@ class Text(el.Span, RadixThemesComponent): as_child: Var[bool] # Change the default rendered element into a semantically appropriate alternative (cannot be used with asChild) - as_: Var[str] + as_: Var[LiteralType] = "p" # type: ignore # Text size: "1" - "9" size: Var[LiteralTextSize] diff --git a/reflex/components/radix/themes/typography/text.pyi b/reflex/components/radix/themes/typography/text.pyi index d4e33d785..fa5aa6f07 100644 --- a/reflex/components/radix/themes/typography/text.pyi +++ b/reflex/components/radix/themes/typography/text.pyi @@ -7,11 +7,14 @@ from typing import Any, Dict, Literal, Optional, Union, overload from reflex.vars import Var, BaseVar, ComputedVar from reflex.event import EventChain, EventHandler, EventSpec from reflex.style import Style +from typing import Literal from reflex import el from reflex.vars import Var from ..base import LiteralAccentColor, RadixThemesComponent from .base import LiteralTextAlign, LiteralTextSize, LiteralTextTrim, LiteralTextWeight +LiteralType = Literal["p", "label", "div", "span"] + class Text(el.Span, RadixThemesComponent): @overload @classmethod @@ -82,7 +85,12 @@ class Text(el.Span, RadixThemesComponent): ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, - as_: Optional[Union[Var[str], str]] = None, + as_: Optional[ + Union[ + Var[Literal["p", "label", "div", "span"]], + Literal["p", "label", "div", "span"], + ] + ] = None, size: Optional[ Union[ Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]],