Bedform UIButtons

Icon Button

An icon-only button.

Icon Button

*
boolean
*
string
*

Usage

import { IconButton } from "@bedform/ui/icon-button";

export function CloseButton() {
  return (
    <IconButton type="button" aria-label="Close">
      <ore-icon aria-hidden="true">
        <svg viewBox="0 0 8 8">
          <path
            fill="currentColor"
            fillRule="evenodd"
            d="M.5.5h1v1h.966v1h-1v-1H.5zm7 1h-1v-1h1zm-2 1v-1h1v1zm-1 1h1v-1h-1zm0 1v-1h-1v-1h-1v1h1v1h-1v1h-1v1h-1v1h1v-1h1v-1h1v-1zm0 0h1v1h-1zm1.034 2H6.5v1h1v-1h-.966v-1h-1z"
          />
        </svg>
      </ore-icon>
    </IconButton>
  );
}

ore-icon is a styling element; see Icons for how to declare it for TypeScript.

Disabled

// closeIcon is the <svg> element from the example above.
<IconButton type="button" aria-label="Close" disabled>
  <ore-icon aria-hidden="true">{closeIcon}</ore-icon>
</IconButton>

API

IconButton renders a native button and accepts every button attribute, event and form behavior. It forwards its ref to the button.

PropTypeDefault
disabledbooleanfalse
type"button" | "reset" | "submit""submit"

CSS variables

VariablePurpose
--ore-icon-button-unitBase size unit
--ore-icon-button-backgroundFace background color
--ore-icon-button-highlightTop highlight color
--ore-icon-button-shadow-colorBottom shadow color
--ore-icon-button-cornerCorner accent color
--ore-icon-button-borderBorder color
--ore-icon-button-foregroundIcon and text color
--ore-icon-button-place-itemsInternal grid item alignment
--ore-icon-button-widthButton width
--ore-icon-button-heightButton height
--ore-icon-button-paddingInternal padding
--ore-icon-button-box-shadowAdditional outer box shadow

Accessibility

Add an aria-label to describe the action. The icon inside the button should use aria-hidden="true".

On this page