UNPKG

@react-md/form

Version:

This package is for creating all the different form input types.

84 lines (83 loc) 3.46 kB
import type { CSSProperties, HTMLAttributes, ReactNode, Ref, TextareaHTMLAttributes } from "react"; import type { TextFieldContainerOptions } from "./TextFieldContainer"; export declare type TextAreaResize = "none" | "auto" | "horizontal" | "vertical" | "both"; export interface TextAreaProps extends TextareaHTMLAttributes<HTMLTextAreaElement>, TextFieldContainerOptions { /** * An id to apply to the text area. This is required for a11y. */ id: string; /** * The value to use for the text field. This will make the component * controlled and require the `onChange` prop to be provided as well otherwise * this will act as a read only text field. */ value?: string; /** * The default value for the text field which will make it uncontrolled. If * you manually change the `defaultValue` prop, the input's value **will not * change** unless you provide a different `key` as well. Use the `value` prop * instead for a controlled input. */ defaultValue?: string; /** * An optional floating label to use for the text field. This should really * only be used when the `theme` prop is not set to `"none"`. This will be * wrapped in the `<Label>` component itself and automatically apply the * `htmlFor` prop for this text field. */ label?: ReactNode; /** * An optional style to apply to the label wrapper. */ labelStyle?: CSSProperties; /** * An optional className to apply to the label wrapper. */ labelClassName?: string; /** * An optional style to apply to the textarea element. The base `style` prop * is applied to the surrounding `div` instead. */ areaStyle?: CSSProperties; /** * An optional className to apply to the textarea element. The base `style` * prop is applied to the surrounding `div` instead. */ areaClassName?: string; /** * The number of rows to display by default. The textarea will automatically * update and animate its height when the users types if the `resize` prop is * set to `"auto"`. */ rows?: number; /** * The maximum number of rows that are allowed. When this is set to `-1`, it * will infinitely expand based on the text content. */ maxRows?: number; /** * Updates the resize ability for the textarea. Native textareas are resizable * both horizontally and vertically, but this component will prevent resizing * by default and instead animate height changes as the user types. */ resize?: TextAreaResize; /** * Boolean if the height changes should be animated when the `resize` prop is * set to `"auto"`. */ animate?: boolean; /** * An optional ref to apply to the text field's container div element. The * default ref is forwarded on to the `input` element. */ containerRef?: Ref<HTMLDivElement>; /** * Any additional html attributes that should be applied to the main container * div. This is probably only going to be used internally so that additional * accessibility can be added to text fields for more complex widgets. * * @remarks \@since 2.5.2 */ containerProps?: Omit<HTMLAttributes<HTMLDivElement>, "style" | "className">; } export declare const TextArea: import("react").ForwardRefExoticComponent<TextAreaProps & import("react").RefAttributes<HTMLTextAreaElement>>;