chore: readd classname to formgroup (#1215)
This commit is contained in:
parent
64817aa43e
commit
8e70f5face
@ -3,6 +3,7 @@ import type { ReactNode } from 'react';
|
|||||||
|
|
||||||
export interface FormGroupProps {
|
export interface FormGroupProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
|
className?: string;
|
||||||
label: string; // For accessibility reasons this must always be set for screen readers. If you want it to not show, then add labelClassName="sr-only"
|
label: string; // For accessibility reasons this must always be set for screen readers. If you want it to not show, then add labelClassName="sr-only"
|
||||||
labelFor: string; // Same as above
|
labelFor: string; // Same as above
|
||||||
hideLabel?: boolean;
|
hideLabel?: boolean;
|
||||||
@ -11,17 +12,19 @@ export interface FormGroupProps {
|
|||||||
|
|
||||||
export const FormGroup = ({
|
export const FormGroup = ({
|
||||||
children,
|
children,
|
||||||
|
className,
|
||||||
label,
|
label,
|
||||||
labelFor,
|
labelFor,
|
||||||
labelAlign = 'left',
|
labelAlign = 'left',
|
||||||
hideLabel = false,
|
hideLabel = false,
|
||||||
}: FormGroupProps) => {
|
}: FormGroupProps) => {
|
||||||
|
const wrapperClasses = classNames('relative mb-6', className);
|
||||||
const labelClasses = classNames('block mb-2 text-sm', {
|
const labelClasses = classNames('block mb-2 text-sm', {
|
||||||
'text-right': labelAlign === 'right',
|
'text-right': labelAlign === 'right',
|
||||||
'sr-only': hideLabel,
|
'sr-only': hideLabel,
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<div data-testid="form-group" className="relative mb-6">
|
<div data-testid="form-group" className={wrapperClasses}>
|
||||||
{label && (
|
{label && (
|
||||||
<label htmlFor={labelFor} className={labelClasses}>
|
<label htmlFor={labelFor} className={labelClasses}>
|
||||||
{label}
|
{label}
|
||||||
|
Loading…
Reference in New Issue
Block a user