A button and a matching link in default, outline, ghost and destructive styles.
Installation
Usage
import { Button } from "./ui/uicontext/button.ts"const Message = UiSchema.TaggedEnum({ ClickedSave: {} })export const SaveButton = (h: Html.H<typeof Message.Type>) => Button(h, { variant: "outline" }) .on("click", Message.ClickedSave()) .children("Save changes")Examples
As a link, and disabled
ButtonLink renders a real link with the button's look, for going somewhere instead of doing something.
API reference
Options
| Name | Type | Default | Description |
|---|---|---|---|
variant | "default" | "outline" | "ghost" | "destructive" | default | How much the button stands out: default for the main action, outline and ghost for quieter ones, destructive for one that deletes; default by default. |
size | "default" | "sm" | "icon" | "icon-sm" | "icon-xs" | default | Height and padding. The icon sizes are square, for a button that holds only an icon; default by default. |
style | StyleXStyles | — | StyleX styles applied after the button's own. |
type | "button" | "submit" | "reset" | button | What pressing it does in a form: submit sends the form, reset clears it; button by default, which does nothing on its own. |
Accessibility
- Renders a native
<button>, so Enter and Space press it and it joins the tab order.ButtonLinkrenders a real<a>with the same look. - An icon-only button needs an
aria-label.