Copyable URL
Put a separate copy action beside a read-only URL.
Components / Forms
Compose a native input with attached actions and shared focus styling.
Last changed in version 0.13.0: Add avatar groups and chips, expand the block gallery, and improve component colors, spacing, and motion.
This installs InputGroup and the action components used in the examples below.
bunx --bun @getweini/cli@latest add input-group icon-button buttonImport the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.
<script setup lang="ts">
import { ref } from 'vue'
import IconButton from './components/ui/icon-button/IconButton.vue'
import Input from './components/ui/input/Input.vue'
import InputGroup from './components/ui/input-group/InputGroup.vue'
const url = ref('https://weini.app/project')
function copyUrl() {
navigator.clipboard.writeText(url.value)
}
</script>
<template>
<InputGroup>
<Input v-model="url" aria-label="Share URL" />
<template #end>
<IconButton variant="ghost" label="Copy URL" @click="copyUrl">
<svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor">
<rect x="5" y="2" width="8" height="9" rx="1.5" />
<path d="M3 5H2v9h8v-1" />
</svg>
</IconButton>
</template>
</InputGroup>
</template>The inner control retains its native attributes. Actions are separate tab stops; give icon-only actions accessible labels.
Put a separate copy action beside a read-only URL.
Attach a submit button while leaving the input editable and native.
The action has its own keyboard stop and name.
<script setup lang="ts">
import { ref } from 'vue'
import IconButton from './components/ui/icon-button/IconButton.vue'
import Input from './components/ui/input/Input.vue'
import InputGroup from './components/ui/input-group/InputGroup.vue'
const url = ref('https://weini.app/team')
function copyUrl() {
void navigator.clipboard.writeText(url.value)
}
</script>
<template>
<InputGroup>
<Input v-model="url" aria-label="Share URL" readonly />
<template #end>
<IconButton type="button" variant="ghost" label="Copy URL" @click="copyUrl">
<svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor">
<rect x="5" y="2" width="8" height="9" rx="1.5" />
<path d="M3 5H2v9h8v-1" />
</svg>
</IconButton>
</template>
</InputGroup>
</template>Keep native form submission on the attached button.
<script setup lang="ts">
import { ref } from 'vue'
import Button from './components/ui/button/Button.vue'
import Input from './components/ui/input/Input.vue'
import InputGroup from './components/ui/input-group/InputGroup.vue'
const query = ref('')
</script>
<template>
<form action="/search">
<label for="query">Search</label>
<InputGroup size="md">
<Input id="query" v-model="query" name="q" size="md" />
<template #end><Button type="submit" size="md">Go</Button></template>
</InputGroup>
</form>
</template>Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
sizeprop | ControlSize | undefined | "md" | Choose the visual size. Medium is the usual default where available. |
invalidprop | boolean | undefined | Not set | Show the invalid state; also provide a visible error message. |
disabledprop | boolean | undefined | Not set | Prevent interaction and show the disabled state. |
defaultslot | () => unknown | Required | Content shown inside InputGroup. |
startslot | (() => unknown) | undefined | Optional | Content for the start area of InputGroup. |
endslot | (() => unknown) | undefined | Optional | Content for the end area of InputGroup. |
// packages/frameworks/vue/components/input-group/types.ts
import type { ControlSize } from '@getweini/vue/types'
export interface InputGroupProps {
size?: ControlSize
invalid?: boolean
disabled?: boolean
}
// packages/frameworks/vue/dist/types/index.d.ts
export type { ButtonOptions, ButtonProps } from './button';
export type ControlSize = 'sm' | 'md' | 'lg';
export interface SelectOption<T = unknown> {
label: string;
value: T;
disabled?: boolean;
}
/** Application-owned copy. Bind translated strings reactively when the locale changes. */
export interface ListboxMessages {
/** Popup name when no aria-label or aria-labelledby is supplied. */
listboxLabel: string;
empty: string;
clearSelection: string;
}
export interface ListboxProps<T> {
options: readonly SelectOption<T>[];
messages: ListboxMessages;
id?: string;
disabled?: boolean;
required?: boolean;
invalid?: boolean;
name?: string;
form?: string;
placeholder?: string;
size?: ControlSize;
clearable?: boolean;
gap?: number;
/** Supply stable equality for object values. Values must be unique. */
by?: (a: T, b: T) => boolean;
/** Required for meaningful form submission of object values. */
serialize?: (value: T) => string;
}
// packages/frameworks/vue/dist/types/button.d.ts
import type { Component } from 'vue';
/** Options shared by button implementations across frameworks. */
export interface ButtonOptions<Variant extends string = string, Size extends string = string> {
variant?: Variant;
size?: Size;
disabled?: boolean;
loading?: boolean;
type?: 'button' | 'submit' | 'reset';
}
/** Vue-specific target options extend the reusable button contract. */
export interface ButtonProps<Variant extends string = 'default' | 'secondary' | 'outline' | 'ghost' | 'destructive', Size extends string = 'sm' | 'md' | 'lg'> extends ButtonOptions<Variant, Size> {
as?: 'button' | 'a' | Component;
asChild?: boolean;
}