Skip to content

Instantly share code, notes, and snippets.

@marshallmurphy
Created April 27, 2020 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marshallmurphy/42ba08176ce7c0b403a1d551dd95cc10 to your computer and use it in GitHub Desktop.
Save marshallmurphy/42ba08176ce7c0b403a1d551dd95cc10 to your computer and use it in GitHub Desktop.
import React, { useState } from 'react';
import styles from './dropdown.module.css';
const Dropdown = () => {
const [active, setActive] = useState(false);
return (
<div className={styles.dropdown}>
<button onClick={() => setActive(!active)}>
Dropdown
<div className={styles.caretDown}>&#94;</div>
</button>
{active && (
<div className={styles.menu}>
<div tabIndex='0' className={styles.menuItem}>Item A</div>
<div tabIndex='0' className={styles.menuItem}>Item B</div>
<div tabIndex='0' className={styles.menuItem}>Item C</div>
</div>
)}
</div>
)
}
export default Dropdown;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment