Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/souporserious/react-aria

Utility components to help compose React ARIA components
https://github.com/souporserious/react-aria

Last synced: 4 months ago
JSON representation

Utility components to help compose React ARIA components

Awesome Lists containing this project

README

        

# Archived

This project has been archived. Please use [react-aria](https://react-spectrum.adobe.com/react-aria/index.html) from Adobe.

## React ARIA

[![npm version](https://badge.fury.io/js/react-aria.svg)](https://badge.fury.io/js/react-aria)
[![Dependency Status](https://david-dm.org/souporserious/react-aria.svg)](https://david-dm.org/souporserious/react-aria)

A set of utility components to help compose ARIA components in React. Please feel free to file an issue or submit a PR if you feel these can be more ARIA compliant ❤️

## Usage

`yarn add react-aria`

`npm install react-aria --save`

```html

(UMD library exposed as `ReactARIA`)
```

### Building a select menu

```jsx
import { Trigger, Select } from 'react-aria'

const { Manager, OptionList, Option } = Select

class SelectMenu extends Component {
state = {
selection: null
}

_handleSelection = (item, e) => {
this.setState({
selection: item.value,
isOpen: false
})
}

render() {
const { isOpen } = this.state
return (

this.setState({ isOpen: !isOpen })}
>
{this.state.selection || 'Select A Dropdown Item'}

{ isOpen &&
this.setState({ isOpen: false })}
>
Apples
Pears
Oranges

}

)
}
}
```

### Building a set of tabs

```jsx
import { Tabs } from 'react-aria'

const { Manager, TabList, Tab, TabPanel } = Tabs

class TabsDemo extends Component {
state = {
tabs: [{
id: 't1',
title: 'Bacon 🐷',
panel:

And eggs 🐔

}, {
id: 't2',
title: 'Zombiez 💀',
panel:
Brainz

}, {
id: 't3',
title: 'Samuel 👨🏿',
panel:
Samuel L Jackson

}],
activeId: 't2'
}

render() {
const { tabs, activeId } = this.state
return (
this.setState({ activeId: id })}
className="tab-set"
>

{tabs.map(({ id, title }) =>

{title}

)}


{tabs.map(({ id, panel }) =>

{panel}

)}


)
}
}
```

## Running Locally

clone repo

`git clone [email protected]:souporserious/react-aria.git`

move into folder

`cd ~/react-aria`

install dependencies

`npm install`

run dev mode

`npm run dev`

open your browser and visit: `http://localhost:8080/`

## Thank You

Huge thank you to [David Clark](https://github.com/davidtheclark) and all of his ARIA work. Most of the code in here is heavily inspired by what he has done.