Getting Started

A quick tutorial to get you up and running with Akar.

Implementing a Popover

In this quick tutorial, we will install and style the Popover component.

1. Install the library

Install the component from your command line.

pnpm add akar

2. Import the parts

Import and structure the parts.

<!-- base-popover.vue -->
<script setup lang="ts">
import { APopoverArrow, APopoverClose, APopoverContent, APopoverPortal, APopoverRoot, APopoverTrigger } from 'akar'
</script>

<template>
  <APopoverRoot>
    <APopoverTrigger>More info</APopoverTrigger>
    <APopoverPortal>
      <APopoverContent>
        Some more info...
        <APopoverClose />
        <APopoverArrow />
      </APopoverContent>
    </APopoverPortal>
  </APopoverRoot>
</template>

3. Add your styles

Add styles where desired.

<template>
  <APopoverRoot>
    <APopoverTrigger class="APopoverTrigger">
      More info
    </APopoverTrigger>
    <APopoverPortal>
      <APopoverContent class="APopoverContent">
        Some more info...
        <APopoverClose />
        <APopoverArrow class="APopoverArrow" />
      </APopoverContent>
    </APopoverPortal>
  </APopoverRoot>
</template>

<style>
.APopoverTrigger {
  background-color: white;
  border-radius: 4px;
}

.APopoverContent {
  border-radius: 4px;
  padding: 20px;
  width: 260px;
  background-color: white;
}

.APopoverArrow {
  background-color: white;
}
</style>

Demo

Here's a complete demo.

<script setup lang="ts">
import { APopoverContent, APopoverPortal, APopoverRoot, APopoverTrigger } from 'akar';
</script>

<template>
  <APopoverRoot>
    <APopoverTrigger
      class="text-sm color-text p-1.5 rounded-md inline-flex ring ring-ring-accented ring-inset shadow-md transition-colors-280 items-center focus-visible:bg-background-elevated hover:bg-background-elevated"
    >
      <i class="i-lucide:info" />
    </APopoverTrigger>
    <APopoverPortal>
      <APopoverContent
        side="bottom"
        :side-offset="5"
        class="rounded-md bg-background pointer-events-auto ring ring-ring shadow-lg origin-$akar-popover-content-transform-origin focus:outline-none data-[state=closed]:(animate-out fade-out-0 zoom-out-95) data-[state=open]:(animate-in fade-in-0 zoom-in-95) data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
      >
        <CorePlaceholder class="m-4 inline-flex size-48" />
      </APopoverContent>
    </APopoverPortal>
  </APopoverRoot>
</template>

Summary

The steps above outline briefly what's involved in using a Akar in your application.

These components are low-level enough to give you control over how you want to wrap them. You're free to introduce your own high-level API to better suit the needs of your team and product.

In a few simple steps, we've implemented a fully accessible Popover component, without having to worry about many of its complexities.

  • Adheres to WAI-ARIA design pattern.
  • Can be controlled or uncontrolled.
  • Customize side, alignment, offsets, collision handling.
  • Optionally render a pointing arrow.
  • Focus is fully managed and customizable.
  • Dismissing and layering behavior is highly customizable.

Working with LLMs

Akar documentation is optimized for Large Language Models (LLMs) to help you get AI-powered assistance while working with our components.

LLM-Friendly Documentation

Our documentation includes a special LLM-friendly format that makes it easier for AI assistants to understand and provide accurate help with Akar components. This format:

  • Removes visual elements and complex formatting that can confuse LLMs
  • Structures content in a way that's optimized for text processing
  • Includes comprehensive component information in a linear format
  • Maintains all the essential technical details while being machine-readable

Accessing LLM Documentation

You can access the LLM-optimized version of our documentation at llms.txt. This file contains:

  • Complete overview of all Akar components
  • Detailed API documentation
  • Usage examples and implementation patterns
  • Accessibility guidelines
  • Styling and customization options

Using LLMs with Akar

When working with LLMs like ChatGPT, Claude, or other AI assistants, you can:

  1. Reference the llms.txt file: Direct your AI assistant to the /llms.txt file for comprehensive context about Akar
  2. Ask specific questions: Get help with implementation, styling, or accessibility features
  3. Generate code examples: Request custom implementations based on your specific needs
  4. Troubleshoot issues: Get assistance with common problems or edge cases

Example Prompts

Here are some example prompts you can use with LLMs:

"Using the Akar documentation at https://akar.vinicunca.dev/llms.txt, help me implement a custom Dialog component with form validation."

"Based on the Akar llms.txt documentation, show me how to create an accessible Select component with custom styling."

"Refer to the Akar llms.txt file and explain how to properly implement keyboard navigation for a Combobox component."

By leveraging our LLM-optimized documentation, you can get more accurate and helpful responses from AI assistants when working with Akar components.