aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/atoms/lists/description-list/term.tsx
blob: 0d21f96d1dae5067b8b8ec9abfcbc1bcdd23b8a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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);