diff options
Diffstat (limited to 'src/components/atoms/lists/description-list/term.tsx')
| -rw-r--r-- | src/components/atoms/lists/description-list/term.tsx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/components/atoms/lists/description-list/term.tsx b/src/components/atoms/lists/description-list/term.tsx new file mode 100644 index 0000000..0d21f96 --- /dev/null +++ b/src/components/atoms/lists/description-list/term.tsx @@ -0,0 +1,28 @@ +import { + forwardRef, + type ForwardRefRenderFunction, + type HTMLAttributes, +} from 'react'; +import styles from './description-list.module.scss'; + +export type TermProps = HTMLAttributes<HTMLElement>; + +const TermWithRef: ForwardRefRenderFunction<HTMLElement, TermProps> = ( + { children, className = '', ...props }, + ref +) => { + const termClass = `${styles.term} ${className}`; + + return ( + <dt {...props} className={termClass} ref={ref}> + {children} + </dt> + ); +}; + +/** + * Term component. + * + * Use it inside a `DescriptionList` or a `Group` component. + */ +export const Term = forwardRef(TermWithRef); |
