Skip to main content

yTextarea

Description

The yTextarea component is designed for multi-line text input, offering extensive functionalities for text manipulation and display. It's particularly useful for cases where users need to input longer forms of text, such as comments, descriptions, or any other form of extended input.

Basic Structure

The yTextarea component is comprised of several parts, including the label, content area, hint text, and optional icons for additional functionalities. Here's a closer look at its basic structure:

Textarea structure

Label

Provides a title or description for the yTextarea, indicating what type of input is expected.

Content

The content is the main area where users can input their text. It can be resized to accommodate more content.

Hint Text

Offers additional guidance or examples to help users understand what they should input.

Properties

Through its various properties the yTextarea can be configured to suit your needs. The display below provides you with an overview of all the yTextarea properties.

Properties can be changed directly through three methods:

  • Inside the Toolbar, which is positioned in your workarea next to your component right where you need it. It shows the most important properties, thus providing a fast and efficient way to configure your component in the most basic way.
  • It may also occur in the Toolbar Extension, which is a seamless extension accesible as a dropdown item of the Toolbar. It extends the functionality of the Toolbar by providing advanced pickers for the most used properties.
  • Inside the Detail Panel, which is located in the righthand drawer. Every property of a component can be configured here.
METAread more
--y-textarea__component-id

The identifier of the component that is unique within a page.

--y-textarea__component-type

The type of the component. For this component it is -textarea.

--y-textarea__name

The custom name of the component. It serves for better identification of the component.

--y-textarea__version

The custom version of the Textarea-component. This can be used to ensure that all components work well together.

--y-textarea__core-theme

The CoreTheme, which will be apllied to the Textarea. For further information on themes visit the themes page.

--y-textarea__sub-theme

The subtheme subordinated to the previously specified CoreTheme, which will be apllied to the Textarea. For further information on themes visit the themes page.

--y-textarea__group-theme

The group theme is a further variation of the subtheme which is specified especially for variations of a component inside the subtheme. For further information on themes visit the Theme-Manager page.

DISPLAYread more
--y-textarea__display

This property specifies the display behavior of the component. This can be be set to:

  • none
  • block
  • flex
  • inline
--y-textarea__position

This property specifies the type of positioning method used for the component. This can be be set to:

  • static
  • relative
  • absolute
  • sticky
  • fixed
--y-textarea__visible

This property can toggle the visibility of the component. The two modes are completely hidden and fully shown.

SIZEread more
--y-textarea__min-width

The minimum value for the width of the component. This can be set in:

  • px
  • pt
  • em
  • vw
  • vh
  • %
--y-textarea__min-height

The minimum value for the height of the component. This can be set in:

  • px
  • pt
  • em
  • vw
  • vh
  • %
--y-textarea__width

The value for the width of the component. This can be set in:

  • px
  • pt
  • em
  • vw
  • vh
  • %
  • auto
--y-textarea__height

The value for the height of the component. This can be set in:

  • px
  • pt
  • em
  • vw
  • vh
  • %
  • auto
--y-textarea__max-width

The maximum value for the width of the component. This can be set in:

  • px
  • pt
  • em
  • vw
  • vh
  • %
  • none
--y-textarea__max-height

The maximum value for the height of the component. This can be set in:

  • px
  • pt
  • em
  • vw
  • vh
  • %
  • none
--y-textarea__flex

The flex property sets the length on flexible items. This sets the value in n-fold shares extrapolated to all other components with the flex display within the same container.

PLACEMENTread more
--y-textarea__margin-top

This property creates a space around the component, outside of the top border. This can be set in percent or pixels.

--y-textarea__margin-right

This property creates a space around the component, outside of the right border. This can be set in percent or pixels.

--y-textarea__margin-bottom

This property creates a space around the component, outside of the bottom border. This can be set in percent or pixels.

--y-textarea__margin-left

This property creates a space around the component, outside of the left border. This can be set in percent or pixels.

--y-textarea__padding-top

This property creates a space within the component, inside of the top border. This can be set in percent or pixels.

--y-textarea__padding-right

This property creates a space within the component, inside of the right border. This can be set in percent or pixels.

--y-textarea__padding-bottom

This property creates a space within the component, inside of the bottom border. This can be set in percent or pixels.

--y-textarea__padding-left

This property creates a space within the component, inside of the top border. This can be set in percent or pixels.

Usage

In this section you will find a collection of application scenarios and examples that illustrate how to leverage the yTextarea in ways that deviate from its standard behavior, as defined by yBase. This section aims to inspire and guide you through various possibilities, helping you to implement more complex or unique functionalities tailored to your specific needs. General properties that are universally applicable can be found in the yBase usage section.

