From 240b12bf0c8362a9768ad66b8f14aab7279a8476 Mon Sep 17 00:00:00 2001 From: Wlad Meixner Date: Thu, 31 Jul 2025 11:44:14 +0200 Subject: [PATCH] feat: add generic prose component --- src/components/typography.tsx | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/components/typography.tsx b/src/components/typography.tsx index 6c88508..e328c03 100644 --- a/src/components/typography.tsx +++ b/src/components/typography.tsx @@ -1 +1,27 @@ -export const Prose = (props: React.PropsWithChildren<{ className?: string }>) =>
{props.children}
; \ No newline at end of file +import { Slot } from "@radix-ui/react-slot"; +import * as React from "react"; + +interface ProseProps { + asChild?: boolean; + as?: T; + className?: string; +} + +const Prose = React.forwardRef< + HTMLDivElement, + ProseProps & React.ComponentPropsWithoutRef<"div"> +>(({ asChild = false, as, className, ...props }, ref) => { + if (asChild) { + return ; + } + + const Component = as || "div"; + + return ( + + ); +}); + +Prose.displayName = "Prose"; + +export { Prose, type ProseProps };