Input
Enter text with support for labels, validation, and form submission.
Demos
Size
Variant
Usage
vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'
const items = [
{ value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>
<template>
<Accordion :items="items" />
</template>
Installation
Complete the shared installation. Copy Input.vue and index.ts into app/components/ui/input/.
app/components/ui/input/Input.vue
<script setup lang="ts">
import { AlertDialog as Primitive } from 'akaza-ui'
import { computed, useAttrs, useTemplateRef } from 'vue'
import { cn } from '../../../utils/ui'
import uiConfig from '../ui.config'
import {
alertDialogVariants,
resolveAlertDialogVariants,
type AlertDialogProps,
type AlertDialogSlots,
} from './index'
defineOptions({ inheritAttrs: false })
// Preserve Akaza defaults when optional props, including Boolean aliases, are omitted.
const props = withDefaults(defineProps<AlertDialogProps>(), {
as: undefined,
teleport: undefined,
transition: undefined,
duration: undefined,
title: undefined,
ariaLabel: undefined,
description: undefined,
ui: undefined,
modelValue: undefined,
})
defineSlots<AlertDialogSlots>()
const attrs = useAttrs()
const styles = computed(() => alertDialogVariants(resolveAlertDialogVariants(props, uiConfig)))
const mergedUi = computed(() => {
const overrides = props.ui as Record<string, string | undefined> | undefined
return Object.fromEntries(
Object.entries(styles.value).map(([part, style]) => [
part,
cn(style(), overrides?.[part], part === 'content' ? props.class : undefined),
]),
)
})
const primitiveProps = computed(() => {
const { class: _class, ui: _ui, width: _width, ...native } = props
return native
})
const primitive = useTemplateRef<InstanceType<typeof Primitive>>('primitive')
defineExpose({
get open() {
return primitive.value!.open
},
get close() {
return primitive.value!.close
},
get toggle() {
return primitive.value!.toggle
},
get titleId() {
return primitive.value!.titleId
},
get descriptionId() {
return primitive.value!.descriptionId
},
})
</script>
<template>
<component
:is="Primitive"
ref="primitive"
v-bind="{ ...primitiveProps, ...attrs }"
:ui="mergedUi"
>
<template v-for="(_, name) in $slots" #[name]="scope"
><slot :name="name as keyof AlertDialogSlots" v-bind="scope ?? {}"
/></template>
</component>
</template>
API
Variants and defaults
| Prop | Values | Default |
|---|---|---|
size | xs, sm, md, lg, xl | sm |
variant | outline, soft, bare | outline |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | — | Input id. Inherited from Field when omitted. |
name | string | — | Form field name. Inherited from Field when omitted. |
type | InputType | "text" | Native input type for text-like inputs. |
placeholder | string | — | Placeholder text. |
autocomplete | string | — | Native autocomplete setting. |
inputmode | InputProps["inputmode"] | — | Native input mode hint. |
minlength | number | — | Native minimum text length. |
maxlength | number | — | Native maximum text length. |
pattern | string | — | Native validation pattern. |
required | boolean | false | Required state. |
disabled | boolean | false | Disabled state. |
readonly | boolean | false | Read-only state. |
invalid | boolean | false | Sets aria-invalid and data-akaza-invalid. |
ariaLabel | string | — | Accessible label when no visible label exists. |
ariaDescribedby | string | field description/error | Accessible description ids. |
ui | InputUi | — | Classes for the input element. |
Events
| Event | Payload | Description |
|---|---|---|
value-change | (value, details) | Fired before model updates. details.cancel() prevents the update. |
Keyboard
Input preserves native keyboard behavior for its type, inputmode, autocomplete, selection, clipboard, and form submission. Akaza does not replace browser text editing shortcuts. Enter submits an owning form when native HTML rules permit it.