Input Group
Add context beside a text input.
Examples
Add context beside a text input
React code
import {
Label,
InputGroup,
Input,
InputGroupAddon,
} from "@accelerate/react/components";
export function Example() {
return (
<>
<Label htmlFor="estimate">Estimated time</Label>
<InputGroup>
<Input id="estimate" type="number" min="0" aria-describedby="estimate-unit" />
<InputGroupAddon id="estimate-unit">hours</InputGroupAddon>
</InputGroup>
</>
);
}Angular code
import { Component } from "@angular/core";
import {
AccLabel,
AccInputGroup,
AccInput,
AccInputGroupAddon,
} from "@accelerate/angular/components";
@Component({
selector: "app-example",
imports: [
AccLabel,
AccInputGroup,
AccInput,
AccInputGroupAddon,
],
template: `
<label accLabel for="estimate">Estimated time</label>
<div accInputGroup>
<input accInput id="estimate" type="number" min="0" aria-describedby="estimate-unit">
<span accInputGroupAddon id="estimate-unit">hours</span>
</div>
`,
})
export class Example {}Installation
Source preview. The expanded component catalog is ahead of the public npm releases. To run these examples in your own application, use packages built from the SDK source used for the previews or a release that includes the APIs below.
- React
@accelerate/ui@0.4.0and@accelerate/react@0.4.0- Angular
@accelerate/ui@0.4.0and@accelerate/angular@0.2.0
Load @accelerate/ui/theme.css and put acc-theme on the app or the region using Accelerator components. See the framework setup guide for the theme and adapter conventions.
Usage
Compose controls with InputGroupAddon or labeled action buttons.
Import the React component InputGroup from @accelerate/react/components. For Angular, add AccInputGroup to the standalone component’s imports and use <div accInputGroup>.
Examples use these React parts: Label, InputGroup, Input, InputGroupAddon. The Angular examples show the corresponding directives and template hosts.
API reference
- InputGroupAddon
- Adds a prefix or suffix beside the control.
- aria-describedby
- Associates a meaningful addon with the input.