1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 07:16:36 +01:00
metamask-extension/ui/components/component-library/label/label.tsx

40 lines
1.0 KiB
TypeScript
Raw Permalink Normal View History

import React from 'react';
import classnames from 'classnames';
import { Text } from '../text';
import type { TextProps } from '../text';
import {
FontWeight,
TextVariant,
Display,
AlignItems,
} from '../../../helpers/constants/design-system';
import type { PolymorphicRef } from '../box';
import { LabelProps, LabelComponent } from './label.types';
export const Label: LabelComponent = React.forwardRef(
<C extends React.ElementType = 'label'>(
{ htmlFor, className, children, ...props }: LabelProps<C>,
ref?: PolymorphicRef<C>,
) => {
return (
<Text
className={classnames(
'mm-label',
{ 'mm-label--html-for': Boolean(htmlFor) },
className ?? '',
)}
as="label"
htmlFor={htmlFor}
variant={TextVariant.bodyMd}
fontWeight={FontWeight.Medium}
display={Display.InlineFlex}
alignItems={AlignItems.center}
ref={ref}
{...(props as TextProps<C>)}
>
{children}
</Text>
);
},
);