UNPKG

@vaadin/text-area

Version:
81 lines (68 loc) 2.9 kB
/** * @license * Copyright (c) 2017 - 2025 Vaadin Ltd. * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ */ import '@vaadin/input-container/theme/lumo/vaadin-input-container-styles.js'; import '@vaadin/vaadin-lumo-styles/color.js'; import '@vaadin/vaadin-lumo-styles/sizing.js'; import '@vaadin/vaadin-lumo-styles/typography.js'; import { inputFieldShared } from '@vaadin/vaadin-lumo-styles/mixins/input-field-shared.js'; import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; const textArea = css` [part='input-field'], [part='input-field'] ::slotted(textarea) { height: auto; box-sizing: border-box; min-height: 0; } [part='input-field'] { /* Equal to the implicit padding in vaadin-text-field */ padding-top: calc((var(--lumo-text-field-size) - 1em * var(--lumo-line-height-s)) / 2); padding-bottom: calc((var(--lumo-text-field-size) - 1em * var(--lumo-line-height-s)) / 2); transition: background-color 0.1s; line-height: var(--lumo-line-height-s); } :host(:not([readonly])) [part='input-field']::after { display: none; } :host([readonly]) [part='input-field'] { border: var(--vaadin-input-field-readonly-border, 1px dashed var(--lumo-contrast-30pct)); } :host([readonly]) [part='input-field']::after { border: none; } :host(:hover:not([readonly]):not([focused]):not([invalid])) [part='input-field'] { background-color: var(--lumo-contrast-20pct); } @media (pointer: coarse) { :host(:hover:not([readonly]):not([focused]):not([invalid])) [part='input-field'] { background-color: var(--lumo-contrast-10pct); } :host(:active:not([readonly]):not([focused])) [part='input-field'] { background-color: var(--lumo-contrast-20pct); } } [part='input-field'] ::slotted(textarea) { line-height: inherit; --_lumo-text-field-overflow-mask-image: none; } /* Use sticky positioning to keep prefix/suffix/clear button visible when scrolling textarea container */ [part='input-field'] ::slotted([slot$='fix']), [part='clear-button'] { position: sticky; top: 0; align-self: flex-start; } [part='input-field'] ::slotted(vaadin-icon[slot$='fix']), [part='clear-button'] { /* Vertically align icon prefix/suffix/clear button with the first line of text */ top: calc((var(--lumo-icon-size-m) - 1em * var(--lumo-line-height-s)) / -2); margin-top: calc((var(--lumo-icon-size-m) - 1em * var(--lumo-line-height-s)) / -2); /* Reduce effective height to match line height of native textarea, so icons don't increase component size when using single row */ margin-bottom: calc((var(--lumo-icon-size-m) - 1em * var(--lumo-line-height-s)) / -2); } `; registerStyles('vaadin-text-area', [inputFieldShared, textArea], { moduleId: 'lumo-text-area', });