Learn how to customize the theme and styles for input component, the theme object for input component has three main objects:
A. The defaultProps
object for setting up the default value for props of input component.
B. The valid
object for customizing the valid values for input component props.
C. The styles
object for customizing the theme and styles of input component.
You can customize the theme and styles of input component by adding Tailwind CSS classes as key paired values for objects.
Variant of Input
component theme has a specific type of Input Variant Styles Type
interface InputStylesType {
defaultProps: {
variant: string;
size: string;
color: string;
label: string;
error: boolean;
success: boolean;
icon: node;
labelProps: object;
className: string;
};
valid: {
variants: string[];
sizes: string[];
colors: string[];
};
styles: {
base: {
container: object;
input: object;
label: object;
icon: object;
};
variants: {
outlined: InputVariantStylesType;
standard: InputVariantStylesType;
static: InputVariantStylesType;
};
};
}
import type { InputStylesType } from "@material-tailwind/react";
Input variant object type contains two specific types of Input Size Styles Type and Input State Styles Type
interface InputVariantStylesType {
base: {
input: object;
inputWithIcon: object;
icon: object;
label: object;
};
sizes: {
md: InputSizeStylesType;
lg: InputSizeStylesType;
};
colors: {
input: object;
label: object;
};
error: InputStateStylesType;
success: InputStateStylesType;
}
import type { InputVariantStylesType } from "@material-tailwind/react";
interface InputSizeStylesType {
container: object;
input: object;
label: object;
icon: object;
}
import type { InputSizeStylesType } from "@material-tailwind/react";
interface InputStateStylesType {
input: object;
label: object;
}
import type { InputStateStylesType } from "@material-tailwind/react";
const theme = {
input: {
styles: {
base: {
container: {
position: "relative",
width: "w-full",
minWidth: "min-w-[200px]",
},
},
},
},
};