diff options
Diffstat (limited to 'src/components/molecules/card/card-title.tsx')
| -rw-r--r-- | src/components/molecules/card/card-title.tsx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/components/molecules/card/card-title.tsx b/src/components/molecules/card/card-title.tsx new file mode 100644 index 0000000..09d61ea --- /dev/null +++ b/src/components/molecules/card/card-title.tsx @@ -0,0 +1,27 @@ +import { type ForwardRefRenderFunction, forwardRef } from 'react'; +import { Heading, type HeadingProps } from '../../atoms'; +import styles from './card.module.scss'; + +export type CardTitleProps = Omit<HeadingProps, 'level'> & { + /** + * The title level (between 1 and 6). + * + * @default 2 + */ + level?: HeadingProps['level']; +}; + +const CardTitleWithRef: ForwardRefRenderFunction< + HTMLHeadingElement, + CardTitleProps +> = ({ children, className = '', level = 2, ...props }, ref) => { + const headingClass = `${styles.title} ${className}`; + + return ( + <Heading {...props} className={headingClass} level={level} ref={ref}> + {children} + </Heading> + ); +}; + +export const CardTitle = forwardRef(CardTitleWithRef); |
