Skip to content

Push Button

Pushbuttons are a variant of the toggle button which incorporate label and action into a single user interface element. Pushbuttons may provide a useful interface element where screen real estate is at a premium.

Guidelines

Web Components Usage

1. Installation

Install the Astro UXDS Push Button package via Command Line (Preferred Method)

sh
npm i --save @astrouxds/rux-push-button
npm i --save @astrouxds/rux-push-button

You may use Yarn, NPM, or your Node package manager of choice. The --save flag adds this component as a dependency in your package.json file.

Alternatively, download the Astro UXDS Component Library source to your project.

Via CLI:

sh
git clone https://github.com/RocketCommunicationsInc/astro-components.git
git clone https://github.com/RocketCommunicationsInc/astro-components.git

Or, download the Astro UXDS Components as a .zip

2. Import the Astro Push Button Web Component

This example assumes you're using the NPM package in node_modules. Otherwise, import the component using the path to the Astro Components directory in your project.

javascript
import { RuxPushButton } from '@astrouxds/rux-push-button/rux-push-button.js'
import { RuxPushButton } from '@astrouxds/rux-push-button/rux-push-button.js'

3. Render the Astro Push Button Web Component

Pass properties as attributes of the Astro Push Button custom element.

Provide a label for the Push Button inside the component node using the component’s slot.

xml
<rux-push-button checked>Push button label</rux-push-button>
<rux-push-button checked>Push button label</rux-push-button>

Basic HTML Usage

1. Include the Astro UXDS CSS file

Latest release is available in the static css directory.

xml
<link rel="stylesheet" href="/your-project/path/astro.css" />
<link rel="stylesheet" href="/your-project/path/astro.css" />

2. Markup the component using HTML and the Astro CSS classes

Astro CSS classes follow the BEM-style naming convention.

xml
<div class="rux-push-button">
  <input class="rux-push-button__input" id="pb1" type="checkbox"></input>
  <label class="rux-push-button__button" for="pb1">Push button label</label>
</div>
<div class="rux-push-button">
  <input class="rux-push-button__input" id="pb1" type="checkbox"></input>
  <label class="rux-push-button__button" for="pb1">Push button label</label>
</div>

Apply attributes such as disabled and/or checked on the <input> element.

xml
<div class="rux-push-button">
  <input class="rux-push-button__input" id="pb1" type="checkbox" disabled checked></input>
  <label class="rux-push-button__button" for="pb1">Push button label</label>
</div>
<div class="rux-push-button">
  <input class="rux-push-button__input" id="pb1" type="checkbox" disabled checked></input>
  <label class="rux-push-button__button" for="pb1">Push button label</label>
</div>

Attributes

AttributeTypeDefaultRequiredDescription
disabledBooleanfalseNoDisables the button via HTML disabled attribute. Button takes on a distinct visual state. Cursor uses the not-allowed system replacement and all keyboard and mouse events are ignored.
checkedBooleanfalseNoChecks the button via HTML checked attribute. Button takes on a distinct "enabled" or "selected" visual state.

For more information about AstroUXDS usage outside of a Web Component environment, please see Astro UXDS Stylesheets

Revision History

4.0
  • Replaced Polymer 3 implementation with LitElement for improved speed and interoperability with JS Frameworks as well as simpler template declaration now available in vanilla JavaScript.
2.1
  • Moved Pushbuttons to its own style sheet
1.4
  • Added rux_ prefixes and BEM-compatible classes to all satcom_-prefixed elements. NOTE: satcom_ will be removed in a future version
  • Removed prefixed linear gradients
  • Removed prefixed transition
  • Fixed added colon to checked pseudo class (e.g., checked became :checked)
  • Alignment issue fixed on toggle button label
  • Updated to WCAG colors
  • Updated transition speed

Properties

PropertyAttributeDescriptionTypeDefault
checkedcheckedChecks the push button via HTML checked attribute. Push button takes on a distinct "enabled" or "selected" visual state.booleanfalse
disableddisabledDisables the push button via HTML disabled attribute. Button takes on a distinct disabled visual state. Cursor uses the not-allowed system replacement and all keyboard and mouse events are ignored.booleanfalse
iconiconFor a button style guide, see the Button section in Astro UXDS Guidelines Displays an Astro icon matching this string. For a full list of available icons, see the Icons section in Astro UXDS Guidelinesstring | undefinedundefined
iconOnlyicon-onlyHides slotted text from the button by setting rux-button--icon-only classbooleanfalse
labellabelThe label of the push button.string'Push Button'
namenameThe name of the push button.string''
sizesizeChanges size of a push button from medium to small or large by setting sizing classes rux-button--small rux-button--large"large" | "medium" | "small" | undefinedundefined
valuevalueThe value of the push button.string''

Events

EventDescriptionType
ruxblurFired when an element has lost focus - HTMLElement/blur_eventCustomEvent<any>
ruxchangeFired when an alteration to the input's value is committed by the user and emits the value on the event.detail - HTMLElement/change_eventCustomEvent<any>

Shadow Parts

PartDescription
"container"the label of rux-push-button
"icon"the optional rux-icon

Dependencies

Depends on

Graph

mermaid
graph TD;
  rux-push-button --> rux-icon
  style rux-push-button fill:#f9f,stroke:#333,stroke-width:4px
graph TD;
  rux-push-button --> rux-icon
  style rux-push-button fill:#f9f,stroke:#333,stroke-width:4px

Built with StencilJS