mirror of
https://github.com/foomo/ui.git
synced 2025-10-16 12:45:34 +00:00
feat: add generic prose component
This commit is contained in:
parent
9dcc6ea98d
commit
240b12bf0c
@ -1 +1,27 @@
|
|||||||
export const Prose = (props: React.PropsWithChildren<{ className?: string }>) => <div className={`prose ${props.className}`}>{props.children}</div>;
|
import { Slot } from "@radix-ui/react-slot";
|
||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
interface ProseProps<T extends React.ElementType = "div"> {
|
||||||
|
asChild?: boolean;
|
||||||
|
as?: T;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Prose = React.forwardRef<
|
||||||
|
HTMLDivElement,
|
||||||
|
ProseProps & React.ComponentPropsWithoutRef<"div">
|
||||||
|
>(({ asChild = false, as, className, ...props }, ref) => {
|
||||||
|
if (asChild) {
|
||||||
|
return <Slot ref={ref} className={`prose ${className || ""}`} {...props} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Component = as || "div";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Component ref={ref} className={`prose ${className || ""}`} {...props} />
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
Prose.displayName = "Prose";
|
||||||
|
|
||||||
|
export { Prose, type ProseProps };
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user