This React hook returns the current Bootstrap 5 breakpoint (xs, sm, md, lg, xl or xxl) based on the window width.
npm i bootstrap-5-breakpoint-react-hook
Or
yarn add bootstrap-5-breakpoint-react-hook
-
Include the hook:
import useBreakpoint from 'bootstrap-5-breakpoint-react-hook';
-
Use it where is needed:
function App() { return ( <div> Current breakpoint: {useBreakpoint()} </div> ); }
Licensed under the MIT License, Copyright © 2021 AlexWebLab