Skip to content

#117 Add useScreenSize() Hook for Responsive Breakpoint Detection with Type Support#124

Closed
jawad-ali786 wants to merge 3 commits intoDavidHDev:mainfrom
jawad-ali786:feat/117-useScreenSize-hook
Closed

#117 Add useScreenSize() Hook for Responsive Breakpoint Detection with Type Support#124
jawad-ali786 wants to merge 3 commits intoDavidHDev:mainfrom
jawad-ali786:feat/117-useScreenSize-hook

Conversation

@jawad-ali786
Copy link
Copy Markdown
Contributor

📝 Description

useScreenSize() that enables responsive breakpoint detection in a type-safe manner using TypeScript. It simplifies working with responsive UI by allowing developers to easily check the current screen size and compare it against standard Tailwind-style breakpoints.

📐 Breakpoint Table

Breakpoint Range
xs 0px - 639px
sm 640px - 767px
md 768px - 1023px
lg 1024px - 1279px
xl 1280px - 1535px
2xl 1536px and up

🧩 Hook API

const screenSize = useScreenSize();

screenSize.equals("md");      // true/false
screenSize.lessThan("lg");    // true/false
screenSize.greaterThan("sm"); // true/false
screenSize.toString();        // "xs" | "sm" | "md" | "lg" | "xl" | "2xl"

@jawad-ali786 jawad-ali786 changed the title Add useScreenSize() Hook for Responsive Breakpoint Detection with Type Support #117 Add useScreenSize() Hook for Responsive Breakpoint Detection with Type Support May 13, 2025
@DavidHDev DavidHDev requested a review from Copilot May 22, 2025 15:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces the new useScreenSize() hook to enable responsive breakpoint detection in a type-safe way for TypeScript projects. The main changes include:

  • Adding the useScreenSize() hook implementation in lib/hooks/useScreenSize.ts.
  • Exporting useScreenSize() from lib/index.ts.
  • Updating documentation and a demo to showcase the new hook.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/index.ts Export of the new useScreenSize() hook added
lib/hooks/useScreenSize.ts Implementation of useScreenSize() with breakpoint detection
docs/docs/hooks/useScreenSize.mdx Documentation and usage examples for the hook added
docs/demo/UseScreenSizeDemo.jsx Demo component for showcasing useScreenSize() functionality
docs/README.md README updated with an entry for the new useScreenSize() hook
Comments suppressed due to low confidence (1)

docs/README.md:136

  • The line contains several typos: 'breakponint' should be 'breakpoint' and 'euqals' should be 'equals'. Consider rephrasing for clarity.
- [`useScreenSize()`](https://reacthaiku.dev/docs/hooks/useScreenSize) - Provide the breakponit values in string method `toString`  with other method `euqals` , `lessThan` , `greaterThan` value in `True/False`.

Comment thread lib/hooks/useScreenSize.ts Outdated
Comment thread lib/hooks/useScreenSize.ts Outdated
Comment thread docs/README.md Outdated
Comment thread lib/hooks/useScreenSize.ts
Comment thread lib/hooks/useScreenSize.ts Outdated
Comment thread lib/hooks/useScreenSize.ts Outdated
Comment thread lib/hooks/useScreenSize.ts Outdated
Comment thread lib/hooks/useScreenSize.ts Outdated
@DavidHDev
Copy link
Copy Markdown
Owner

Is there anything different on this PR VS the one you opened 4 days ago? Please close one of them

@jawad-ali786
Copy link
Copy Markdown
Contributor Author

jawad-ali786 commented Jun 10, 2025 via email

DavidHDev added a commit that referenced this pull request Aug 12, 2025
#117 Add useScreenSize() Hook for Responsive Breakpoint Detection with Type Support #124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants