@@ -108,6 +108,42 @@ const WithIconAndLoadingIndicator = () => {
108108render (< WithIconAndLoadingIndicator / > )
109109```
110110
111+ ### With trailing action
112+
113+ ``` jsx live
114+ < Box display= " grid" sx= {{gap: 3 }}>
115+ < FormControl>
116+ < FormControl .Label > Icon action< / FormControl .Label >
117+ < TextInput
118+ trailingAction= {
119+ < TextInput .Action
120+ onClick= {() => {
121+ alert (' clear input' )
122+ }}
123+ icon= {XIcon}
124+ aria- label= " Clear input"
125+ sx= {{color: ' fg.subtle' }}
126+ / >
127+ }
128+ / >
129+ < / FormControl>
130+ < FormControl>
131+ < FormControl .Label > Text action< / FormControl .Label >
132+ < TextInput
133+ trailingAction= {
134+ < TextInput .Action
135+ onClick= {() => {
136+ alert (' clear input' )
137+ }}
138+ >
139+ Clear
140+ < / TextInput .Action >
141+ }
142+ / >
143+ < / FormControl>
144+ < / Box>
145+ ```
146+
111147### With error and warning states
112148
113149``` jsx live
@@ -160,61 +196,63 @@ render(<WithIconAndLoadingIndicator />)
160196
161197<PropsTable >
162198 <PropsTableRow name = " aria-label" type = " string" description = " Allows input to be accessible." />
163- <PropsTableRow
164- name = " block"
165- type = " boolean"
166- defaultValue = " false"
167- description = " Creates a full-width input element"
168- />
199+ <PropsTableRow name = " block" type = " boolean" defaultValue = " false" description = " Creates a full-width input element" />
169200 <PropsTableRow
170201 name = " contrast"
171202 type = " boolean"
172203 defaultValue = " false"
173204 description = " Changes background color to a higher contrast color"
174205 />
175- <PropsTableRow name = ' size' type = " 'small' | 'medium' | 'large'" description = " Creates a smaller or larger input than the default." />
176-
177- <PropsTableRow name = " loading" type = " boolean" description = " Whether to show a loading indicator in the input" />
178- <PropsTableRow
179- name = " loaderPosition"
180- type = " 'auto' | 'leading' | 'trailing'"
181- description = {
182- <>
183- <div >Which position to render the loading indicator</div >
184- <ul >
185- <li >
186- 'auto' (default): at the end of the input, unless a `leadingVisual` is passed. Then, it will render at the
187- beginning
188- </li >
189- <li >'leading': at the beginning of the input</li >
190- <li >'trailing': at the end of the input</li >
191- </ul >
192- </>
193- }
194- />
195- <PropsTableRow
196- name = " leadingVisual"
197- type = { <>string | React.ComponentType</>}
198- description = " Visual positioned on the left edge inside the input"
199- />
200- <PropsTableRow name = " monospace" type = " boolean" defaultValue = " false" description = " Shows input in monospace font" />
201- <PropsTableRow
202- name = " trailingVisual"
203- type = { <>string | React.ComponentType</>}
204- description = " Visual positioned on the right edge inside the input"
205- />
206- <PropsTableRow
207- name = " validationStatus"
208- type = " 'error' | 'success' | 'warning'"
209- description = " Style the input to match the status"
210- />
211- <PropsTableRow
212- name = " variant"
213- type = " 'small' | 'medium' | 'large'"
214- description = " (Use size) Creates a smaller or larger input than the default."
215- deprecated
216- />
217-
206+ <PropsTableRow
207+ name = " size"
208+ type = " 'small' | 'medium' | 'large'"
209+ description = " Creates a smaller or larger input than the default."
210+ />
211+ <PropsTableRow name = " loading" type = " boolean" description = " Whether to show a loading indicator in the input" />
212+ <PropsTableRow
213+ name = " loaderPosition"
214+ type = " 'auto' | 'leading' | 'trailing'"
215+ description = {
216+ <>
217+ <div >Which position to render the loading indicator</div >
218+ <ul >
219+ <li >
220+ 'auto' (default): at the end of the input, unless a `leadingVisual` is passed. Then, it will render at the
221+ beginning
222+ </li >
223+ <li >'leading': at the beginning of the input</li >
224+ <li >'trailing': at the end of the input</li >
225+ </ul >
226+ </>
227+ }
228+ />
229+ <PropsTableRow
230+ name = " leadingVisual"
231+ type = { <>string | React.ComponentType</>}
232+ description = " Visual positioned on the left edge inside the input"
233+ />
234+ <PropsTableRow name = " monospace" type = " boolean" defaultValue = " false" description = " Shows input in monospace font" />
235+ <PropsTableRow
236+ name = " trailingVisual"
237+ type = { <>string | React.ComponentType</>}
238+ description = " Visual positioned on the right edge inside the input"
239+ />
240+ <PropsTableRow
241+ name = " trailingAction"
242+ type = " React.ReactElement<HTMLProps<HTMLButtonElement>>"
243+ description = " A visual that renders inside the input after the typing area"
244+ />
245+ <PropsTableRow
246+ name = " validationStatus"
247+ type = " 'error' | 'success' | 'warning'"
248+ description = " Style the input to match the status"
249+ />
250+ <PropsTableRow
251+ name = " variant"
252+ type = " 'small' | 'medium' | 'large'"
253+ description = " (Use size) Creates a smaller or larger input than the default."
254+ deprecated
255+ />
218256 <PropsTableRow
219257 name = " width"
220258 type = {
@@ -265,6 +303,29 @@ render(<WithIconAndLoadingIndicator />)
265303 />
266304</PropsTable >
267305
306+ ### TextInput.Action
307+
308+ <PropsTable >
309+ <PropsTableRow
310+ name = " aria-label"
311+ type = " string"
312+ description = " Text that appears in a tooltip. If an icon is passed, this is also used as the label used by assistive technologies."
313+ />
314+ <PropsTableRow name = " icon" type = " React.FunctionComponent" description = " The icon to render inside the button" />
315+ <PropsTableRow
316+ name = " variant"
317+ type = " 'default' | 'primary' | 'invisible' | 'danger'"
318+ description = " Determine's the styles on a button"
319+ />
320+ <PropsTableBasePropRows
321+ elementType = " button"
322+ refType = " HTMLButtonElement"
323+ passthroughPropsLink = {
324+ <Link href = " https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attributes" >MDN</Link >
325+ }
326+ />
327+ </PropsTable >
328+
268329## Status
269330
270331<ComponentChecklist
0 commit comments