w6w docs

Buttons and icons

Icon-only buttons with a required accessible name, and the glyph set they draw from. All four are props-only.

For a text button, use a plain <button className="w6w-btn"> and the library’s button styles apply.

IconButton

A square, icon-only button. Its label is always the aria-label, so screen readers announce it even though nothing visible says it.

PropTypeDefaultWhat it does
labelstringRequiredAccessible name. Also the tooltip unless title is set.
onClick() => voidRequiredClick handler.
iconIconNameNoneA glyph from the shared set, by name.
childrenReactNodeNoneYour own glyph markup. Wins over icon if you pass both.
iconSizenumber16Size passed to the named icon.
titlestringlabelTooltip text, when it should differ from the accessible name.
dangerbooleanfalseDanger styling, for destructive actions.
disabledbooleanfalseDisables the button.
aria-pressed, aria-expandedbooleanNonePassed through, for toggle and disclosure buttons.
className, data-testidstringNonePassed through.

It forwards a ref to the underlying <button>.

import { IconButton } from "@w6w/ui";

<IconButton label="Show history" icon="history" onClick={() => setOpen(true)} />

Icon

One glyph from the shared set, drawn in currentColor.

PropTypeDefaultWhat it does
nameIconNameRequiredWhich glyph.
sizenumber16Width and height in px.
labelstringNoneOmit for a decorative glyph (it gets aria-hidden). Pass it when the icon stands alone as content: it then renders as role="img" with this name.
classNamestringNoneAdded to w6w-icon.
import { Icon } from "@w6w/ui";

<span className="w6w-muted">
  <Icon name="warning" /> Rate limited
</span>

iconNames lists every available name at runtime. Today’s set: edit, edit-2, delete, copy, check, close, history, clock, json, code, sync, cloud-download, eye, play, stop, warning, file-text, settings, settings-2, github, user, users, logout, id-card, dashboard, pulse, workflow, globe, lambda, sliders, file, plug, grid, folder, git-branch, coin, building, server, price-tag, lang-node, terminal, lang-python, lang-curl, sun, moon, circle-half, layout, run, trash, maximize, form and braces.

EditButton and DeleteButton

Ready-made IconButtons: EditButton draws the pencil, DeleteButton draws the trash can and is always danger-styled. Both take label, onClick, disabled, className and data-testid.

DeleteButton doesn’t ask for confirmation. Gate it yourself, for example with ConfirmModal:

import { ConfirmModal, DeleteButton, EditButton } from "@w6w/ui";

<EditButton label="Rename connection" onClick={startRename} />
<DeleteButton label="Delete connection" onClick={() => setConfirming(true)} />
{confirming && (
  <ConfirmModal
    title="Delete connection?"
    message="Workflows using it will stop authenticating."
    confirmLabel="Delete"
    onConfirm={() => {
      remove();
      setConfirming(false);
    }}
    onClose={() => setConfirming(false)}
  />
)}

Where to next

  • Data display: app icons, list rows and copy-to-clipboard.
  • Modals: ConfirmModal and the other dialogs.