Input Group
Wraps an input with prefix and suffix addons, such as labels, icons or buttons, that share its border.
<arc-input-group>Overview
InputGroup puts addons before and after an input inside one border, so a prefix like "https://", a suffix like ".com", a currency symbol, a unit or a button reads as part of the field. The group draws the box itself and takes the border, radius and shadow off the slotted input.
When the input inside has focus, the whole group gets the accent border and focus glow. Three sizes (sm, md, lg) set the addon padding and font size.
Guidelines
Do
- Use it for fixed context like "https://", "$" or ".com"
- Put action buttons such as copy, clear or search in the suffix slot
- Set the group's `size` to match the input inside it
Don't
- Don't put more than one input in a group
- Don't use a group just for a decorative icon. `arc-input` has its own prefix and suffix slots
Features
- Works with `arc-input`, `arc-select` and native `<input>` and `<select>` elements
- CSS parts: group, prefix, content, suffix
Preview
Usage
Its events and state need JavaScript, so use the Web Component or a framework wrapper for those.
<!-- URL input with prefix -->
<arc-input-group>
<span slot="prefix">https://</span>
<arc-input placeholder="example.com"></arc-input>
</arc-input-group>
<!-- Currency input with prefix and suffix -->
<arc-input-group>
<span slot="prefix">$</span>
<arc-input type="number" placeholder="0.00"></arc-input>
<span slot="suffix">USD</span>
</arc-input-group>import { InputGroup, Input } from '@arclux/arc-ui-react';
export default function Example() {
return (
<>
<InputGroup>
<span slot="prefix">https://</span>
<Input placeholder="example.com" />
</InputGroup>
<InputGroup>
<span slot="prefix">$</span>
<Input type="number" placeholder="0.00" />
<span slot="suffix">USD</span>
</InputGroup>
</>
);
}<script setup>
import { InputGroup, Input } from '@arclux/arc-ui-vue';
</script>
<template>
<InputGroup>
<template #prefix>https://</template>
<Input placeholder="example.com" />
</InputGroup>
</template><script>
import { InputGroup, Input } from '@arclux/arc-ui-svelte';
</script>
<InputGroup>
<span slot="prefix">https://</span>
<Input placeholder="example.com" />
</InputGroup>import { Component } from '@angular/core';
import { InputGroup, Input } from '@arclux/arc-ui-angular';
@Component({
imports: [InputGroup, Input],
template: `
<arc-input-group>
<span slot="prefix">https://</span>
<arc-input placeholder="example.com" />
</arc-input-group>
`,
})
export class UrlField {}import { InputGroup, Input } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<InputGroup>
<span slot="prefix">https://</span>
<Input placeholder="example.com" />
</InputGroup>
);
}import { InputGroup, Input } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<InputGroup>
<span slot="prefix">https://</span>
<Input placeholder="example.com" />
</InputGroup>
);
}<!-- Auto-generated by @arclux/prism — do not edit manually -->
<!-- arc-input-group — requires input-group.css + base.css (or arc-ui.css) -->
<div class="arc-input-group">
<div class="input-group">
<div class="input-group__addon input-group__addon--prefix">https://</div>
<div class="input-group__content"><input placeholder="example.com" /></div>
</div>
</div><!-- Auto-generated by @arclux/prism — do not edit manually -->
<div style="display: flex">
<div style="display: flex; align-items: stretch; width: 100%; border-radius: 10px; overflow: hidden; border: 1px solid rgb(42, 42, 52); background: rgb(17, 17, 22)">
<div style="display: flex; align-items: center; padding: 0 12px; background: rgb(24, 24, 32); border-right: 1px solid rgb(42, 42, 52); font-size: 14px; color: rgb(124, 124, 137);">https://</div>
<div style="flex: 1;"><input placeholder="example.com" style="border: none; background: transparent; width: 100%; padding: 8px 12px; color: inherit;" /></div>
</div>
</div>API
size'sm' | 'md' | 'lg''md'- Controls addon padding and font size.
See also
- InputText field with a built-in label, placeholder and validation states. Set `multiline` for a textarea.
- LabelForm label with a required indicator, description text and a tooltip slot. Clicking it focuses the control whose id is in `for`.
- Button GroupJoins related buttons into one strip, in a row or a column.