Textarea
A styled native multi-line input.
View as MarkdownExample
- Preview
- Code
Sizes
xs, sm, md (default) and lg: set size="sm" on it, or data-size="sm" on any container, as here. See Theming.
xs
sm
md
lg
Installation
npx fizzy-ui add textarea Copies textarea.ts into src/app/ui/ and installs what it needs. Run init once first.
Accessibility
No axe-core violations axe-core 4.14.0 checks this example, closed and with its panels open, on every build; the site is not published otherwise.
Source
The exact file add copies. It is yours to edit.
textarea.ts
import { Directive, input } from '@angular/core';
type FzSize = 'xs' | 'sm' | 'md' | 'lg';
@Directive({
selector: 'textarea[fzTextarea]',
host: {
'[attr.data-size]': 'size() ?? null',
class:
'flex min-h-16 w-full rounded-md border bg-background px-(--fz-field-px) py-2 text-(length:--fz-text) shadow-xs transition-colors outline-none ' +
'placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring ' +
'disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive',
},
})
export class FzTextarea {
/** xs, sm, md, lg. Unset, it takes the size of the nearest `data-size` container, else md. */
readonly size = input<FzSize>();
}
export const FZ_TEXTAREA = [FzTextarea] as const;