npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@browser.style/xy

v1.0.15

Published

A 2D coordinate picker/controller custom element for selecting a point within a bounded area.

Readme

XY Controller

A 2D coordinate picker/controller custom element for selecting a point within a bounded area. Supports mouse, touch, and keyboard navigation with optional grid snapping.

Installation

npm install @browser.style/xy

For required dependencies and basic setup, see the main documentation.

Usage

Import the component:

import '@browser.style/xy';

Or include via script tag:

<script type="module" src="node_modules/@browser.style/xy/index.js"></script>

Basic Example

<x-y x="50" y="50"></x-y>

Attributes

| Attribute | Type | Default | Description | |-----------|------|---------|-------------| | x | Number | 0 | Initial X value | | y | Number | 100 | Initial Y value | | min-x | Number | 0 | Minimum X value | | max-x | Number | 100 | Maximum X value | | min-y | Number | 0 | Minimum Y value | | max-y | Number | 100 | Maximum Y value | | grid-x | Number | 0 | Grid divisions on X axis (0 = no grid) | | grid-y | Number | 0 | Grid divisions on Y axis (0 = no grid) | | shift | Number | 10 | Movement multiplier when Shift is held | | leave | Boolean | true | Trigger xyup on pointer leave |

Events

| Event | Description | Detail | |-------|-------------|--------| | xydown | Pointer down on element | — | | xyup | Pointer up or leave | — | | xymove | Position changed | { x, y, tx, ty, gx, gy } | | xytoggle | Spacebar pressed | — |

Event Detail Properties

| Property | Description | |----------|-------------| | x | Logical X value (within min-x to max-x) | | y | Logical Y value (within min-y to max-y) | | tx | Pixel X translation | | ty | Pixel Y translation | | gx | Grid X position (1-based, if grid enabled) | | gy | Grid Y position (1-based, if grid enabled) |

Keyboard Navigation

| Key | Action | |-----|--------| | Arrow keys | Move by single step | | Shift + Arrow | Move by shift amount (default: 10x) | | Shift + Alt + Arrow | Move by 1 pixel | | Home | Move to min-x | | End | Move to max-x | | Ctrl + Home | Move to min-y | | Ctrl + End | Move to max-y | | Space | Dispatch xytoggle event |

CSS Custom Properties

Host Styling

| Property | Default | Description | |----------|---------|-------------| | --ui-xy-bg | var(--CanvasGray) | Background color |

Point Styling

| Property | Default | Description | |----------|---------|-------------| | --ui-xy-point-bg | var(--ButtonFace) | Point background | | --ui-xy-point-bdc | var(--ButtonBorder) | Point border color | | --ui-xy-point-bdw | 0.5rem | Point border width | | --ui-xy-point-bdrs | 50% | Point border radius | | --ui-xy-point-sz | 4rem | Point size | | --ui-xy-point--focus | var(--Highlight) | Point focus background |

Grid Styling

| Property | Default | Description | |----------|---------|-------------| | --ui-xy-grid-bdw | 2px | Grid line width |

CSS Parts

| Part | Description | |------|-------------| | xypoint | The draggable point indicator |

Examples

Custom Range

<x-y min-x="0" max-x="360" min-y="0" max-y="100" x="180" y="50"></x-y>

Grid Mode

<x-y grid-x="6" grid-y="6"></x-y>

When grid is enabled, the point snaps to grid intersections and resizes to fill one cell.

Custom Styling

<x-y style="
  --ui-xy-bg: #333;
  --ui-xy-point-bg: transparent;
  --ui-xy-point-bdc: white;
  --ui-xy-point-bdw: 2px;
  --ui-xy-point-sz: 24px;
"></x-y>

JavaScript Integration

const xy = document.querySelector('x-y');

// Listen for movement
xy.addEventListener('xymove', (e) => {
  console.log(`X: ${e.detail.x}, Y: ${e.detail.y}`);
});

// Listen for interaction
xy.addEventListener('xydown', () => console.log('Started'));
xy.addEventListener('xyup', () => console.log('Ended'));

// Programmatic positioning
xy.setAttribute('x', '75');
xy.setAttribute('y', '25');

Notes

  • Y-axis inversion: Visual Y increases downward, but logical Y increases upward (like a standard coordinate system).
  • Grid sizing: In grid mode, point size is automatically set to 100% / grid-x.
  • Leave behavior: Default leave="true" triggers xyup when pointer leaves. Set to false for continuous tracking outside bounds.
  • Focus: The element is focusable (tabIndex=0) to enable keyboard navigation.