diff --git a/docs/content/3.components/textarea.md b/docs/content/3.components/textarea.md index a46c8c37..9c326d71 100644 --- a/docs/content/3.components/textarea.md +++ b/docs/content/3.components/textarea.md @@ -22,6 +22,17 @@ props: --- :: +### Rows + +Use the `rows` prop to set the number of rows. Defaults to `3`. + +::component-code +--- +props: + rows: 12 +--- +:: + ### Placeholder Use the `placeholder` prop to set a placeholder text. @@ -33,6 +44,37 @@ props: --- :: +### Autoresize + +Use the `autoresize` prop to enable autoresizing the height of the Textarea. + +::component-code +--- +ignore: + - modelValue +external: + - modelValue +props: + modelValue: 'This is a long text that will autoresize the height of the Textarea.' + autoresize: true +--- +:: + +Use the `maxrows` prop to set the maximum number of rows when autoresizing. If set to `0`, the Textarea will grow indefinitely. + +::component-code +--- +ignore: + - modelValue +external: + - modelValue +props: + modelValue: 'This is a long text that will autoresize the height of the Textarea with a maximum of 4 rows.' + maxrows: 4 + autoresize: true +--- +:: + ### Color Use the `color` prop to change the ring color when the Textarea is focused. @@ -82,6 +124,102 @@ props: --- :: +### Icon + +Use the `icon` prop to show an [Icon](/components/icon) inside the Textarea. + +::component-code +--- +prettier: true +ignore: + - placeholder +props: + icon: 'i-lucide-search' + size: md + variant: outline + placeholder: 'Search...' + rows: 1 +--- +:: + +Use the `leading` and `trailing` props to set the icon position or the `leading-icon` and `trailing-icon` props to set a different icon for each position. + +::component-code +--- +prettier: true +ignore: + - placeholder +props: + trailingIcon: i-lucide-at-sign + placeholder: 'Enter your email' + size: md + rows: 1 +--- +:: + +### Avatar + +Use the `avatar` prop to show an [Avatar](/components/avatar) inside the Textarea. + +::component-code +--- +prettier: true +ignore: + - placeholder +props: + avatar: + src: 'https://github.com/nuxt.png' + size: md + variant: outline + placeholder: 'Search...' + rows: 1 +--- +:: + +### Loading + +Use the `loading` prop to show a loading icon on the Textarea. + +::component-code +--- +ignore: + - placeholder +props: + loading: true + trailing: false + placeholder: 'Search...' + rows: 1 +--- +:: + +### Loading Icon + +Use the `loading-icon` prop to customize the loading icon. Defaults to `i-lucide-refresh-cw`. + +::component-code +--- +ignore: + - placeholder +props: + loading: true + loadingIcon: 'i-lucide-repeat-2' + placeholder: 'Search...' + rows: 1 +--- +:: + +::framework-only +#nuxt +:::tip{to="/getting-started/icons/nuxt#theme"} +You can customize this icon globally in your `app.config.ts` under `ui.icons.loading` key. +::: + +#vue +:::tip{to="/getting-started/icons/vue#theme"} +You can customize this icon globally in your `vite.config.ts` under `ui.icons.loading` key. +::: +:: + ### Disabled Use the `disabled` prop to disable the Textarea. @@ -96,48 +234,6 @@ props: --- :: -### Rows - -Use the `rows` prop to set the number of rows. Defaults to `3`. - -::component-code ---- -props: - rows: 12 ---- -:: - -### Autoresize - -Use the `autoresize` prop to enable autoresizing the height of the Textarea. - -::component-code ---- -ignore: - - modelValue -external: - - modelValue -props: - modelValue: 'This is a long text that will autoresize the height of the Textarea.' - autoresize: true ---- -:: - -Use the `maxrows` prop to set the maximum number of rows when autoresizing. If set to `0`, the Textarea will grow indefinitely. - -::component-code ---- -ignore: - - modelValue -external: - - modelValue -props: - modelValue: 'This is a long text that will autoresize the height of the Textarea with a maximum of 4 rows.' - maxrows: 4 - autoresize: true ---- -:: - ## API ### Props diff --git a/playground/app/pages/components/input.vue b/playground/app/pages/components/input.vue index d6c2ba1a..5a14541b 100644 --- a/playground/app/pages/components/input.vue +++ b/playground/app/pages/components/input.vue @@ -38,7 +38,7 @@ const variants = Object.keys(theme.variants.variant) as Array - + diff --git a/playground/app/pages/components/textarea.vue b/playground/app/pages/components/textarea.vue index 8e9332cf..2e1bd7bc 100644 --- a/playground/app/pages/components/textarea.vue +++ b/playground/app/pages/components/textarea.vue @@ -9,7 +9,7 @@ const variants = Object.keys(theme.variants.variant) as Array
- +
@@ -36,11 +36,59 @@ const variants = Object.keys(theme.variants.variant) as Array
- - + + + + + + +
- + +
+
+ +
+
+ +
+
+
diff --git a/src/runtime/components/Textarea.vue b/src/runtime/components/Textarea.vue index 40d37589..403de843 100644 --- a/src/runtime/components/Textarea.vue +++ b/src/runtime/components/Textarea.vue @@ -3,7 +3,9 @@ import type { VariantProps } from 'tailwind-variants' import type { AppConfig } from '@nuxt/schema' import _appConfig from '#build/app.config' import theme from '#build/ui/textarea' +import type { UseComponentIconsProps } from '../composables/useComponentIcons' import { tv } from '../utils/tv' +import type { AvatarProps } from '../types' import type { PartialString } from '../types/utils' const appConfigTextarea = _appConfig as AppConfig & { ui: { textarea: Partial } } @@ -12,7 +14,7 @@ const textarea = tv({ extend: tv(theme), ...(appConfigTextarea.ui?.textarea || { type TextareaVariants = VariantProps -export interface TextareaProps { +export interface TextareaProps extends UseComponentIconsProps { /** * The element or component this component should render as. * @defaultValue 'div' @@ -54,13 +56,16 @@ export interface TextareaEmits { } export interface TextareaSlots { + leading(props?: {}): any default(props?: {}): any + trailing(props?: {}): any }