TextArea
Captures text over several lines. `autosize` grows the field with the content.
Health
Source
Design
Storybook
Playground
No Example
Accessibility
compliant
Platform
Universal
- Overview
- Props
- Figma
Usage
Input help text
Autosize
When using the autosize prop, the component will automatically resize to fit the content. This is useful for capturing long-form text input. This behavior is always active when the on mobile.
Controlled
import { useState } from "react";
import { TextArea } from "murray";
function Demo() {
const [value, setValue] = useState("");
return <TextArea value={value} onChange={(newValue) => setValue(newValue)} />;
}
Error state
Invalid name
Disabled state
Condensed theme
For applications with condensed theme density, this component renders in a condensed style:
With SX prop
You can pass positional props to the component:
Usage in <Form>
On web, TextArea can be used in <Form> component and be controleld by Formik:
Playground
Loading...
tip
This component is universal, its usage is the same in
murray and murray/mobile.TextArea props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| aria-describedby | string | Id of an element outside the input that also describes it, such as an error shared by several inputs | ||
| aria-label | string | Accessibility label, only necessary when not associated with a label | ||
| aria-labelledby | string | |||
| aria-required | boolean | Overrides `aria-required` set by `required`, to mark the input as mandatory without the asterisk | ||
| autoFocus | boolean | If true, focuses the input on componentDidMount.The default value is false. | ||
| autosize | boolean | If true, multiline input will automatically grow based on its content, up to `numberOfLines`. On iOS, it starts at a single line instead of the `numberOfLines` height. | ||
| cursor | Cursor | Enforce a cursor type | ||
| defaultValue | string | Uncontrolled default value. | ||
| disabled | boolean | Disable input | ||
| enterKeyHint | "search""done""go""next""send" | |||
| error | ReactNode | Contents of `InputError` component, if not set, error is not rendered. | ||
| focused | boolean | Show focus styles even when the input isn't focused, e.g. while a readonly input's picker is open | ||
| helpText | ReactNode | Contents of `InputHelp` component, if not set, description is not rendered. | ||
| id | string | |||
| label | ReactNode | |||
| max | stringnumber | |||
| maxLength | number | Maximum string length that the user can enter in UTF-16 code units | ||
| min | stringnumber | |||
| minLength | number | Maximum string length that the user can enter in UTF-16 code units | ||
| name | string | Html input name | ||
| numberOfLines | number | Enforce a number of lines when input is multiline. | ||
| onChange | ((value: string) => void) | Trigger when input value is changing | ||
| onPress | ((event: GestureResponderEvent) => void) | |||
| placeholder | string | |||
| readonly | boolean | Make input readonly | ||
| render | 1 possibilities((elements: { input: ReactNode; prefix?: ReactNode; suffix?: ReactNode; }, pseudoState: PseudoState) => ReactNode) | Fully control how input, prefix and suffix are rendererd | ||
| renderPlaceholder | (() => ReactNode) | To render a custom placeholder view when the field is empty | ||
| required | boolean | Adds required attribute to the input and a red asterisk on the right side of label, `false` by default Determines whether the input should have `aria-required` attribute | ||
| resize | Resize | Enforce a resize type when input is multiline | ||
| step | stringnumber | |||
| sx | PositionProps | Positioning properties | ||
| title | string | Html input title | ||
| type | HTMLInputTypeAttribute | HTML input type | ||
| value | string | Control the input. |
Undocumented props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| clearButtonMode | any | |||
| enablesReturnKeyAutomatically | any | |||
| onBlur | any | |||
| onFocus | any | |||
| onKeyPress | any | |||
| ref | any | |||
| returnKeyType | any | |||
| submitBehavior | any |
Style API
Use sx for one-off adjustments. It accepts these style keys:
alignSelfanimationaspectRatiobottomcursordisplayendflexflexBasisflexGrowflexShrinkheightinsetinsetInlineinsetInlineEndinsetInlineStartleftmarginmarginBottommarginHorizontalmarginInlinemarginInlineEndmarginInlineStartmarginLeftmarginRightmarginTopmarginVerticalmatrixmaxHeightmaxWidthminHeightminWidthopacityperspectivepositionrightrotaterotateXrotateYrotateZscalescaleXscaleYskewXskewYstarttoptransformtransformOriginwidthxyzIndex
Each can be overridden per breakpoint with:
$lg$ltLg$ltMd$ltSm$ltVs$ltXl$ltXxl$md$sm$vs$xl$xs$xxl