Updated
Balloon Button
Customize
Color
Radius18px
Puff0.70
Crease spacing14px
Crease depth0.40
Bounce0.20
Installation
npx shadcn@latest add https://uibrik.com/r/balloon-button.jsonInstall the packages
npm install threeAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/balloon-button/balloon-button.tsx"use client"; import { useEffect, useRef, type CSSProperties, type ButtonHTMLAttributes, type PointerEvent } from "react"; import * as THREE from "three"; import { cn } from "@/lib/utils"; // The button is drawn as a height field: an inflated pillow (half a balloon) // over a rounded rectangle, with folds pinched in along the sealed edge. Lighting // comes from the normals of that field, so a press just reshapes the heights. // All lengths are CSS pixels, origin at the button centre, y up. const vertex = /* glsl */ ` void main() { gl_Position = vec4(position.xy, 0.0, 1.0); } `; const fragment = /* glsl */ ` precision highp float; uniform vec2 uCanvas; // canvas size, px uniform float uDpr; uniform vec2 uHalf; // button half size, px uniform float uRadius;
Adds the files to
components/uibrik/balloon-button and installs three. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/balloon-button.Usage
import { BalloonButton } from "@/components/uibrik/balloon-button/balloon-button";<BalloonButton label="Balloon Button" color="#000000" radius={18} puff={0.7} creaseSpacing={14} creaseDepth={0.4} bounce={0.2} onClick={(event) => {}}/>Where to use Balloon Button
Consumer app actions
An inflated button that dents when pressed makes a main action in a playful app feel tactile.
Kids and game products
Soft folds and a springy press suit brands where fun matters more than restraint.
Bold landing page CTAs
A WebGL-shaded button stands out from flat buttons when one call to action must win attention.
Pairs with Soft Button
Props
BalloonButton- label
- Type string
- "Balloon Button"
- Button text.
- color
- Type string
- "#000000"
- Balloon colour.
- radius
- Type number
- 18
- Corner radius.
- puff
- Type number
- 0.7
- How far the surface swells.
- creaseSpacing
- Type number
- 14
- Distance between folds along the edge.
- creaseDepth
- Type number
- 0.4
- How deep the folds pinch in.
- bounce
- Type number
- 0.2
- How far the dent springs back past rest on release.
- onClick
- Type MouseEventHandler<HTMLButtonElement>
- –
- Called on click, like any button.
- className
- Type string
- –
- Classes for the button.