# Pressable Feedback

Wraps any content with a scale-down press animation.

- Category: Core Elements
- Page: https://wunderui.com/components/pressable-feedback
- Tier: Free

## Install

```bash
npx wunderui-cli add pressable-feedback
```

## Import

```tsx
import { PressableFeedback } from "@/components/wunderui/pressable-feedback"
```

## Minimal usage

Then use it:

```tsx
import { PressableFeedback } from "@/components/ui/pressable-feedback"

export function QuickAction() {
  return (
    <PressableFeedback
      onPress={() => console.log("opened")}
      className="rounded-xl border border-border bg-card p-4 text-sm font-medium text-foreground hover:bg-bg-page"
    >
      New invoice
    </PressableFeedback>
  )
}
```

Expected result: You should see a bordered tile that says New invoice. Hold the mouse button on it and it shrinks a little; release and it springs back and logs opened.

## Usage

```tsx
import { useState } from "react"
import { PressableFeedback } from "@/components/ui/pressable-feedback"

export function Example() {
  const [count, setCount] = useState(0)

  return (
    <div className="flex flex-col items-center gap-4">
      <PressableFeedback onPress={() => setCount(count + 1)} className="rounded-md border border-border bg-card px-4 py-2 text-sm font-medium text-foreground hover:bg-bg-page">
        Press me
      </PressableFeedback>
      <p role="status" className="text-sm text-text-secondary">
        Pressed {count} {count === 1 ? "time" : "times"}
      </p>
    </div>
  )
}

```

## When to use

### Use Pressable Feedback for

- Tiles, cards and rows that people press, such as quick actions or a template picker
- A link or a button of your own that should react to a press the way the library buttons do
- Touch layouts, where a press needs to be seen at once under the finger

### Use something else

