npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@s-ui/react-atom-button

v1.96.0

Published

Atom Element: SUI button

Downloads

9,787

Readme

Button

Atom Element: SUI button

Installation

$ npm install @s-ui/react-atom-button --save

Usage

Basic usage

import Button from '@s-ui/react-atom-button'

return (
  <div>
    <Button>Normal</Button>
    <Button focused>Focused</Button>
    <Button size="large" disabled>
      Disabled
    </Button>
  </div>
)

Flexible props

All props available from regular buttons can be used.

import Button from '@s-ui/react-atom-button'

return (
  <div>
    <Button onClick={() => alert('Primary with onClick')}>
      Primary with onClick
    </Button>
    <Button type="accent" title="Title: Lorem Ipsum">
      Accent with title
    </Button>
    <Button type="secondary" className="customClass">
      Secondary with className
    </Button>
  </div>
)

Button with AtomIcon

You could use the AtomButton along the AtomIcon in order to show the button text with an icon. The proper size and color of the AtomIcon will be used according to the needs of the AtomButton definition.

import Button from '@s-ui/react-atom-button'
import AtomIcon from '@s-ui/react-atom-icon'

const Icon = (
  <AtomIcon>
    <svg viewBox="0 0 24 24">
      <path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" />
    </svg>
  </AtomIcon>
)

return (
  <div>
    <Button leftIcon={Icon} />
    <Button size="large" rightIcon={Icon}>
      Large icon
    </Button>
    <Button size="small" rightIcon={Icon}>
      Small icon
    </Button>
  </div>
)

Button shape

Use shape prop to modify the border radius of the component. Choose between: squared, rounded and circular

import Button, {atomButtonShapes} from '@s-ui/react-atom-button'

return (
  <>
    <AtomButton shape={atomButtonShapes.SQUARED} />
    <AtomButton shape={atomButtonShapes.ROUNDED} />
    <AtomButton shape={atomButtonShapes.CIRCULAR} />
  </>
)

Button loading

Set isLoading prop to display the loading state of a button. Optionally, use loader prop if you want to overwrite the default spinner and loadingText prop if you want to display some text next to the loader.

import Button from '@s-ui/react-atom-button'

return (
  <>
    <AtomButton isLoading />
    <AtomButton loadingText="Submitting" isLoading />
  </>
)

Button with elevation

Set elevation prop to display a shadow around the button. If it's not set no shadow will be shown.

import Button from '@s-ui/react-atom-button'
return (
  <>
    <Button elevation="medium">Example</Button>
    <Button elevation="large">Example</Button>
  </>
)

Button inside Form

By default AtomButton inside a form will submit the form

import Button from '@s-ui/react-atom-button'

return (
  <form onSubmit={() => window.alert('Submit!')}>
    <div>
      <input type="text" placeholder="Put your name" />
    </div>
    <div>
      <Button>Submit</Button>
    </div>
  </form>
)

If we need several AtomButton inside a form we can specify which one we want to submit the form w/ props isButton and isSubmit

import Button from '@s-ui/react-atom-button'

return (
  <form onSubmit={() => window.alert('Submit!')}>
    <div>
      <input type="text" placeholder="Put your name" />
    </div>
    <div>
      <Button isButton onClick={() => window.alert('Click!')}>
        Click Me!
      </Button>
      <Button isButton onClick={() => window.alert('Click!')}>
        Click Me!
      </Button>
    </div>
    <div>
      <Button isSubmit>Submit</Button>
    </div>
  </form>
)

Rendering a link

When link property is passed, the component will render an html link.

import Button from '@s-ui/react-atom-button'

return (
  <Button
    link
    href="https://www.adevinta.com"
    target="_blank"
    rel="nofollow noopener"
  >
    Link
  </Button>
)

output:

<a
  class="sui-AtomButton sui-AtomButton--link"
  href="https://www.adevinta.com"
  target="_blank"
  >Link</a
>

Find full description and more examples in the demo page.