You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/react/components/form-components/InputGroup/InputGroupAddon.tsx

32 lines
702 B

import { ComponentType, PropsWithChildren } from 'react';
import clsx from 'clsx';
import { useInputGroupContext } from './InputGroup';
type BaseProps<TProps> = {
as?: ComponentType<TProps> | string;
required?: boolean;
className?: string;
};
export function InputGroupAddon<TProps>({
children,
as = 'span',
className,
required,
...props
}: PropsWithChildren<BaseProps<TProps> & TProps>) {
useInputGroupContext();
const Component = as as 'span';
return (
<Component
className={clsx('input-group-addon', required && 'required', className)}
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
>
{children}
</Component>
);
}