import { ReactNode } from 'react'; import classnames from 'classnames'; import styles from './FormErrorMessage.css'; import helperTextStyles from './FormHelperText.css'; import Box from '../Box'; import Flex from '../Flex'; import IconCompact from '../IconCompact'; import Text from '../Text'; import useExperimentalTheme from '../utils/useExperimentalTheme'; type SizeType = 'sm' | 'md' | 'lg'; type Props = { id: string; text?: ReactNode; size?: SizeType; noPadding?: boolean; marginTop?: boolean; }; export default function FormErrorMessage({ id, size, text = '', noPadding: noStartPadding, marginTop, }: Props) { const theme = useExperimentalTheme(); return (
{/* Class used to ensure all children are font size "sm" */} {/* This error message is accessible by screenreaders. It alerts the user right when the error message is presented to the user. While error messages are visually apparent to users who can see the page, they may not be obvious to users of assistive technologies. This role="alert" provides a way to programmatically expose dynamic content changes in a way that can be announced by assistive technologies. */} {text}
); }