crtxdmp.

A collection of ideas, snippets and other things.


Bootstrap 5.3 Breakpoint helper component

A small helper component to show the current breakpoint in Bootstrap 5.3

File: Breakpoint/Breakpoint.tsx
import React, { PropsWithChildren } from 'react';

import * as styles from './Breakpoint.module.scss';

type Props = {
    className?: string;
};

const Breakpoint: React.FC<PropsWithChildren<Props>> = (
  props: PropsWithChildren<Props>
): React.ReactElement => {
  return (
    <div
      className={[props.className, styles.root, 'text-white bg-dark'].join(' ')}
      data-testid={'breakpoint-root'}>
      <div className="d-none d-md-none d-sm-block">SM</div>
      <div className="d-none d-lg-none d-md-block">MD</div>
      <div className="d-none d-xl-none d-lg-block">LG</div>
      <div className="d-none d-xl-block">XL</div>
    </div>
  );
};

export { Breakpoint };
File: Breakpoint/index.tsx
import { Breakpoint } from './Breakpoint';

export default Breakpoint;
File: Breakpoint/Breakpoint.module.scss
.root {
  position: fixed;
  left: 0;
  top: 0;
  width: 50px;
  text-align: center;
  box-sizing: content-box;
}

, , , — Jul 10, 2023