Skip to content

Instantly share code, notes, and snippets.

View thevolcanomanishere's full-sized avatar
🍑

Alex McGonagle thevolcanomanishere

🍑
View GitHub Profile
@thevolcanomanishere
thevolcanomanishere / ExampleComponent.tsx
Last active August 2, 2022 07:11
Toggling darkmode the easy way (Tailwind)
const ExampleComponent = () => {
return <h1 className="bg-white dark:bg-black">Hello</h1>;
};
export default ExampleComponent;
@thevolcanomanishere
thevolcanomanishere / DetectBreakpoint.tsx
Created July 28, 2022 11:20
Detecting Tailwind breakpoints in Typescript
const DetectBreakpoint = () => {
const getCurrentBreakpoint = (): string => {
const breakpointUnknown: string = "unknown";
const breakpointSM: string | null =
document.getElementById("breakpoint-sm")?.offsetParent === null
? null
: "sm";
const breakpointMD: string | null =
document.getElementById("breakpoint-md")?.offsetParent === null
? null