<script setup lang="ts">
import { ALabel } from 'akar';
</script>
<template>
<div class="px-5 flex flex-wrap gap-4 items-center">
<ALabel
class="color-text font-medium block"
for="firstName"
>
First name
</ALabel>
<input
id="firstName"
class="text-sm color-text-highlighted px-2.5 py-1.5 appearance-none border-0 rounded-md bg-background gap-1.5 w-full ring ring-ring-accented ring-inset transition-colors placeholder:color-text-dimmed focus:outline-none focus-visible:(ring-2 ring-primary ring-inset)"
type="text"
value="Nyoman Gabler"
>
</div>
</template>
Import the component.
<script setup>
import { ALabel } from 'akar';
</script>
<template>
<ALabel />
</template>
Contains the content for the label.
| Prop | Default | Type |
|---|---|---|
as | 'label' | APrimitiveAsTag | ComponentThe element or component this component should render as. Can be overwritten by |
asChild | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | |
for | stringThe id of the element the label is associated with. |
This component is based on the native label element, it will automatically apply the correct labelling when wrapping controls or using the for attribute. For your own custom controls to work correctly, ensure they use native elements such as button or input as a base.