wealth/packages/island/src/atoms/field-error/FieldError.tsx

27 lines
815 B
TypeScript

import { cn } from '../../tools/cn';
import { FlexBox } from '../flex-box';
import { Icon } from '../icon';
import { Typography } from '../typography';
import type { FieldErrorProps } from './types';
/**
* The error line under a group that has no field of its own, such as a set of chips, a consent
* box or a photo: an alert icon and the message, announced when it appears.
*/
export function FieldError({ id, className, children }: FieldErrorProps) {
return (
<FlexBox
id={id}
role="alert"
alignItems="items-start"
gap="gap-1"
className={cn('text-danger-text', className)}
>
<Icon name="alert" size={16} className="mt-[3px] flex-none" />
<Typography tag="span" variant="caption" color="inherit">
{children}
</Typography>
</FlexBox>
);
}