Input
A single-line text field, with an optional clear button.
Put an input in a Field to give it a visible label and a description. The field wires
the label and description to the input for you.
Clearable
InputGroup holds an input with controls beside it. InputClear empties the input and only
shows while it has a value.
Dependencies
What it's built from and what's built from it in Base, read from the imports in its source.
| Uses | ButtonprimitiveTextprimitive |
|---|---|
| Used by | Selectform itemTextareaform item |
| Packages | @ui-sdk/core@0.1.0-beta.20@ui-sdk/react@0.1.0-beta.20lucide-react@1.73.0tailwind-variants@4.1.0 |
Installation
Set the project up for Base once first, as Getting started shows. Then add it with the CLI, or by hand.
With the CLI
Manually
Install its packages:
Add the components it uses first, listed under Dependencies.
Then copy the source:
API reference
Generated from Base's types. Props marked ours are added here; the rest come from the ui-sdk part it wraps. Every part also accepts its element's native attributes.
Input
A single-line text field, filled rather than outlined. Put it in a Field to give it a label, a description and errors.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: InputState) => ReactNode)
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: InputState) => string)
- controller
Reads and writes the field from anywhere. Create one with
createInputController().Type { getValue: () => string; setValue: (value: string, options?: ChangeOptions<InputValueChangeReason>) => boolean; clear: (options?: ChangeOptions<...>) => boolean; focus: () => void; }
- debug
Logs every state change with its reason to the console, in development builds.
Type boolean
- defaultValue
The value it starts with. A form reset returns here.
Type string
- disabled
Stops presses. The button is natively disabled, so it leaves the tab order and its form doesn't submit through it, unless
focusableWhenDisabledis set.Type boolean · Default false
- onValueChange
Called when the user changes the value: typing (
"input-change"), a Clear part ("clear-press"), a form reset ("reset") or a controller ("imperative").details.cancel()keeps the value as it was.Type (value: string, details: ChangeDetails<InputValueChangeReason>) => void
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<InputState>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: InputState) => CSSProperties)
- value
The value, for a controlled field.
Type string
InputClear
Empties the input in its group. Shows only while the input has a value.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: NoInfer<InputGroupState>) => ReactNode)
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: NoInfer<InputGroupState>) => string)
- disabled
Stops presses. The button is natively disabled, so it leaves the tab order and its form doesn't submit through it, unless
focusableWhenDisabledis set.Type boolean · Default false
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<NoInfer<InputGroupState>>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: NoInfer<InputGroupState>) => CSSProperties)
InputGroup
Holds an Input together with buttons or text beside it, like an InputClear.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: InputGroupState) => ReactNode)
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: InputGroupState) => string)
- debug
Logs every state change with its reason to the console, in development builds.
Type boolean
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<InputGroupState>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: InputGroupState) => CSSProperties)