
Company News
Socket Partners with Replit to Block Malicious Packages in AI-Powered Development
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.
@page-speed/pressable
Advanced tools
Performance-optimized universal link/button component with automatic URL detection and normalization for DashTrack ecosystem
Performance-optimized universal link/button component with automatic URL detection and normalization for the DashTrack ecosystem.
<a>, <button>, or fallback elements based on propstel: formatmailto: prefix to email addresses<a> tags for proper SEO```bash
pnpm add @page-speed/pressable
npm install @page-speed/pressable
yarn add @page-speed/pressable ```
```json { "react": ">=17.0.0", "react-dom": ">=17.0.0" } ```
```tsx import { Pressable } from "@page-speed/pressable";
function Navigation() { return About Us; } ```
Automatically gets `target="_blank"` and `rel="noopener noreferrer"`:
```tsx Visit Google ```
```tsx Contact Us ```
Automatically normalized to `tel:` format:
```tsx Call Us // Renders: Call Us ```
Automatically normalized to `mailto:` format:
```tsx Email Us // Renders: Email Us ```
```tsx <Pressable onClick={() => alert("Clicked")} asButton variant="default"> Click Me ```
Supports all ShadCN button variants:
```tsx // Default variant Primary
// Outline variant Outline
// Secondary variant Secondary
// Ghost variant Ghost
// Link variant Link Style
// Destructive variant Delete ```
```tsx Small Default Medium Large
// Icon sizes ```
Full control over children:
```tsx
Learn more about what we offer
\`\`\````tsx <Pressable href="/important" aria-label="Important action" aria-describedby="description" id="important-link"
Click here for important information ```
```tsx const linkRef = useRef(null);
Link with Ref \`\`\`| Prop | Type | Default | Description |
|---|---|---|---|
| `children` | `ReactNode` | - | Content inside the component |
| `href` | `string` | - | URL to navigate to (supports internal, external, mailto, tel) |
| `onClick` | `MouseEventHandler` | - | Click handler function |
| `className` | `string` | - | Additional CSS classes |
| `asButton` | `boolean` | `false` | Apply button styles even when rendering as `` |
| Prop | Type | Default | Description |
|---|---|---|---|
| `variant` | `'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link'` | - | Button variant style |
| `size` | `'default' | 'sm' | 'md' | 'lg' | 'icon' | 'icon-sm' | 'icon-lg'` | - | Button size |
| Prop | Type | Default | Description |
|---|---|---|---|
| `componentType` | `'a' | 'button' | 'span' | 'div'` | auto | Explicit component type to render |
| `fallbackComponentType` | `'span' | 'div' | 'button'` | `'span'` | Component to render when no href/onClick |
| Prop | Type | Default | Description |
|---|---|---|---|
| `aria-label` | `string` | - | ARIA label for accessibility |
| `aria-describedby` | `string` | - | ARIA describedby reference |
| `id` | `string` | - | Element ID |
Any `data-*` attributes are automatically forwarded to the rendered element.
Full URLs matching the current origin are automatically converted to relative paths:
```tsx // On https://example.com About // Renders: About ```
Supports various phone number formats:
```tsx // → tel:+14322386131 // → tel:+5122322212 // → tel:+5122322212 // → tel:+14322386131 // → tel:+5122322212;ext=123 ```
Automatically detects email addresses:
```tsx // → mailto:hello@example.com // → mailto:test@ex.com (unchanged) ```
Low-level hook for custom navigation logic:
```tsx import { useNavigation } from "@page-speed/pressable/hooks";
function CustomLink({ href }) { const { linkType, normalizedHref, target, rel, isInternal, isExternal, handleClick, } = useNavigation({ href });
return ( {href} ); } ```
| Property | Type | Description |
|---|---|---|
| `linkType` | `'internal' | 'external' | 'mailto' | 'tel' | 'none' | 'unknown'` | Detected link type |
| `normalizedHref` | `string | undefined` | Normalized URL |
| `target` | `'_blank' | '_self' | undefined` | Link target attribute |
| `rel` | `string | undefined` | Link rel attribute |
| `isInternal` | `boolean` | Whether link is internal |
| `isExternal` | `boolean` | Whether link is external |
| `shouldUseRouter` | `boolean` | Whether to use client-side routing |
| `handleClick` | `MouseEventHandler` | Click handler function |
Utility for merging Tailwind classes:
```tsx import { cn } from "@page-speed/pressable/utils";
function CustomButton() { return ( <Pressable href="/test" className={cn( "base-class", isActive && "active-class", { "conditional": someCondition } )} > Custom Button ); } ```
The Pressable component integrates seamlessly with the opensite-blocks navigation system:
```tsx // Set up navigation handler (typically done in opensite-blocks) window.__opensiteNavigationHandler = (href, event) => { // Custom navigation logic (e.g., React Router) navigate(href); return true; // Indicates navigation was handled };
// Pressable automatically uses the handler for internal links About ```
The component supports extensive CSS variable customization for button styles. See the button-variants.ts file for the complete list of CSS variables.
```css :root { --button-font-family: inherit; --button-font-weight: 500; --button-letter-spacing: 0; --button-line-height: 1.25; --button-text-transform: none; --button-transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1); --button-radius: 0.375rem; --button-shadow: none; --button-shadow-hover: none; } ```
```css :root { /* Default variant */ --button-default-bg: hsl(var(--primary)); --button-default-fg: hsl(var(--primary-foreground)); --button-default-hover-bg: hsl(var(--primary) / 0.9);
/* Outline variant */ --button-outline-bg: hsl(var(--background)); --button-outline-border: hsl(var(--border)); --button-outline-border-width: 1px;
/* ... and more */ } ```
The package is fully tree-shakable. Import only what you need:
```tsx // Import specific components import { Pressable } from "@page-speed/pressable/core"; import { useNavigation } from "@page-speed/pressable/hooks"; import { cn } from "@page-speed/pressable/utils";
// Or use granular imports import { Pressable } from "@page-speed/pressable/core/Pressable"; import { buttonVariants } from "@page-speed/pressable/core/button-variants"; ```
MIT
Contributions are welcome! Please follow the DashTrack ecosystem guidelines.
FAQs
Performance-optimized universal link/button component with automatic URL detection and normalization for DashTrack ecosystem
The npm package @page-speed/pressable receives a total of 66 weekly downloads. As such, @page-speed/pressable popularity was classified as not popular.
We found that @page-speed/pressable demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.

Security News
npm confirmed a tooling bug incorrectly marked several one-character packages as security holders and said it was working on a rollback.

Research
/Security News
Newer packages in this compromise use native extensions and .pth loaders to execute JavaScript stealers in developer environments.