Click away
Notices a click outside a box, so a dropdown can close.
Add it to your project
Or install the packages yourselfTerminal
npm install @mui/material @mui/system
First time with Material UI? Set it up once.
The code
'use client';
import * as React from 'react';
import Box from '@mui/material/Box';
import ClickAwayListener from '@mui/material/ClickAwayListener';
import type { SxProps } from '@mui/system';
export default function ClickAway() {
const [open, setOpen] = React.useState(false);
const handleClick = () => {
setOpen((prev) => !prev);
};This comes with paid plans
The code for every component comes with paid plans, along with the rest of the AI toolkit. The first component under each heading is free.