InputGroup
The InputGroup component extends form controls by adding text, buttons, or icons before or after inputs.
Quick Start
Usage Scenarios
Text Addons
InputGroup(InputGroupText("$"), Input("amount", input_type="number", placeholder="0.00"), InputGroupText(".00"))
InputGroup(Input("domain", placeholder="Your website"), InputGroupText(".com"))
InputGroup(InputGroupText("https://"), Input("url", placeholder="example.com"))
Button Addons
InputGroup(Input("search", placeholder="Search..."), Button("Go", variant="primary"))
InputGroup(Button("Copy", variant="outline-secondary"), Input("share_link", value="https://example.com/share/abc123", readonly=True))
Sizes
InputGroup(InputGroupText("@"), Input("username", placeholder="Large"), size="lg")
InputGroup(InputGroupText("@"), Input("username", placeholder="Default"))
InputGroup(InputGroupText("@"), Input("username", placeholder="Small"), size="sm")
Parameter Reference
InputGroup
| Parameter | Type | Default | Description |
|---|---|---|---|
*children |
Any |
Required | Form controls and addons |
size |
"sm" \| "lg" \| None |
None |
Group size |
nowrap |
bool |
False |
Prevent wrapping on smaller screens |
**kwargs |
Any |
- | Additional HTML attributes |
InputGroupText
| Parameter | Type | Default | Description |
|---|---|---|---|
*children |
Any |
Required | Text or icon content |
**kwargs |
Any |
- | Additional HTML attributes |
Accessibility
- Proper form control structure is maintained.
- Label associations work when used with labels.
API Reference
faststrap.components.forms.inputgroup.InputGroup(*children, size=None, nowrap=False, **kwargs)
Bootstrap InputGroup component.
Extend form controls with text, buttons, or other elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*children
|
Any
|
Form controls and addons (InputGroupText, Button, Input, etc.) |
()
|
size
|
SizeType | None
|
Group size (sm, lg) |
None
|
nowrap
|
bool
|
Prevent wrapping on smaller screens |
False
|
**kwargs
|
Any
|
Additional HTML attributes |
{}
|
Returns:
| Type | Description |
|---|---|
Div
|
FastHTML Div element with input-group structure |
Examples:
With text addon:
With button:
>>> InputGroup(
... Input("search", placeholder="Search..."),
... Button("Go", variant="primary"),
... )
Large size:
>>> InputGroup(
... InputGroupText("$"),
... Input("amount", input_type="number"),
... InputGroupText(".00"),
... size="lg"
... )
See Also
Bootstrap docs: https://getbootstrap.com/docs/5.3/forms/input-group/
Source code in src/faststrap/components/forms/inputgroup.py
faststrap.components.forms.inputgroup.InputGroupText(*children, **kwargs)
Bootstrap InputGroup Text addon.
Text or icon addon for InputGroup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*children
|
Any
|
Text or icon content |
()
|
**kwargs
|
Any
|
Additional HTML attributes |
{}
|
Returns:
| Type | Description |
|---|---|
Span
|
FastHTML Span element with input-group-text class |
Examples:
Source code in src/faststrap/components/forms/inputgroup.py
faststrap.components.forms.inputgroup.FloatingLabel(name, *, label, input_type='text', value='', placeholder='', disabled=False, readonly=False, required=False, input_id=None, input_cls='', label_cls='', **kwargs)
Bootstrap FloatingLabel input component.
An input with an animated floating label that moves when focused.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Input name attribute |
required |
label
|
str
|
Label text (required for floating labels) |
required |
input_type
|
Literal['text', 'password', 'email', 'number', 'url', 'tel', 'search', 'date', 'time', 'datetime-local']
|
HTML input type |
'text'
|
value
|
str
|
Initial value |
''
|
placeholder
|
str
|
Placeholder text (usually same as label) |
''
|
disabled
|
bool
|
Disable the input |
False
|
readonly
|
bool
|
Make input read-only |
False
|
required
|
bool
|
Mark as required field |
False
|
input_id
|
str | None
|
ID for the input (auto-generated from name if not provided) |
None
|
input_cls
|
str
|
Additional classes for input element |
''
|
label_cls
|
str
|
Additional classes for label element |
''
|
**kwargs
|
Any
|
Additional HTML attributes |
{}
|
Returns:
| Type | Description |
|---|---|
Div
|
FastHTML Div element with form-floating structure |
Examples:
Basic:
With value:
Password:
See Also
Bootstrap docs: https://getbootstrap.com/docs/5.3/forms/floating-labels/
Source code in src/faststrap/components/forms/inputgroup.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |