Skip to content

Input Group

@astryxdesign/core v0.7.1 · InputGroup

Price
$
Website
https://
.com

Usage ​

InputGroup joins a field with a prefix, a suffix, or a button so they read as one control. Use it for a unit, a protocol, or a short action.

Put fixed text in the before and after slots:

vue
<script setup lang="ts">
import { InputGroup, InputGroupText } from '@astryx-vue/core/InputGroup'
import { TextInput } from '@astryx-vue/core/TextInput'
import { ref } from 'vue'

const domain = ref('')
</script>

<template>
  <InputGroup label="Website">
    <template #before>
      <InputGroupText>https://</InputGroupText>
    </template>
    <TextInput v-model="domain" label="URL" is-label-hidden placeholder="example" />
    <template #after>
      <InputGroupText>.com</InputGroupText>
    </template>
  </InputGroup>
</template>

Once the group has a label, it is a field. The label, description, optional or required mark, and status come from the shared field shell, so do not wrap another field around it. A control inside the group keeps its own label for that cell, usually hidden. Fixed text in the addons uses the group text component, which shares the addon type size and color. Without a label, the group stays a joined control that can sit inside a field that already exists.

Anatomy

ElementDescription
LabelText above the group.
Prefix addonContent before the input (text, icon, or button).
InputThe main input element (TextInput, NumberInput, TimeInput, DateInput, Typeahead, Selector, or MultiSelector).
Suffix addonContent after the input (text, icon, or button).
Status messageAn error, warning, or success message below the group.

Best practices ​

GuidelinePractice
DoUse before for a fixed prefix such as a unit or https://.
DoUse after for a short action, such as clear or submit.
DoKeep the addons short so the field itself stays easy to read.
Don'tStack several addons on both sides. The field becomes cramped.

Examples ​

Basic

Price
$
USD

A currency field with a static prefix and suffix around the amount.

Website

Website
https://
.com

The protocol and the domain suffix stay fixed on either side of the address.

Field status

Price Optional
Before tax
$
USD
Enter an amount

With a label, the description, optional mark, and error belong to the group.