@@ -5,6 +5,10 @@ import {TextInputBaseWrapper} from '../internal/components/TextInputWrapper'
55import type { FormValidationStatus } from '../utils/types/FormValidationStatus'
66import type { SxProp } from '../sx'
77import sx from '../sx'
8+ import { toggleStyledComponent } from '../internal/utils/toggleStyledComponent'
9+ import { clsx } from 'clsx'
10+ import { useFeatureFlag } from '../FeatureFlags'
11+ import classes from './TextArea.module.css'
812
913export const DEFAULT_TEXTAREA_ROWS = 7
1014export const DEFAULT_TEXTAREA_COLS = 30
@@ -38,33 +42,39 @@ export type TextareaProps = {
3842} & TextareaHTMLAttributes < HTMLTextAreaElement > &
3943 SxProp
4044
41- const StyledTextarea = styled . textarea < TextareaProps > `
42- border: 0;
43- font-size: inherit;
44- font-family: inherit;
45- background-color: transparent;
46- -webkit-appearance: none;
47- color: inherit;
48- width: 100%;
49- resize: both;
45+ const CSS_MODULES_FEATURE_FLAG = 'primer_react_css_modules_team'
5046
51- &:focus {
52- outline: 0;
53- }
47+ const StyledTextarea = toggleStyledComponent (
48+ CSS_MODULES_FEATURE_FLAG ,
49+ 'textarea' ,
50+ styled . textarea < TextareaProps > `
51+ border: 0;
52+ font-size: inherit;
53+ font-family: inherit;
54+ background-color: transparent;
55+ -webkit-appearance: none;
56+ color: inherit;
57+ width: 100%;
58+ resize: both;
5459
55- ${ props =>
56- props . resize &&
57- css `
58- resize : ${ props . resize } ;
59- ` }
60+ &:focus {
61+ outline: 0;
62+ }
6063
61- ${ props =>
62- props . disabled &&
63- css `
64- resize : none;
65- ` }
64+ ${ props =>
65+ props . resize &&
66+ css `
67+ resize : ${ props . resize } ;
68+ ` }
69+
70+ ${ props =>
71+ props . disabled &&
72+ css `
73+ resize : none;
74+ ` }
6675 ${ sx } ;
67- `
76+ ` ,
77+ )
6878
6979/**
7080 * An accessible, native textarea component that supports validation states.
@@ -88,6 +98,8 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
8898 } : TextareaProps ,
8999 ref ,
90100 ) : ReactElement => {
101+ const enabled = useFeatureFlag ( CSS_MODULES_FEATURE_FLAG )
102+
91103 return (
92104 < TextInputBaseWrapper
93105 sx = { sxProp }
@@ -106,6 +118,7 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
106118 disabled = { disabled }
107119 rows = { rows }
108120 cols = { cols }
121+ className = { clsx ( enabled && classes . TextArea , className ) }
109122 { ...rest }
110123 />
111124 </ TextInputBaseWrapper >
0 commit comments