Command palette

@yasinsensoy/native

React Native · Components

Accordion

Collapsible sections (FAQ, settings groups).

4 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

Preview

How long does shipping take?
Orders are delivered within 1-3 business days.
Can I return it?
You can return it for free within 14 days.
Which payment methods are there?
Credit card, debit card and bank transfer.

Code

import { Accordion, ReturnPolicy } from "@yasinsensoy/native";

<Accordion exclusive defaultValue="kargo"
  items={[
    { value: "shipping", title: "How long does shipping take?", content: "1-3 business days." },
    { value: "returns", title: "Can I return it?", content: <ReturnPolicy /> },
  ]}
/>

Events

  1. Events appear here when you interact with the preview.

Import

import { Accordion } from "@yasinsensoy/native";

Accordion

component

Collapsible sections (FAQ, settings groups). Height is animated; the content of closed sections keeps its state.

Accordion({ ref, items, exclusive, defaultValue, value, onValueChange, variant: variantProp, effect, style, }: AccordionProps): JSX.Element

Examples

<Accordion exclusive defaultValue="returns" items={[
  { value: "shipping", title: "How long does shipping take?", content: <Text>1-3 business days.</Text> },
  { value: "returns", title: "How do I return an item?", content: <ReturnSteps /> },
]} />

AccordionItem

interface

A section inside Accordion.

NameTypeDescription
value?stringUnique value of the section; defaults to its index.
titleReactNodeText in the header row.
description?ReactNodeSmall description below the title.
icon?IconPropIcon at the start of the header.
contentReactNodeContent shown while the section is open.
disabled?booleanCannot be opened.

Look of the sections: line with dividers between them, card each in its own box.

type AccordionVariant = "line" | "card"

Props of Accordion.

NameTypeDefaultDescription
ref?Ref<ViewRef>Ref of the underlying native element.
itemsreadonly AccordionItem[]Sections.
exclusive?booleanfalseOnly one section stays open at a time.
defaultValue?string | readonly string[]Value of the initially open section(s).
value?readonly string[]Open sections (controlled).
onValueChange?(value: string[]) => voidWhen the open sections change.
variant?AccordionVariant | (string & {})"line"Variant: one of the built-in variants or a name added via appearance.variants.accordion (applied to each section).
effect?EffectPropEffect of the sections ("ripple", "lift"…). Defaults to appearance.defaults.accordion.effect. See BuiltinEffect.
style?StyleProp<ViewStyle>Container style.