MicroClub Textarea
mcoli-ui-registry/mc-textareaFreeComponent
A multi-line text input with field integration and block addons for MicroClub UI
Live preview
live · rendered by the registry
Rendered by mcoli-ui-registry on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://mcoli-ui.microclub.info/r/mc-textarea.jsonSource
1'use client';23import * as React from 'react';45import { cn } from '@/lib/utils';67export interface McTextareaProps extends React.ComponentProps<'textarea'> {8 /** Label rendered above the textarea. */9 label?: React.ReactNode;10 /** Help text below the textarea. Replaced by error when present. */11 description?: React.ReactNode;12 /** Truthy = error state. ReactNode = renders the message. `true` = red border only. */13 error?: React.ReactNode;14 /** Block-start addon (toolbar, controls above the textarea). */15 addonTop?: React.ReactNode;16 /** Block-end addon (character count, action buttons below the textarea). */17 addonBottom?: React.ReactNode;18}1920function McTextarea({21 className,22 label,23 description,24 error,25 addonTop,26 addonBottom,27 id,28 disabled,29 required,30 rows = 3,31 ...props32}: McTextareaProps) {33 const generatedId = React.useId();34 const textareaId = id ?? generatedId;3536 const hasError = !!error;37 const errorMessage = typeof error === 'boolean' ? null : error;38 const showError = hasError && !!errorMessage;39 const showDescription = !hasError && !!description;40 const messageId = showError41 ? `${textareaId}-error`42 : showDescription43 ? `${textareaId}-description`44 : undefined;4546 const handleGroupClick = (e: React.MouseEvent<HTMLDivElement>) => {47 const target = e.target as HTMLElement;48 if (!target.closest('button, a, input, select, textarea, [tabindex]')) {49 e.currentTarget.querySelector<HTMLTextAreaElement>('[data-slot="textarea"]')?.focus();50 }51 };5253 return (54 <div data-slot="textarea-root" className={cn('flex flex-col gap-1.5', className)}>55 {label && (56 <label57 data-slot="textarea-label"58 htmlFor={textareaId}59 className="text-sm font-medium text-muted-foreground"60 >61 {label}62 </label>63 )}6465 <div66 data-slot="textarea-group"67 data-error={hasError || undefined}68 data-disabled={disabled || undefined}69 role="group"70 onClick={handleGroupClick}71 className={cn(72 // Structure73 'group/textarea flex min-w-0 cursor-text flex-col rounded-lg border border-border bg-input shadow-xs transition-all',74 // Focus ring75 'focus-within:ring-4 focus-within:ring-ring',76 // Error77 'data-error:border-destructive',78 'data-error:focus-within:border-destructive data-error:focus-within:ring-destructive/20',79// … truncated
Files it writes
More from mcoli-ui-registry
All 42 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| MicroClub Accordionmc-accordion | mcoli-ui-registry | Components | Free | 2 deps | |
| MicroClub Alertmc-alert | mcoli-ui-registry | Components | Free | 1 dep | |
| MicroClub Alert Dialogmc-alert-dialog | mcoli-ui-registry | Components | Free | 1 dep | |
| MicroClub Avatarmc-avatar | mcoli-ui-registry | Components | Free | 1 dep | |
| MicroClub Badgemc-badge | mcoli-ui-registry | Components | Free | 1 dep | |
| MicroClub Breadcrumbmc-breadcrumb | mcoli-ui-registry | Components | Free | 2 deps | |
| MicroClub Buttonmc-button | mcoli-ui-registry | Components | Free | 2 deps | |
| MicroClub Calendarmc-calendar | mcoli-ui-registry | Components | Free | 3 deps |
