Skip to content

Alpine screen size detector x-data using Toolkit $screen

Notifications You must be signed in to change notification settings

josh-tt/screenSizeDetector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

screenSizeDetector

Alpine screen size detector x-data using Toolkit $screen

Deps: https://github.com/alpine-collective/toolkit

Why

Didn't want to use the $screen magic over and over again on a bunch of components, so figured I'd get the screensize information once and then just use x-data wrapper in my app to access it everywhere. Might be possible with the $screen magic alone, but there were no docs for it so did it this way.

Install @apline-collective/toolkit-screen using npm, then in main js:

import Alpine from 'alpinejs'

import Screen from '@alpine-collective/toolkit-screen' import screenSizeDetector from './alpine/screenSizeDetector' // this is the location in your project for the js file

Alpine.plugin(Screen); Alpine.data('screenSizeDetector', screenSizeDetector);

window.Alpine = Alpine

Usage

  1. Setup your sizes in the main js
  2. Add to markup
2. Look at console log 3. Access it
...

About

Alpine screen size detector x-data using Toolkit $screen

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published