Index Bar

The section index of a phone list: a column of letters at the trailing edge that jumps to a section under the finger, as the iOS section index does. Desktop lists have no index, so an index bar never renders from 768px up.

import { IndexBar } from "@plexui/vue/components/IndexBar";

An index bar takes people through a long list that is sorted by its titles, such as countries or contacts, as the iOS section index does: a letter for each section down the trailing edge, and a press or a drag on a letter shows its section. Give a list one only when it is long and its sections are its letters. A desktop list has no index, so the bar renders under 768px only.

Examples

The example shows the phone view.

Overview

Countries

A

Argentina
Australia
Austria

B

Belgium
Brazil
Bulgaria

C

Canada
Chile
Croatia

D

Denmark
Dominican Republic

E

Ecuador
Egypt
Estonia

F

Fiji
Finland
France

G

Germany
Ghana
Greece

H

Honduras
Hungary

I

Iceland
India
Ireland
Italy

J

Jamaica
Japan
Jordan

K

Kenya
Kuwait

L

Latvia
Lithuania
Luxembourg

M

Malta
Mexico
Morocco

N

Netherlands
New Zealand
Norway

O

Oman

P

Panama
Peru
Poland
Portugal

Q

Qatar

R

Romania
Rwanda

S

Singapore
Slovenia
Spain
Sweden

T

Thailand
Tunisia
Türkiye

U

Uganda
Ukraine
Uruguay

V

Vanuatu
Vietnam

Y

Yemen

Z

Zambia
Zimbabwe

API

IndexBar

PropTypeDefaultDescription
itemsstring[]—The titles of the sections, in order: usually letters, such as A to Z and #
idstring—The id of the index bar
aria-labelstring"Section index"Name of the index bar
aria-controlsstring—The id of the list the index scrolls

Events: select with the title and the index of the section to show, on a press, on each new letter while dragging and from the keys (React onSelect); focus and blur.

The bar is one stop for the Tab key: a vertical slider named Section index, read as the letter of the current section, as the iOS section index is one adjustable element for VoiceOver. Down and Up, or Right and Left, move one section; Home and End go to the first and the last; Enter or Space shows the current section again. The letters themselves are hidden from assistive technology. While a pointer presses the bar, it has data-pressed. Classes and other attributes go to the strip of the index bar.

Styling

IndexBar reads these component tokens. Override them at any scope to restyle it:

  • --index-bar-width, --index-bar-inset-inline-end: the column of letters and its space from the trailing edge (default 16px, 0px)
  • --index-bar-font-size, --index-bar-line-height, --index-bar-font-weight: the letters and the space from one to the next (default 11px, 14px, medium)
  • --index-bar-color: the letters (default var(--color-text-info))
  • --index-bar-target-width: how far in from the edge a press reaches the bar (default 30px)