Component Blueprints
Textarea
- HTML/CSS:Dev Ready
- Web Component:True
- Layout:Responsive
Sections
Textarea inputs are used for freeform data entry.
About Textarea#
You can style the HTML <textarea>
element to align with the Salesforce brand by using the class .slds-textarea
on the <textarea>
element.
Base#
<div class="slds-form-element">
<label class="slds-form-element__label" for="textarea-id-01">Textarea Label</label>
<div class="slds-form-element__control">
<textarea id="textarea-id-01" placeholder="Placeholder text…" class="slds-textarea"></textarea>
States#
Disabled#
<div class="slds-form-element">
<label class="slds-form-element__label" for="textarea-id-01">Textarea Label</label>
<div class="slds-form-element__control">
<textarea id="textarea-id-01" disabled="" placeholder="Placeholder text…" class="slds-textarea"></textarea>
Required#
<div class="slds-form-element">
<label class="slds-form-element__label" for="textarea-id-01">
<abbr class="slds-required" title="required">* </abbr>Textarea Label</label>
<div class="slds-form-element__control">
Error#
Enter a value.
<div class="slds-form-element slds-has-error">
<label class="slds-form-element__label" for="textarea-id-01">
<abbr class="slds-required" title="required">* </abbr>Textarea Label</label>
<div class="slds-form-element__control">
Read only#
Textarea Label
Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Maecenas sed diam eget risus varius blandit sit amet non magna. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Nullam quis risus eget urna mollis ornare vel eu leo. Vestibulum id ligula porta felis euismod semper. Donec ullamcorper nulla non metus auctor fringilla. Maecenas faucibus mollis interdum.
<div class="slds-form-element">
<span class="slds-form-element__label">Textarea Label</span>
<div class="slds-form-element__control slds-border_bottom">
<div class="slds-form-element__static">
Styling Hooks Overview#
Use these CSS Custom Properties as hooks to customize this SLDS component with your own style. For more information, read the technical documentation.
Category | Styling Hook Name | Value Type(s) | Fallback Value |
---|---|---|---|
Box Shadow | --slds-c-textarea-shadow | String | |
--slds-c-textarea-shadow-focus | String | 0 0 3px #0176d3 | |
Color | --slds-c-textarea-color-background | Color | white |
--slds-c-textarea-color-background-error-focus | Color | white | |
--slds-c-textarea-color-background-focus | Color | white | |
--slds-c-textarea-color-border | Color | #c9c9c9 | |
--slds-c-textarea-color-border-focus | Color | #1b96ff | |
--slds-c-textarea-text-color | Color | ||
--slds-c-textarea-text-color-error-focus | Color | ||
--slds-c-textarea-text-color-focus | Color | ||
Radius | --slds-c-textarea-radius-border | Dimension | 0.25rem |
Sizing | --slds-c-textarea-sizing-min-height | Dimension | |
Spacing | --slds-c-textarea-spacing-block-end | Dimension | 0.5rem |
--slds-c-textarea-spacing-block-start | Dimension | 0.5rem | |
--slds-c-textarea-spacing-inline-end | Dimension | 0.75rem | |
--slds-c-textarea-spacing-inline-start | Dimension | 0.75rem |
Overview of CSS Classes#
- Selector
- The CSS class being referred to.
- Summary
- A description of what the class does.
- Support
- Whether the class name is dev-ready (meaning it's fully vetted and tested and safe to use) or prototype (which means it's not fully vetted yet).
- Restrict
- The selector that the class name is allowed to be used on.
- Variant
- The base level pattern for a component. A variant can be extended to create another variant of that component, for example, a stateful button is a derivative of the base button.
- Modifier
- A single class that can be added to an HTML element of a component to modify its output. Typically these will be colors, sizing and positioning.
Selector | .slds-textarea |
---|---|
Summary | Initialize textarea |
Support | dev-ready |
Restrict | textarea |
Variant | True |
Textarea Release Notes
2.17.0
Added
- Added
slds
as the default namespace withsds
fallbacks for Styling Hooks. - Added CSS Custom Property reassignments for variants and states
2.14.0
Added
- Enabled styling hooks for textarea. See textarea's styling hooks overview table for a full listing of the currently available hooks.
2.13.1
Fixed
- Small improvements to the UI text.
2.7.0
Fixed
- Removed
box-shadow
added by Firefox for all required fields.- By default, Firefox was adding a
box-shadow
to all fields markedrequired
. This has now been normalized to match the styling in all other browsers.
- By default, Firefox was adding a