InputButton
Examples
External error + helper text
The error prop renders an external error message independent of field validation; infoMessage renders alongside it. The two are colored differently — helper text is neutral,
not the error red — so they cannot be mistaken for each other.
Required blocks submission
required (previously only mandatory) now reaches the Input underneath, not just the decorative asterisk beside the label — before this PR it drew the asterisk
and nothing else, so an empty "required" field submitted anyway. Leaving this one empty blocks the form
with the browser's own validation message, exactly like a plain <input required>.
Validity messaging
InputButton renders the error and helper text itself. Both now carry ids and are referenced by aria-describedby on a group around the control, with aria-invalid set only while an error is showing.
Documentation
A composite component that combines an Input field with optional left, right, and bottom Button components. The right and bottom buttons are automatically disabled until the input validation state becomes Valid. Pressing Enter in the input triggers the right button's onkeyup handler when validation passes. The input label and error/info messages are rendered outside the input-button group. Internally uses the Input component with actionInput=true for seamless visual integration.
Usage
<script>
import { InputButton } from '@juspay/svelte-ui-components';
</script>
<InputButton />
Validity messaging
InputButton renders the error and helper text itself — it passes actionInput to the
Input inside, which suppresses Input's own copies. Both elements now carry ids and
are referenced by aria-describedby on a role="group" wrapper around the control, and
aria-invalid is set while an error is showing.
The wrapper is described rather than the field itself because the field is inside
Input, which composes its own aria-describedby from its own onErrorMessage /
infoMessage props and offers no seam for an outside one. A group description is
announced on entering the group rather than on the control, which is weaker than the
per-control link Checkbox, Radio and Input get. Pass
inputProperties.onErrorMessage instead when you want the message bound to the text
field itself — note that actionInput then hides it, so you would be choosing the ARIA
link over the visible message.
Precedence is unchanged: a non-empty error wins over inputProperties.onErrorMessage,
which itself only appears once validation has actually failed.
Props
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
| value | string |
Yes | '' |
Bindable. The current input value. Passed through to the internal Input component. |
| inputProperties | OptionalInputProperties |
Yes | - |
Pass-through configuration for the internal Input component (placeholder, dataType, label, validators, readonly, spellcheck, inputMode, and more) — see Input's own docs for the full, current list. |
| testId | string |
No | - |
data-pw/testID on the root .container element. |
| rightButtonProperties | OptionalButtonProperties | null |
No | - |
Configuration for the right-side Button. Pass text, icon, loaderType, etc. The button is auto-disabled when input validation is not 'Valid'. Set to null to hide. |
| leftButtonProperties | OptionalButtonProperties | null |
No | - |
Configuration for the left-side Button. Pass text, icon, etc. Set to null to hide. |
| bottomButtonProperties | OptionalButtonProperties | null |
No | - |
Configuration for the bottom Button (rendered below the input row). Auto-disabled when input validation is not 'Valid'. Set to null to hide. |
| classes | string |
No | - |
CSS class string applied to the component's top-level element. Useful for theming — define classes with CSS variable overrides and pass them to create variant styles. |
| required | boolean |
No | - |
Marks the field required: native required and aria-required on the Input underneath — so an empty field blocks native form submission — plus the decorative asterisk (*) beside the label. |
| mandatory | boolean |
No | - |
Deprecated. Use required, the platform's name for this; checked only when required is not passed. It previously drew only the asterisk without making the field required — it now does both, matching required exactly. |
| size | InputButtonSize ('sm' | 'md' | 'lg') |
No | - |
Preset height/padding size variant: sm (36px), md (44px), lg (54px). Each size is fully overridable via its CSS variables. Omit to use default fit-content height. |
| error | string |
No | - |
External error message rendered below the input-button row. Takes precedence over internal validation errors — when this prop is a non-empty string, inputProperties.onErrorMessage is suppressed. Pass an empty string or omit to let internal validation messages surface. |
Methods
Exported methods that can be called via bind:this on the component instance.
| Method | Signature | Description |
|---|---|---|
focus() |
() => void |
Programmatically focuses the underlying input element. |
blur() |
() => void |
Programmatically removes focus from the underlying input element. |
Snippets
Svelte 5 Snippet props — pass content blocks to the component.
| Snippet | Type | Description |
|---|---|---|
| leftIcon | Snippet |
A Svelte 5 Snippet passed as the icon prop to the left Button. |
| rightIcon | Snippet |
A Svelte 5 Snippet passed as the icon prop to the right Button. |
Events
| Event | Type | Description |
|---|---|---|
| inputEventProperties | InputEventProperties = { onInput?: (value: string, event: Event) => void; onFocus?: (event: FocusEvent) => void; onFocusout?: (event: FocusEvent) => void; onPaste?: (event: ClipboardEvent) => void; onClick?: (event: MouseEvent) => void; onStateChange?: (state: ValidationState) => void; onKeyDown?: (event: KeyboardEvent) => void } |
Event handlers passed to the internal Input. The onStateChange callback will receive validation state changes. Note: internally the component intercepts onStateChange to update button enable states before forwarding to your handler. |
| rightButtonEventProperties | ButtonEventProperties | null |
Event handlers for the right Button. The onclick handler is only called when the input validation state is 'Valid'. The onkeyup is triggered when Enter is pressed in the input with valid state. |
| leftButtonEventProperties | ButtonEventProperties | null |
Event handlers for the left Button. These are passed directly to the Button component. |
| bottomButtonEventProperties | ButtonEventProperties | null |
Event handlers for the bottom Button. The onclick handler is only called when the input validation state is 'Valid'. |
CSS Variables
Override these custom properties to theme the component.
| Variable | Default | CSS Property | Description |
|---|---|---|---|
--input-button-container-width |
auto |
width | Width of the entire InputButton container. Set to 100% to make the control fill its parent. |
--input-button-container-margin |
- |
margin | Outer margin of the entire InputButton container. |
--input-height |
fit-content |
height | Height of the input-button container. Overridden by size preset vars when size is set. |
--input-font-size |
16px |
font-size | |
--input-button-margin |
- |
margin | Margin of the inner input-button row. |
--input-button-radius |
4px |
border-radius | Corner rounding of the input-button row. |
--input-button-container-border |
- |
border | Border of the outer container. |
--input-button-container-background |
- |
background | Background of the outer container. |
--input-button-container-padding |
- |
padding | Padding inside the outer container. |
--input-button-border |
- |
border | Border of the inner input-button row. |
--input-button-box-shadow |
0px 1px 8px #2f537733 |
box-shadow | Box shadow of the input-button row. |
--input-button-background |
- |
background | Background of the input-button row. |
--input-button-focus-border |
- |
border | Border applied to the container when any child has focus. |
--input-bottom-btn-padding |
10px 0px |
padding | Padding around the bottom button. |
--bottom-button-cursor |
- |
--cursor | Cursor of the bottom button. |
--bottom-button-color |
- |
--button-color | Background color of the bottom button. |
--bottom-button-text-color |
- |
--button-text-color | Text color of the bottom button. |
--bottom-button-font-family |
- |
--button-font-family | Font family of the bottom button. |
--bottom-button-font-weight |
- |
--button-font-weight | Font weight of the bottom button. |
--bottom-button-font-size |
- |
--button-font-size | Font size of the bottom button. |
--bottom-button-height |
54px |
--button-height | Height of the bottom button. |
--bottom-button-padding |
- |
--button-padding | Padding inside the bottom button. |
--bottom-button-border-radius |
- |
--button-border-radius | Corner rounding of the bottom button. |
--bottom-button-width |
- |
--button-width | Width of the bottom button. |
--input-label-msg-text-weight |
400 |
font-weight | |
--input-label-msg-text-size |
12px |
font-size | |
--input-label-msg-text-color |
#4d6174 |
color | |
--input-label-msg-text-line-height |
- |
line-height | |
--input-label-msg-text-margin |
0px 0px 6px 0px |
margin | |
--invalid-outline |
1px solid var(--input-field-error-stroke, #e11900) |
outline | Outline applied to the input-button row when validation state is 'Invalid'. |
--input-error-msg-text-weight |
400 |
font-weight | |
--input-error-msg-text-size |
12px |
font-size | |
--input-error-msg-text-color |
#c5120a |
color | Shared with Input's own error text (6.06:1 on white, AA). |
--input-btn-error-msg-margin |
12px 0px 0px 0px |
margin | Margin around the error message. |
--input-info-msg-text-weight |
400 |
font-weight | |
--input-info-msg-text-size |
12px |
font-size | |
--input-info-msg-text-color |
#52525b |
color | Neutral, not the error color — shared with Input's own helper text. |
--input-btn-info-msg-margin |
12px 0px 0px 0px |
margin | Margin around the info message. |
--inputbutton-mandatory-color |
#e11900 |
color | Color of the mandatory asterisk marker rendered next to the label. |
--inputbutton-sm-height |
36px |
--input-height | Container height when size="sm". |
--inputbutton-sm-padding |
6px 12px |
--input-padding | Container padding when size="sm". |
--inputbutton-md-height |
44px |
--input-height | Container height when size="md". |
--inputbutton-md-padding |
10px 16px |
--input-padding | Container padding when size="md". |
--inputbutton-lg-height |
54px |
--input-height | Container height when size="lg". |
--inputbutton-lg-padding |
14px 20px |
--input-padding | Container padding when size="lg". |
--inputbutton-external-error-color |
#c5120a |
color | Color of the external error message (set via the error prop); 6.06:1 on white, AA. |
--inputbutton-external-error-margin |
6px 0px 0px 0px |
margin | Margin around the external error message. |
--input-button-font-weight |
500 |
font-weight | Font weight of the input-button container row. |
--left-button-color |
- |
--button-color | Background color of the left button. |
--left-button-text-color |
- |
--button-text-color | Text color of the left button. |
--left-button-font-family |
- |
--button-font-family | Font family of the left button. |
--left-button-font-weight |
- |
--button-font-weight | Font weight of the left button. |
--left-button-font-size |
- |
--button-font-size | Font size of the left button. |
--left-button-height |
54px |
--button-height | Height of the left button. |
--left-button-padding |
- |
--button-padding | Padding inside the left button. |
--left-button-border-radius |
- |
--button-border-radius | Corner rounding of the left button. |
--left-button-width |
- |
--button-width | Width of the left button. |
--left-button-cursor |
- |
--cursor | Cursor of the left button. |
--left-button-opacity |
- |
--opacity | Opacity of the left button. |
--left-button-border |
- |
--button-border | Border of the left button. |
--left-button-content-gap |
- |
--button-content-gap | Gap between icon/text in the left button. |
--left-button-content-flex-direction |
row |
--button-content-flex-direction | Layout direction of the left button content. |
--left-button-icon-order |
- |
--button-icon-order | Flex order of the icon in the left button. |
--left-button-icon-display |
- |
--button-icon-display | Display of the icon in the left button. |
--left-button-text-order |
- |
--button-text-order | Flex order of the text in the left button. |
--left-button-disabled-cursor |
- |
--disabled-cursor | Cursor of the left button when disabled. |
--left-button-disabled-opacity |
- |
--disabled-opacity | Opacity of the left button when disabled. |
--right-button-flex |
1 |
flex | Flex value of the right button container. |
--right-button-min-width |
0px |
min-width | Minimum width of the right button. |
--right-button-color |
- |
--button-color | Background color of the right button. |
--right-button-text-color |
- |
--button-text-color | Text color of the right button. |
--right-button-font-family |
- |
--button-font-family | Font family of the right button. |
--right-button-font-weight |
- |
--button-font-weight | Font weight of the right button. |
--right-button-font-size |
- |
--button-font-size | Font size of the right button. |
--right-button-height |
54px |
--button-height | Height of the right button. |
--right-button-padding |
- |
--button-padding | Padding inside the right button. |
--right-button-border-radius |
0px 4px 4px 0px |
--button-border-radius | Corner rounding of the right button. |
--right-button-width |
100% |
--button-width | Width of the right button. |
--right-button-cursor |
- |
--cursor | Cursor of the right button. |
--right-button-opacity |
- |
--opacity | Opacity of the right button. |
--right-button-border |
- |
--button-border | Border of the right button. |
--right-button-content-gap |
- |
--button-content-gap | Gap between icon/text in the right button. |
--right-button-visibility |
visible |
--button-visibility | Visibility of the right button. |
--right-button-content-flex-direction |
row |
--button-content-flex-direction | Layout direction of the right button content. |
--right-button-icon-order |
- |
--button-icon-order | Flex order of the icon in the right button. |
--right-button-icon-display |
- |
--button-icon-display | Display of the icon in the right button. |
--right-button-text-order |
- |
--button-text-order | Flex order of the text in the right button. |
--right-button-disabled-cursor |
- |
--disabled-cursor | Cursor of the right button when disabled. |
--right-button-disabled-opacity |
- |
--disabled-opacity | Opacity of the right button when disabled. |
Type Reference
Custom types used by this component's props and events:
InputButtonSize
type InputButtonSize = 'sm' | 'md' | 'lg';
Preset size variants. sm renders at 36px height, md at 44px, lg at 54px. Each can be overridden via the corresponding --inputbutton-{size}-height and --inputbutton-{size}-padding CSS variables.
OptionalInputProperties
inputProperties accepts the same optional props as the standalone Input component — see Input's own documentation for the full, current list rather than a duplicated snapshot here (a prior inline copy of this type drifted out of date as Input grew new props).
ButtonProperties
type ButtonProperties = {
text?: string;
enable?: boolean;
showProgressBar?: boolean;
showLoader?: boolean;
loaderType?: 'Circular' | 'ProgressBar';
type?: 'submit' | 'reset' | 'button';
testId?: string;
icon?: Snippet;
children?: Snippet;
ariaLabel?: string;
ariaExpanded?: boolean;
disabled?: boolean;
classes?: string;
onclick?: (event: MouseEvent) => void;
onkeyup?: (event: KeyboardEvent) => void;
};
InputEventProperties
type InputEventProperties = {
onInput?: (value: string, event: Event) => void;
onFocus?: (event: FocusEvent) => void;
onFocusout?: (event: FocusEvent) => void;
onPaste?: (event: ClipboardEvent) => void;
onClick?: (event: MouseEvent) => void;
onStateChange?: (state: ValidationState) => void;
onKeyDown?: (event: KeyboardEvent) => void;
};
ButtonEventProperties
type ButtonEventProperties = {
onclick?: (event: MouseEvent) => void;
onkeyup?: (event: KeyboardEvent) => void;
};
Internal Dependencies
This component uses the following library components internally:
- Button
- Input
Web Component
Tag: <sui-input-button>
<sui-input-button value="Search...">
<svg slot="left-icon">...</svg>
<svg slot="right-icon">...</svg>
</sui-input-button>
Slots
| Slot Name | Maps to Snippet | Description |
|---|---|---|
left-icon |
leftIcon |
Icon rendered on the left side of the input. |
right-icon |
rightIcon |
Icon rendered on the right side of the input. |