diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-10-04 18:16:55 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-11 18:14:41 +0100 |
| commit | a724b4b38bacc631410627395b0d1190a0e8de0d (patch) | |
| tree | 27bd2704fbaf2c3c7455e5cd424765df91db3d02 /src/components/atoms/visually-hidden/visually-hidden.tsx | |
| parent | 0e60743d140aff66eca6df712f653ee20f5d4ef3 (diff) | |
feat(components): add a VisuallyHidden component
Diffstat (limited to 'src/components/atoms/visually-hidden/visually-hidden.tsx')
| -rw-r--r-- | src/components/atoms/visually-hidden/visually-hidden.tsx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/components/atoms/visually-hidden/visually-hidden.tsx b/src/components/atoms/visually-hidden/visually-hidden.tsx new file mode 100644 index 0000000..a877321 --- /dev/null +++ b/src/components/atoms/visually-hidden/visually-hidden.tsx @@ -0,0 +1,26 @@ +import type { FC, HTMLAttributes, ReactNode } from 'react'; +import styles from './visually-hidden.module.scss'; + +export type VisuallyHiddenProps = Omit< + HTMLAttributes<HTMLSpanElement>, + 'children' +> & { + /** + * The contents to visually hide. + */ + children: ReactNode; +}; + +export const VisuallyHidden: FC<VisuallyHiddenProps> = ({ + children, + className = '', + ...props +}) => { + const wrapperClass = `${styles.wrapper} ${className}`; + + return ( + <span {...props} className={wrapperClass}> + {children} + </span> + ); +}; |
