Textarea

Used to enter free form text that spans over multiple lines of text.

Installation

import { Textarea } from "@octopusdeploy/design-system-components"

Properties

Using the Text Field component

When setting up a Text Field component you will need to import Textarea from the design-system-components package and enable the desired props as shown above.

For example:


                                                        
                                                        
                                                            <Textarea
                                                            value={description}
                                                            onChange={() => ()}
                                                            label="Label for the Textarea"
                                                            description="Description for the text area"
                                                            error={error}
                                                        />
                                                        
                                                            

Setting the height of the Textarea

The initial height of the Textarea component is determined by the number of rows, by default it is set to 4, which is approximately 7rem. By determining the height based on the rows we ensure a line of text is not cut off. To adjust the height, you can adjust the number of rows. If your text exceeds the number of rows, the Textarea will automatically enable the scrollbar so the user can scroll the Textarea (you also have the option of adding autosize, see below.)

For example:


                                                        
                                                        
                                                            <Textarea
                                                            value={description}
                                                            onChange={() => ()}
                                                            label="Label for the Textarea"
                                                            description="Description for the text area"
                                                            error={error}
                                                            rows={5}
                                                        />
                                                        
                                                            

Using the autosize property

The height of the Textarea can be set to adjust the height automatically based on the amount of content via the autosize property. The rows as outlined above will set the initial height, if the content exceeds the number of rows and autosize is set, instead of a scrollbar it will increase the height of the Textarea.

We recommend using this feature sparingly as it has implications for performance if the Textarea pushes content down the page and requires the browser to re-calculate positions.

Restricting the number of characters

You can restrict the number of characters allowed in the Textarea with the minLength and maxLength props. They can be used on their own or together.

For example:


                                                        
                                                        
                                                            <Textarea
                                                            value={description}
                                                            onChange={() => ()}
                                                            label="Label for the Textarea"
                                                            description="Description for the text area"
                                                            error={error}
                                                            label="Limited textarea (10-200 characters)" 
                                                            placeholder="Between 10 and 200 characters" 
                                                            minLength={10} 
                                                            maxLength={200}
                                                        />
                                                        
                                                            

Form Description

Form descriptions allow you to pass in a string, with the option to include an inline code descriptor or link. It has a particular format to allow for flexibility. You can include as many links or code descriptors as you need.

For example:


                                                        
                                                        
                                                             descriptionText`Set ${descriptionText.code("itemEnabled")} to true or see our ${descriptionText.link("guide", "/docs/guide")} for more details.`
                                                        
                                                            

The above code will render the following:

Adding a Popover to the label

This is used to display a Popover with more content explaining the context of a field. It should only be used when the Helper Text is not sufficient.

To include this you can pass the PopoverBasicHelp component to the popover prop, e.g.:


                                                        
                                                        
                                                            <Textarea
                                                            value={description}
                                                            onChange={() => ()}
                                                            label="Label for the Textarea with popover"
                                                            description="Description for the text area"
                                                            error={error}
                                                            popover={<PopoverBasicHelp placement="right-start" description="A popover" />}
                                                        />
                                                        
                                                            

Monospaced

If you require the text in the Textarea to use a monospaced font, you can set the monospace prop to true


                                                        
                                                        
                                                            <Textarea
                                                            value={description}
                                                            onChange={() => ()}
                                                            label="Label for the Textarea"
                                                            description="Description for the text area"
                                                            error={error}
                                                            monospace={true}
                                                        />
                                                        
                                                            

Displaying a validation message

To display a validation message, use the validationMessage prop. By default this will be displayed as an error. The validationState prop can be set to "success" if a success message is needed.

Code Sub-components

Sub-components are used to compose the Form components in the Design System, however they are not exposed via the design system package and therefore cannot be used on their own. Instead, use the packaged components we ship, e.g. Textarea , Textfield etc.

Should you require changes to the sub components please reach out in #team-frontend-foundations-requests or follow the Contribution guidelines.

Name

Description

InputLabel

Renders the label for the input item

InputError

Renders the error message and icon for the component

FormDescription

Renders a text description with optional links, or inline code descriptors

All states