Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/apkoponen/tailwind-accessible-react-demo

Accessible Listbox built with React + Tailwind CSS
https://github.com/apkoponen/tailwind-accessible-react-demo

Last synced: about 2 months ago
JSON representation

Accessible Listbox built with React + Tailwind CSS

Awesome Lists containing this project

README

        

# Tailwind CSS + React + TypeScript accessible demo

This is a demo of building an accessible React ListBox component. This is mostly a port of [https://github.com/tailwindui/vue].

# Example

```
import { useState } from "react";
import {
Listbox,
ListboxButton,
ListboxLabel,
ListboxList,
ListboxOption,
} from "../src/components/Listbox";
import classNames from "classnames";

const chevronDown = (



);

export default function Home() {
const wrestlers = [
"The Ultimate Warrior",
"Randy Savage",
"Hulk Hogan",
"Bret Hart",
"The Undertaker",
"Mr. Perfect",
"Ted DiBiase",
"Bam Bam Bigelow",
"Yokozuna",
];
const [selectedWrestler, setSelectedWrestler] = useState(wrestlers[0]);
return (




{({ isOpen }) => (
<>

Select a wrestler:


{selectedWrestler} {chevronDown}

{isOpen && (

{wrestlers.map((wrestler) => (

{({ isActive }) => (

{wrestler}

)}

))}

)}
>
)}



);
}

```