<script setup lang="ts">
import { ASliderRange, ASliderRoot, ASliderThumb, ASliderTrack } from 'akar';
import { ref } from 'vue';
const value = ref([50]);
</script>
<template>
<ASliderRoot
v-model="value"
class="flex w-full select-none items-center relative touch-none"
:max="100"
:step="1"
>
<ASliderTrack class="rounded-full bg-background-accented grow h-[8px] relative overflow-hidden">
<ASliderRange class="rounded-full bg-primary h-full absolute" />
</ASliderTrack>
<ASliderThumb
class="rounded-full bg-background size-4 ring-2 ring-primary focus-visible:(outline-2 outline-primary/50 outline-offset-2)"
aria-label="Volume"
/>
</ASliderRoot>
</template>
Import all parts and piece them together.
<script setup>
import { AStepperDescription, AStepperIndicator, AStepperItem, AStepperRoot, AStepperTitle, AStepperTrigger } from 'akar';
</script>
<template>
<AStepperRoot>
<AStepperItem>
<AStepperTrigger />
<AStepperIndicator />
<AStepperTitle />
<AStepperDescription />
<AStepperSeparator />
</AStepperItem>
</AStepperRoot>
</template>
One benefit of using Akar is its flexibility and low-level control over the components. However, this also means that you may need to manually construct more complex UI elements by combining multiple Akar components together.
If you feel there's a lot of elements that needs to be constructed manually using Akar, consider using Pohon UI instead. It provides a higher-level abstraction over Akar components with pre-defined styles and behaviors that can help you build UIs faster.
Contains all the stepper component parts.
| Prop | Default | Type |
|---|---|---|
as | 'div' | 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. | |
defaultValue | 1 | numberThe value of the step that should be active when initially rendered. Use when you do not need to control the state of the steps. |
dir | 'ltr' | 'rtl'The reading direction of the combobox when applicable. | |
linear | true | booleanWhether or not the steps must be completed in order. |
modelValue | number | |
orientation | 'horizontal' | 'horizontal' | 'vertical'The orientation the steps are laid out. Mainly so arrow navigation is done accordingly (left & right vs. up & down). |
| Event | Type |
|---|---|
update:modelValue | [payload: number]Event handler called when the value changes |
| Slot | Type |
|---|---|
modelValue | number The controlled value of the step to activate. Can be bound as |
totalSteps | numberTotal number of steps |
isNextDisabled | booleanWhether or not the next step is disabled |
isPrevDisabled | booleanWhether or not the previous step is disabled |
isFirstStep | booleanWhether or not the first step is active |
isLastStep | booleanWhether or not the last step is active |
goToStep | (step: number): voidGo to a specific step |
nextStep | (): voidGo to the next step |
prevStep | (): voidGo to the previous step |
hasNext | (): booleanWhether or not there is a next step |
hasPrev | (): booleanWhether or not there is a previous step |
| Attribute | Value |
|---|---|
[data-orientation] | 'vertical' | 'horizontal' |
[data-linear] | Present when linear |
The step item component.
| Attribute | Value |
|---|---|
[data-state] | 'active' | 'inactive' | 'completed' |
[data-disabled] | Present when disabled |
[data-orientation] | 'vertical' | 'horizontal' |
The trigger that toggles the step.
| Prop | Default | Type |
|---|---|---|
as | 'button' | 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. |
| Attribute | Value |
|---|---|
[data-state] | 'active' | 'inactive' | 'completed' |
[data-disabled] | Present when disabled |
[data-orientation] | 'vertical' | 'horizontal' |
The indicator for the step.
| Prop | Default | Type |
|---|---|---|
as | 'div' | 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. |
| Slot | Type |
|---|---|
step | numberCurrent step |
An accessible title to be announced when the stepper trigger is focused.
If you want to hide the title, wrap it inside our Visually Hidden utility like this <VisuallyHidden asChild>.
| Prop | Default | Type |
|---|---|---|
as | 'h4' | 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. |
An optional accessible description to be announced when the stepper trigger is focused.
If you want to hide the description, wrap it inside our Visually Hidden utility like this <VisuallyHidden asChild>. If you want to remove the description entirely, remove this part and pass aria-describedby="undefined" to AStepperTrigger.
| Prop | Default | Type |
|---|---|---|
as | 'div' | 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. | |
completed | false | booleanShows whether the step is completed. |
disabled | false | booleanWhen |
step* | numberCurrent step |
| Slot | Type |
|---|---|
state | 'active' | 'completed' | 'inactive'The current state of the stepper item |
You can create vertical steps by using the orientation prop.
<script setup>
import { AStepperDescription, AStepperIndicator, AStepperItem, AStepperRoot, AStepperTitle } from 'akar';
</script>
<template>
<AStepperRoot
:default-value="1"
orientation="vertical"
>
<AStepperItem>
<AStepperIndicator />
<AStepperTitle />
<AStepperDescription />
</AStepperItem>
<AStepperItem>
<AStepperIndicator />
<AStepperTitle />
<AStepperDescription />
</AStepperItem>
</AStepperRoot>
</template>
You can add additional controls for the stepper using buttons and access the typed component instance using useTemplateRef.
<script setup lang="ts">
const stepper = useTemplateRef('stepper');
</script>
<template>
<AStepperRoot
ref="stepper"
:default-value="1"
>
<AStepperItem>
<AStepperIndicator />
<AStepperTitle />
<AStepperDescription />
</AStepperItem>
<AStepperItem>
<AStepperIndicator />
<AStepperTitle />
<AStepperDescription />
</AStepperItem>
</AStepperRoot>
<div class="mt-4 flex gap-2 justify-between">
<button
:disabled="!stepper?.hasPrev()"
@click="stepper?.prevStep()"
>
Prev
</button>
<button
:disabled="!stepper?.hasNext()"
@click="stepper?.nextStep()"
>
Next
</button>
</div>
</template>
| Key | Description |
|---|---|
Tab | When focus moves onto the steps, focuses the first step |
ArrowDown | Moves focus to the next step depending on |
ArrowRight | Moves focus to the next step depending on |
ArrowUp | Moves focus to the previous step depending on |
ArrowLeft | Moves focus to the previous step depending on |
EnterSpace | Selects the focused step. |