Skip to content

Commit

Permalink
feat(Textarea): allow passing props to the textarea wrapper element
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptammergard committed Dec 20, 2023
1 parent 5f7e3dc commit 8a92c9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-peaches-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@einride/ui": minor
---

Allow passing props to textarea wrapper element.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ interface TextareaBaseProps extends ComponentPropsWithoutRef<"textarea"> {
/** Default is `neutral`. */
status?: Status

/** Props passed to the textarea wrapper element. */
textareaWrapperProps?: BoxProps

/** Props passed to root elemenet. */
wrapperProps?: BoxProps
}
Expand All @@ -32,7 +35,7 @@ interface TextareaWithoutLabelProps {
export type TextareaProps = TextareaBaseProps & (TextareaWithLabelProps | TextareaWithoutLabelProps)

export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
({ message, status, wrapperProps, ...props }, ref) => {
({ message, status, textareaWrapperProps, wrapperProps, ...props }, ref) => {
const id = useId()
const messageId = useId()
return (
Expand All @@ -42,7 +45,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
{props.label}
</StyledLabel>
)}
<Box position="relative">
<Box position="relative" {...textareaWrapperProps}>
<StyledTextarea
{...props}
aria-errormessage={status === "fail" && message ? messageId : undefined}
Expand Down

0 comments on commit 8a92c9d

Please sign in to comment.