Input

Exports

Import these components from @mbsw/ui.

Field
Input

Props

The tables list common props for each component. See the full types for supported prop combinations and inherited HTML and Radix props.

Field

Field props
PropTypeRequirement
messageReactNodeRequired
status'default' | 'success' | 'error'Optional
currentLengthnumberConditional
maxLengthnumberConditional

Input

Input props
PropTypeRequirement
clearLabelstringOptional
leadingIconReactElement<unknown, string | JSXElementConstructor<any>>Optional
sizenumber | 'lg' | 'md' | 'sm' | 'xs'Optional

Type reference

Show full types

Full TypeScript definitions, including prop combinations and inherited props.

import { type HTMLAttributes, type InputHTMLAttributes, type ReactElement, type ReactNode, type Ref } from 'react';

export type InputSize = 'lg' | 'md' | 'sm' | 'xs';

export type FieldStatus = 'default' | 'success' | 'error';

type DataAttributes = {
    [key: `data-${string}`]: boolean | number | string | undefined;
};

export type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> & DataAttributes & {
    clearLabel?: string;
    leadingIcon?: ReactElement;
    size?: InputSize | number;
};

type FieldBaseProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & DataAttributes & {
    message: ReactNode;
    status?: FieldStatus;
};

type FieldWithCounterProps = {
    currentLength: number;
    maxLength: number;
};

type FieldWithoutCounterProps = {
    currentLength?: never;
    maxLength?: never;
};

export type FieldProps = FieldBaseProps & (FieldWithCounterProps | FieldWithoutCounterProps);

export declare const Input: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "size"> & DataAttributes & {
    clearLabel?: string;
    leadingIcon?: ReactElement;
    size?: InputSize | number;
} & import("react").RefAttributes<HTMLInputElement>>;

export declare const Field: import("react").ForwardRefExoticComponent<FieldProps & import("react").RefAttributes<HTMLDivElement>>;