Button

July 31, 2019 ยท View on GitHub

Displays a text button with a Ripple effect.

Main features

  • Ripple effect, optionally disable
  • Customize ripple effect (center, opacity, speed, color)
  • Hover effect, optionally disable
  • Selected state
  • After click, inactivate for n seconds
  • Add borders
  • Keyboard control

Usage

Keyboard control

Press TAB to navigate to a button - it will show a highlight. Press ENTER to execute the equivalent of a click.

Options

Button specific options

ParameterRequiredTypeDefaultDescription
borderoptionalBooleanfalseSet to true to add a border; by default the border has no color - set border color to class pe-button__content to see the border
containedoptionalBooleanfalseSet to true to give the button a Contained Button appearance (larger side padding)
disabledoptionalBooleanfalseDisables the button
dropdownoptionalObjectSet to a trueish value to add a dropdown icon; use dropdown.open to show an "open" icon, otherwise a "closed" icon is shown; note that a dropdown button has no minimum width
extraWideoptionalBooleanfalseSet to true to add even more side padding
formaction (React: formAction)optionalString"The URI of a program that processes the information submitted by the button. If specified, it overrides the action attribute of the button"s form owner." source:MDN
highLabeloptionalBooleanfalseThis does not make the button higher in itself; set to true to move the vertical "outer" padding to the label, creating a higher hover effect (and higher separator when using Button Group)
inactivateoptionalNumberThe number of seconds after tap/click when the button is inactive; useful to prevent double clicks
inactiveoptionalBooleanSet to true to disable button events and ripple/wash effects
inkoptionalBooleantrueSet to false to disable the ripple effect on click/tap
labeluse label or contentStringThe button label
rippleoptional (valid if ink is true)Options objectPass ripple options to define ripple behavior
selectedoptionalBooleanfalseSet to true to show the button as selected
separatorAtStartoptionalBooleanfalseSet to true to add a separator - normally placed at the left, with RTL languages at the right side
textStyleoptionalObjectStyle object for the text label
urloptionalObject with href, optionally oncreate (for Mithril 1.x) or onClick (for React) or to (for React Router)URL location; Mithril 2.x: only use url.href and set element to m.route.Link; Mithril 1.x: for in-app route linking set oncreate : m.route.link; React: for in-app route linking use onClick and a router such as react-router-dom
washoptionalBooleantrueSet to false to hide the effect on hover

Raised button options

A raised button is a button with option raised: true.

ParameterRequiredTypeDefaultDescription
raisedoptionalBooleanfalseSet to true to create a Raised Button
shadowDepthoptionalNumber 0-50The shadow depth
animateOnTapoptionalBooleantrueSet to false to remove shadow depth animation and subsequent redraw
increaseoptionalNumber1The shadow depth increment/decrement on tap; the maximum shadow depth is 5
shadowDepthoptionalNumber 0-51The shadow depth

Common component options

ParameterRequiredTypeDefaultDescription
afteroptionalString, hyperscript or componentExtra content after main content; note that this content is placed right of preceding elements with a higher stacking depth
beforeoptionalString, hyperscript or componentExtra content before main content; note that this content is placed left of subsequent elements with a lower stacking depth
classNameoptionalStringExtra CSS class appended to pe-text-button
contentuse label or contentString, hyperscript or componentAlternative content; replaces children and ignores label
elementoptionalString"a"HTML element tag; may also be "button"
eventsoptionalObjectOptions object containing one or more standard events such as onclick (React: onClick)
idoptionalStringHTML element id
styleoptionalObjectFor setting simple style attributes
tabindex (React: tabIndex)optionalInteger0Tab index
toneoptionalString: "dark" or "light"Renders the component light on dark (sets class pe-dark-tone); use "light" to locally inverse (sets class pe-light-tone)

Composition

Button is optionally composed from:

CSS classes