aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/atoms/lists/description-list/description.tsx
blob: 9fa7ecd0224e183efb5f11afbc0ab61dbea5e03a (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 DescriptionProps = HTMLAttributes<HTMLElement>;

const DescriptionWithRef: ForwardRefRenderFunction<
  HTMLElement,
  DescriptionProps
> = ({ children, className = '', ...props }, ref) => {
  const descriptionClass = `${styles.description} ${className}`;

  return (
    <dd {...props} className={descriptionClass} ref={ref}>
      {children}
    </dd>
  );
};

/**
 * Description component.
 *
 * Use it inside a `DescriptionList` or a `Group` component.
 */
export const Description = forwardRef(DescriptionWithRef);