Variations

Textarea Elevated
Elevated
Textarea Flat
Flat
Textarea Outlined
Outlined
Textarea Rounded
Rounded
Textarea Plain
Plain
genericsizeminWidth200px
genericsizemaxWidth200px
genericsizemaxHeight100px
stylebackgroundbgColor__normal#44ddbb
styleshadowboxShadow__normal0 3px 6px 0 rgba(16, 18, 24, 0.2)
styleborderborderRadius8px
stylelabellabel__fontColor__normal#FFFFFF
stylehinthint
styleindicatorindicator__height0px

Special Variations

Beyond standard configurations, the yTextarea allows for advanced customization. Tailor the component for specific needs like user feedback forms with character limits or code input areas with monospace font styling.

Textarea Blank
No Label, Placeholder
Textarea Colorized
Colorized
genericsizeminWidth200px
genericsizemaxWidth200px
genericsizemaxHeight100px
stylelabellabel
stylehinthint
styleplaceholderplaceholder
stylecontentvalue
styleindicatorindicator__height0px
styleborderborderStyleTop__normalsolid
styleborderborderStyleRight__normalsolid
styleborderborderStyleBottom__normalsolid
styleborderborderStyleLeft__normalsolid
styleborderborderWidthTop__normal2px
styleborderborderWidthRight__normal2px
styleborderborderWidthBottom__normal2px
styleborderborderWidthLeft__normal2px
styleborderborderColorTop__normal#000000
styleborderborderColorRight__normal#000000
styleborderborderColorBottom__normal#000000
styleborderborderColorLeft__normal#000000

Compared to the yInput component, it is not possible to request only number input here. This kind of validation has to be done manually via JavaScript.

Custom Validation and Mask Usage

Because there is no built in validation and mask features like in the yInput component, we have to create this functionality by ourselves. Via custom JavaScript create a yTextarea with custom validation for email input and apply a mask for phone number formatting. Implement dynamic validation feedback to guide user input.

Code example:

Textarea EvtChanged
// function onTextarea_2_EvtChanged (apiObject, component, eventData) {
// Assuming a yTextarea component with ID "emailTextarea" for email validation
const emailInput = component.get("style", "content", "value");
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(emailInput)) {
// Display validation error message
component.set(
"component",
"error",
"errorMessage",
"Please enter a valid email address."
);
} else {
// Clear error message
component.set("component", "error", "errorMessage", "");
}
// }

Handling Large Text with Auto-Expand

Configure yTextarea to automatically expand based on content, enhancing user experience for inputs like user-generated stories or extensive comments.

Code example:

Textarea EvtChanged
// function onTextarea_2_EvtChanged (apiObject, component, eventData) {
// Retrieve the current text from the textarea
const currentText = component.get("content", "value");
// Estimate the height required based on the text length
// This is a simplified example. Consider line breaks and other factors in a real implementation.
const lines = currentText.split("\n").length;
const lineHeight = 20; // Assuming each line requires 20 pixels
const padding = 20; // Top and bottom padding
const minHeight = 100; // Minimum height of the textarea
const newHeight = Math.max(minHeight, lines * lineHeight + padding);

// Adjust the height of the textarea based on the content
component.set("style", "size", "minHeight", `${newHeight}px`);
// }

These examples showcase the flexibility of yTextarea, catering to a wide range of use cases from simple text inputs to complex data entry forms with validation and formatting.

Creating a feedback form

The yTextarea can be used in many use-cases - for example a form to send out feedback via email.

How to:

  1. Create a yButton.
  2. Open the Detail Panel, proceed to Events, unfold Input and modify EvtClicked.
  3. Insert the snippet from down below.

Code example:

The following example will read the value of your yTextarea and send it out via email.

Button EvtClicked
// async function onButton_2_EvtClicked (apiObject, component, eventData) {
const textare = apiObject.ui.getObject(3, "y-textarea", "y-page", 1);
const feedbackText = textarea.get("style", "content", "content");

if (feedbackText.length > 0) {
await apiObject.email.sendUserMail({
path: "[Folder in the mediamanager for your template]",
template: "[Your template]",
placeholderValues: `{'yeet:Feedback': ${feedbackText}}`,
attachmentInfos: "[]",
recipientAddress: "[A mail for recipient]",
recipientName: "Lorem Ipsum",
subject: "Feedback send, thank you!",
userName: "testUser",
});
} else {
alert("Please provide a feedback text first, before sending empty emails.");
}
// }