npm.io
2.8.4 • Published 4d ago

@justeattakeaway/pie-icon-button

Licence
Apache-2.0
Version
2.8.4
Deps
3
Size
55 kB
Vulns
0
Weekly
0
Stars
42

@justeattakeaway/pie-icon-button

Source Code | Design Documentation | NPM

GitHub Workflow Status

@justeattakeaway/pie-icon-button is a Web Component built using the Lit library. It offers a simple and accessible icon button component for web applications.

Table of Contents

Installation

To install any of our web components in your application, we would suggest following the getting started guide to set up your project.

Ideally, you should install the component using the @justeattakeaway/pie-webc package, which includes all of the components. Or you can install the individual component package.

Documentation

Properties
Prop Options Description Default
aria { label?: string }, { labelledby?: string }, { describedby?: string }, { description?: string }, { expanded?: boolean }, { controls?: string }, { haspopup?: string } The ARIA attributes available to use on the icon button. Offers label, labelledby, describedby, description, expanded, controls, and haspopup. description is applied as an aria-description attribute, so the text travels as a string and is not bound by IDREF resolution. undefined
size "xsmall", "small", "medium", "large" Set the size of the icon button. "medium"
variant "primary", "primary-alternative", "primary-alternative-dark", "secondary", "outline", "ghost", "ghost-secondary", "ghost-secondary-dark", "inverse", "inverse-outline", "ghost-inverse", "ghost-inverse-light", "translucent" Set the variant of the icon button. "primary"
disabled true, false If true, disables the icon button. false
isLoading true, false If true, displays a loading indicator inside the icon button. false
Slots
Slot Description
default The default slot is used to pass an icon into the icon button component. Please use an icon from justeattakeaway/pie-icons-webc.
CSS Variables

This component does not expose any CSS variables for style overrides.

Events

This component does not emit any custom events. In order to add event listening to this component, you can treat it like a native HTML element in your application.

Usage Examples

For HTML:

// import as module into a js file e.g. main.js
import '@justeattakeaway/pie-webc/components/icon-button.js';
import '@justeattakeaway/pie-icons-webc/dist/IconClose.js';
<!-- pass js file into <script> tag -->
<pie-icon-button onclick="e => console.log(e)">
  <icon-close></icon-close>
</pie-icon-button>
<script type="module" src="/main.js"></script>

For Native JS Applications, Vue, Angular, Svelte, etc.:

// Vue templates (using Nuxt 3)
import '@justeattakeaway/pie-webc/components/icon-button.js';

<pie-icon-button @click="handleClick">
  <icon-close></icon-close>
</pie-icon-button>

For React Applications:

import { PieIconButton } from '@justeattakeaway/pie-webc/react/icon-button.js';
import { IconClose } from '@justeattakeaway/pie-icons-webc/dist/react/IconClose.js';

<PieIconButton onClick={handleClick}>
  <IconClose></IconClose>
</PieIconButton>

Questions and Support

If you work at Just Eat Takeaway.com, please contact us on #help-designsystem. Otherwise, please raise an issue on Github.

Contributing

Check out our contributing guide for more information on local development and how to run specific component tests.