- [Button](https://wunderui.com/components/button) for a normal action; it already reacts to a press
- [Icon Button](https://wunderui.com/components/icon-button) for an action that is only an icon
- [Card](https://wunderui.com/components/card) for a surface that holds content, with an interactive mode for whole-card links

## Keyboard

Without asChild it is a native button, so the browser provides focus and activation. With asChild the keys are those of the child.

| Key | Action |
|---|---|
| `Tab` or `Shift+Tab` | Moves focus to the pressable and away from it. The focus ring shows while it is focused. |
| `Enter` | Activates a button or a link and calls `onPress`. Enter does not hold the pressed look; only the click runs. |
| `Space` | Holds the pressed look while the key is down on a button, and activates it on release. |

## Behavior

What the pressable does while it is held, with a mouse, a finger or a key, and how it relates to its child.

- **Pressed:** Pressing the mouse button sets the pressed look, 95 % scale at 90 % opacity, and releasing or leaving the element returns it. A finger and the Space key get the same look.
- **Own button:** Alone it renders a button around its children and calls the press handler on click. It takes no other attributes, so it cannot be disabled or labelled: its content names it.
- **asChild:** With asChild and one element as child, the effect goes onto that child: class names merge and its own handlers still run. A non-element child falls back to the own button.
- **Hover:** There is no hover look of its own. Add one to the content.
- **Focus:** The focus ring is the standard one: an indigo border with a 2 px ring, shown for keyboard focus.
- **Motion:** The scale animates with the fast duration and the move easing, so a press answers at once and springs back softly.
- **Reduced motion:** With reduced motion the transition is removed. The scale and opacity still apply instantly, so a press is seen without anything moving.

## Anatomy

- `PressableFeedback`: Scales its content to 95 % at 90 % opacity while pressed. Alone it renders a button, with asChild it lends the effect to its single child, and it adds a focus ring only.
- `Content`: What you pass as children: a label, an icon with a label, a card body. It scales together with the button.

## Best practices

### Do

- Use it to give press feedback to something that is not a button yet, such as a tile, card or row. Buttons and icon buttons already react to a press.
- Pass asChild when the child is already a button or a link. Without it you nest a button inside a button, which is invalid HTML.
- Handle the action with the press handler. With asChild the child's own click handler runs first, then the press handler.
- Give the pressable its own look: a border, a fill and a hover tone. The component only adds the scale, the opacity and the focus ring.

### Don't

- Don't put links or other buttons inside it without asChild. They would sit inside a button, and nested interactive elements break.
- Don't use it for a disabled state or a name that is not in the content. Its own button takes neither; use asChild and put them on the child.
- Don't use it on a large surface, such as a whole panel. A 5 % scale of a wide element moves its edges visibly.

## API reference

### PressableFeedback

| Prop | Type | Default | Description |
|---|---|---|---|
| children* | React.ReactNode |  | The content to scale. With `asChild` it must be a single element, which receives the effect. |
| asChild | boolean | false | Apply the press effect to the child element instead of wrapping it. |
| className | string |  | Extra classes for the button, or merged into the child with `asChild`. This is where the look goes: border, fill, padding and hover. |
| onPress | () => void |  | Called when the pressable is activated, from the click. With `asChild` it runs after the child's own `onClick`. |

## Examples

### Wrapping: its own button, or lent to a button or a link

```tsx
import { PressableFeedback } from "@/components/ui/pressable-feedback"

export function Example() {
  return <PressableFeedback className="rounded-md border border-border bg-card px-4 py-2 text-sm font-medium text-foreground hover:bg-bg-page">Press me</PressableFeedback>
}

```

### State: at rest and held down

```tsx
import { PressableFeedback } from "@/components/ui/pressable-feedback"

export function Example() {
  return (
    <PressableFeedback className="rounded-md border border-border bg-card px-4 py-2 text-sm font-medium text-foreground hover:bg-bg-page">
      Press me
    </PressableFeedback>
  )
}

```

## In context

### Quick actions: tiles that press in

Each tile is its own button with the press effect. The line below says which one was chosen.

```tsx
import { useState } from "react"
import { PressableFeedback } from "@/components/ui/pressable-feedback"
import { FilePlus, Link2, Upload, UserPlus } from "lucide-react"

const actions = [
  { label: "New invoice", icon: FilePlus },
  { label: "Add member", icon: UserPlus },
  { label: "Upload file", icon: Upload },
  { label: "Share link", icon: Link2 },
]

export function QuickActions() {
  const [last, setLast] = useState("")

  return (
    <div className="flex flex-col gap-4">
      <div className="grid grid-cols-2 gap-3">
        {actions.map((action) => {
          const Icon = action.icon
          return (
            <PressableFeedback key={action.label} onPress={() => setLast(action.label)} className="flex w-36 flex-col items-center gap-2 rounded-xl border border-border bg-card p-4 text-sm font-medium text-foreground hover:bg-bg-page">
              <Icon aria-hidden className="size-5" strokeWidth={1.5} />
              {action.label}
            </PressableFeedback>
          )
        })}
      </div>
      <p role="status" className="text-sm text-text-secondary">
        {last === "" ? "Choose an action." : `${last} opened.`}
      </p>
    </div>
  )
}

```

### Template picker: the effect lent to buttons that stay selected

The child keeps its own attributes, here aria-pressed, so the choice is announced. The effect adds nothing to the markup.

```tsx
import { useState } from "react"
import { PressableFeedback } from "@/components/ui/pressable-feedback"
import { Check } from "lucide-react"

const templates = ["Blank", "Invoice", "Report"]

export function TemplatePicker() {
  const [selected, setSelected] = useState("Blank")

  return (
    <div role="group" aria-label="Template" className="grid grid-cols-3 gap-3">
      {templates.map((name) => (
        <PressableFeedback key={name} asChild>
          <button
            type="button"
            aria-pressed={selected === name}
            onClick={() => setSelected(name)}
            className={
              selected === name
                ? "flex h-24 flex-col items-start justify-between rounded-xl border border-border bg-bg-subtle p-3 text-sm font-medium text-foreground"
                : "flex h-24 flex-col items-start justify-between rounded-xl border border-border bg-card p-3 text-sm font-medium text-foreground hover:bg-bg-page"
            }
          >
            {name}
            <Check aria-hidden strokeWidth={1.5} className={selected === name ? "size-4" : "size-4 opacity-0"} />
          </button>
        </PressableFeedback>
      ))}
    </div>
  )
}

```

### Article card: the whole card is one link

A link holding a title, text and a call to action presses in as one piece. Its own click handler runs first, then the press handler.

```tsx
import { useState } from "react"
import { PressableFeedback } from "@/components/ui/pressable-feedback"
import { ArrowRight } from "lucide-react"

export function ArticleCard() {
  const [opened, setOpened] = useState(false)

  return (
    <div className="flex flex-col gap-4">
      <PressableFeedback asChild>
        {/* The click is stopped here only because this link is a stand-in for a real route. */}
        <a
          href="#"
          onClick={(event) => {
            event.preventDefault()
            setOpened(true)
          }}
          className="flex flex-col gap-1 rounded-xl border border-border bg-card p-4 hover:bg-bg-page"
        >
          <span className="text-sm font-semibold text-foreground">Design tokens in practice</span>
          <span className="text-sm text-text-secondary">How WunderUI keeps colour, spacing and motion in one place.</span>
          <span className="mt-2 flex items-center gap-1 text-sm font-medium text-text-link">
            Read article
            <ArrowRight aria-hidden className="size-4" strokeWidth={1.5} />
          </span>
        </a>
      </PressableFeedback>
      <p role="status" className="text-sm text-text-secondary">
        {opened ? "The article would open here." : ""}
      </p>
    </div>
  )
}

```

## For AI agents

`get_component("pressable-feedback")`

Hand your agent this page as Markdown or the WunderUI MCP server, not a screenshot.
