This browser is not supported. The glass needs a Chromium browser or Electron. Why

Button

SwiftUI's Button in the system styles, as a real <button>. The glass styles are interactive glass: they scale, glow under the finger and spring back. The others are flat fills that fade while pressed.

import { Button } from "@adamexu/glass";

Styles

buttonStyle is SwiftUI's .buttonStyle(_:). Its default, automatic, draws borderless, as on iOS outside lists and toolbars.

<Button buttonStyle="glassProminent">Glass Prominent</Button>
<Button buttonStyle="glass">Glass</Button>
<Button buttonStyle="borderedProminent">Bordered Prominent</Button>
<Button buttonStyle="bordered">Bordered</Button>
<Button buttonStyle="borderless">Borderless</Button>
<Button buttonStyle="plain">Plain</Button>

Icons, sizes and shapes

icon takes a Lucide icon component, drawn before the title at 1.2 times the font size. In a circle the prominent and bordered styles show the icon alone; labelStyle="iconOnly" does it anywhere and makes the title the accessible name.

<Button buttonStyle="glass" icon={Heart}>Favorite</Button>
<Button buttonStyle="glass" borderShape="circle" icon={Plus} aria-label="Add" />
<Button buttonStyle="glassProminent" controlSize="large">Large</Button>
<Button buttonStyle="bordered" controlSize="small">Small</Button>
<Button buttonStyle="borderedProminent" controlSize="large" borderShape="roundedRectangle">Rounded</Button>
<Button buttonStyle="glassProminent" controlSize="large" borderShape="circle" icon={Star} labelStyle="iconOnly">Star</Button>

Roles, tint and clear glass

role="destructive" makes the accent the system red, so a bordered label or a prominent fill turns red; a glass label stays primary, as on iOS. tint takes any CSS colour; prominent labels stay white, so pick a dark enough tint. glass="clear" is the clearer glass of .glass(.clear), for over photos and video.

<Button buttonStyle="bordered" role="destructive" icon={Trash2}>Delete</Button>
<Button buttonStyle="glassProminent" tint="#ff5a1f">Tinted</Button>
<Button buttonStyle="bordered" tint="#ff5a1f">Tinted</Button>
<Button buttonStyle="glass" glass="clear">Clear</Button>
<Button buttonStyle="glass" disabled>Disabled</Button>

Props

PropTypeDefaultDescription
buttonStyle"automatic" | "glass" | "glassProminent" | "bordered" | "borderedProminent" | "borderless" | "plain""automatic"SwiftUI .buttonStyle(_:). automatic draws borderless.
glass"regular" | "clear""regular"The glass style's variant: .glass(.clear). Only for buttonStyle="glass".
controlSize"mini" | "small" | "regular" | "large" | "extraLarge""regular"SwiftUI .controlSize(_:).
borderShape"automatic" | "capsule" | "circle" | "roundedRectangle" | { roundedRectangle: number }"automatic"SwiftUI .buttonBorderShape(_:). { roundedRectangle: r } is .roundedRectangle(radius: r).
role"destructive" | "cancel" | "close" | "confirm"-SwiftUI Button(role:). destructive makes the accent the system red (a glass label stays primary).
tintstring-SwiftUI .tint(_:): any CSS colour.
iconComponentType (a Lucide icon)-The Label's icon, drawn at round(1.2 x font size) before the title.
labelStyle"automatic" | "titleAndIcon" | "titleOnly" | "iconOnly""automatic"SwiftUI .labelStyle(_:). With iconOnly a string title becomes the aria-label.
fontnumber-The label's size in pt, whatever the control size (padding keeps to the control size).
childrenReactNode-The title.
disabledbooleanfalseSwiftUI .disabled(_:).
...restButtonHTMLAttributes-type, onClick, form props, aria-*. className and style go on the outer box.

Behaviour

A click only counts if the finger lifts within reach of the button, as on iOS: drag well off it and let go to cancel. Space and Enter press it from the keyboard.

SwiftUI

SwiftUI@adamexu/glass
.buttonStyle(.glass) / .glassProminent<Button buttonStyle="glass"> / "glassProminent"
.buttonStyle(.glass(.clear))<Button buttonStyle="glass" glass="clear">
.controlSize(.large)controlSize="large"
.buttonBorderShape(.circle)borderShape="circle"
Button(role: .destructive)role="destructive"
Button("Add", systemImage:)<Button icon={Plus}>Add</Button>
.labelStyle(.iconOnly)labelStyle="iconOnly"
.tint(.orange)tint="orange"