Accordion
Collapsible question-and-answer sections. One stays open at a time unless you set multiple.
<arc-accordion>Overview
Accordion stacks <arc-accordion-item> elements. Each item's question attribute becomes a button, and the item's text becomes the panel under it. Opening one item closes the others unless you set multiple.
Answers are plain text. The item's textContent is rendered into a paragraph, so links, lists and other markup inside an item are lost. That suits FAQs and short notes. For a single block of rich content, use Collapsible.
Guidelines
Do
- Keep questions short enough to scan
- Keep answers short. They render as plain text, so put long or linked content on its own page
- Put the most-asked question first
- Give the accordion a max width so answers don't run edge to edge
Don't
- Don't use it for sections readers compare side by side. Use Tabs
- Don't put pricing, legal terms or anything else readers must see inside a closed item
- Don't use it for a single item. Use Collapsible
Features
- Panel height animates with a CSS grid transition, with no JavaScript measuring
- Each trigger is a `<button>` with `aria-expanded` and `aria-controls`, and each panel is a `region` labelled by its trigger
- The chevron turns 180 degrees when an item opens
- Items sit in one bordered, rounded container with a 1px divider between them
Preview
React, Vue, Svelte, Angular, Solid and Preact each get a generated package. Plain HTML uses the Web Components directly.
Override the tokens on :root to change the whole page, or on a wrapper element to change one part of it.
Yes. Each component has its own entry point, for example @arclux/arc-ui/accordion.
Usage
Its events and state need JavaScript, so use the Web Component or a framework wrapper for those.
<arc-accordion>
<arc-accordion-item question="What is ARC UI?">
A framework-agnostic component library built with Lit web components,
with first-class wrappers for React, Vue, Svelte, Angular, Solid, and Preact.
</arc-accordion-item>
<arc-accordion-item question="How do I theme components?">
Override the CSS custom-property tokens at any scope and every
component updates automatically.
</arc-accordion-item>
<arc-accordion-item question="Can I tree-shake unused components?">
Yes — import only the modules you need and your bundler will
eliminate everything else.
</arc-accordion-item>
</arc-accordion>import { Accordion, AccordionItem } from '@arclux/arc-ui-react';
export default function FAQ() {
return (
<Accordion>
<AccordionItem question="What is ARC UI?">
A framework-agnostic component library built with Lit web components,
with first-class wrappers for React, Vue, Svelte, Angular, Solid, and Preact.
</AccordionItem>
<AccordionItem question="How do I theme components?">
Override the CSS custom-property tokens at any scope and every
component updates automatically.
</AccordionItem>
<AccordionItem question="Can I tree-shake unused components?">
Yes — import only the modules you need and your bundler will
eliminate everything else.
</AccordionItem>
</Accordion>
);
}<script setup>
import { Accordion, AccordionItem } from '@arclux/arc-ui-vue';
</script>
<template>
<Accordion>
<AccordionItem question="What is ARC UI?">
A framework-agnostic component library built with Lit web components,
with first-class wrappers for React, Vue, Svelte, Angular, Solid, and Preact.
</AccordionItem>
<AccordionItem question="How do I theme components?">
Override the CSS custom-property tokens at any scope and every
component updates automatically.
</AccordionItem>
<AccordionItem question="Can I tree-shake unused components?">
Yes — import only the modules you need and your bundler will
eliminate everything else.
</AccordionItem>
</Accordion>
</template><script>
import { Accordion, AccordionItem } from '@arclux/arc-ui-svelte';
</script>
<Accordion>
<AccordionItem question="What is ARC UI?">
A framework-agnostic component library built with Lit web components,
with first-class wrappers for React, Vue, Svelte, Angular, Solid, and Preact.
</AccordionItem>
<AccordionItem question="How do I theme components?">
Override the CSS custom-property tokens at any scope and every
component updates automatically.
</AccordionItem>
<AccordionItem question="Can I tree-shake unused components?">
Yes — import only the modules you need and your bundler will
eliminate everything else.
</AccordionItem>
</Accordion>import { Component } from '@angular/core';
import { Accordion, AccordionItem } from '@arclux/arc-ui-angular';
@Component({
imports: [Accordion, AccordionItem],
template: `
<arc-accordion>
<arc-accordion-item question="What is ARC UI?">
A framework-agnostic component library built with Lit web components,
with first-class wrappers for React, Vue, Svelte, Angular, Solid, and Preact.
</arc-accordion-item>
<arc-accordion-item question="How do I theme components?">
Override the CSS custom-property tokens at any scope and every
component updates automatically.
</arc-accordion-item>
<arc-accordion-item question="Can I tree-shake unused components?">
Yes — import only the modules you need and your bundler will
eliminate everything else.
</arc-accordion-item>
</arc-accordion>
`,
})
export class FaqComponent {}import { Accordion, AccordionItem } from '@arclux/arc-ui-solid';
export default function FAQ() {
return (
<Accordion>
<AccordionItem question="What is ARC UI?">
A framework-agnostic component library built with Lit web components,
with first-class wrappers for React, Vue, Svelte, Angular, Solid, and Preact.
</AccordionItem>
<AccordionItem question="How do I theme components?">
Override the CSS custom-property tokens at any scope and every
component updates automatically.
</AccordionItem>
<AccordionItem question="Can I tree-shake unused components?">
Yes — import only the modules you need and your bundler will
eliminate everything else.
</AccordionItem>
</Accordion>
);
}import { Accordion, AccordionItem } from '@arclux/arc-ui-preact';
export default function FAQ() {
return (
<Accordion>
<AccordionItem question="What is ARC UI?">
A framework-agnostic component library built with Lit web components,
with first-class wrappers for React, Vue, Svelte, Angular, Solid, and Preact.
</AccordionItem>
<AccordionItem question="How do I theme components?">
Override the CSS custom-property tokens at any scope and every
component updates automatically.
</AccordionItem>
<AccordionItem question="Can I tree-shake unused components?">
Yes — import only the modules you need and your bundler will
eliminate everything else.
</AccordionItem>
</Accordion>
);
}<arc-accordion>
<arc-accordion-item question="What is ARC UI?">
A framework-agnostic component library built with Lit web components,
with first-class wrappers for React, Vue, Svelte, Angular, Solid, and Preact.
</arc-accordion-item>
<arc-accordion-item question="How do I theme components?">
Override the CSS custom-property tokens at any scope and every
component updates automatically.
</arc-accordion-item>
<arc-accordion-item question="Can I tree-shake unused components?">
Yes — import only the modules you need and your bundler will
eliminate everything else.
</arc-accordion-item>
</arc-accordion><!-- arc-accordion is hybrid — CSS handles layout, JS handles expand/collapse -->
<arc-accordion>
<arc-accordion-item question="What is ARC UI?">
A framework-agnostic component library.
</arc-accordion-item>
<arc-accordion-item question="How do I theme components?">
Override the CSS custom-property tokens.
</arc-accordion-item>
</arc-accordion>API
multiplebooleanfalse- When true, allows multiple accordion panels to be open simultaneously. When false (default), opening one panel closes any other open panel.
AccordionItem
<arc-accordion-item>One section of an Accordion. The question attribute is the button text, and the item's text content is the answer.
answer- Answer content from slotted children
questionstring''- The heading text displayed on the trigger button. Should be a concise, scannable label or question.