logo polydile dile-components

dile-textarea

Input textarea field Web Component, with customized design.

<dile-textarea label="The label" placeholder="Write something..."></dile-textarea>

Install

npm install @dile/dile-textarea

Usage

Import the component.

import '@dile/dile-textarea/dile-textarea';

Use the component

<dile-textarea
  label="Text to the label"
  max-rows="5"
  rows="2"
  placeholder="write something"
></dile-textarea>

Properties

Styling

Custom propertyDescriptionDefault
--dile-textarea-label-colorLabel text color#59e
--dile-textarea-label-font-sizeLabel font size1em
--dile-textarea-label-font-weightLabel font weightbold
--dile-textarea-borderTextarea box border1px solid #888
--dile-textarea-border-radiusTextarea element border radius5px
--dile-textarea-font-sizeInput element font size1em
--dile-textarea-paddingPadding for the textarea element5px
--dile-textarea-font-familyTextarea element font familysans-serif
--dile-textarea-label-margin-bottomLabel marging bottom4px
--dile-input-error-border-colorBorder color on errored state#c00
--dile-input-message-padding-topSpace from input to message4px
--dile-input-message-font-sizeMessage font size0.875em
--dile-input-message-colorMessage text color#888
--dile-input-message-error-colorMessage text color on errored state#c00
--dile-textarea-background-colorTextarea background color#ffffff
--dile-textarea-colorTextarea text color#000
--dile-textarea-placeholder-colorPlaceholder text color#999
--dile-textarea-disabled-background-colorDisabled background color#ebebeb
--dile-textarea-disabled-border-colorDisabled border color#ccc

Events

input

This element acts as an native textarea element. So, you can listen the native input event.

inputField.addEventListener('input', (e) => {
  console.log('input event named ', e.target.name, ' has value: ', e.target.value);
});

dile-textarea demos

Default textarea

<dile-textarea label="Comments"></dile-textarea>
<style>
.styled {
  --dile-textarea-border: 2px solid blue;
  --dile-textarea-border-radius: 0;
  --dile-textarea-label-color: blue;
  --dile-textarea-padding: 2px;
}
</style>
<dile-textarea class="styled" rows="2" max-rows="4" label="Styled element" placeholder="Write something here"></dile-textarea>