1.35.0 • Published 4 years ago

@schibstedspain/sui-atom-button v1.35.0

Weekly downloads
36
License
MIT
Repository
-
Last release
4 years ago

Button

Atom Element: SUI button

npm.io

Installation

$ npm install @schibstedspain/sui-atom-button --save

Usage

Basic usage

import Button from '@schibstedspain/sui-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 '@schibstedspain/sui-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 '@schibstedspain/sui-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 inside Form

By default AtomButton inside a form will submit the form

import Button from '@schibstedspain/sui-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 '@schibstedspain/sui-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 '@schibstedspain/sui-atom-button'

return (
  <Button link href='http://www.schibsted.com/' target='_blank'>Link</Button>
)

output:

<a class="sui-AtomButton sui-AtomButton--link" href="http://www.schibsted.com/" target='_blank'>Link</a>

Find full description and more examples in the demo page.

1.35.0

4 years ago

1.34.0

4 years ago

1.33.0

4 years ago

1.32.0

5 years ago

1.31.0

5 years ago

1.30.0

5 years ago

1.29.0

5 years ago

1.28.0

5 years ago

1.27.0

5 years ago

1.26.0

5 years ago

2.0.0

5 years ago

1.25.0

5 years ago

1.24.0

5 years ago

1.23.0

5 years ago

1.22.0

6 years ago

1.21.0

6 years ago

1.20.0

6 years ago

1.19.0

6 years ago

1.18.0

6 years ago

1.17.0

6 years ago

1.16.0

6 years ago

1.15.0

6 years ago

1.14.0

6 years ago

1.13.0

6 years ago

1.12.0

6 years ago

1.11.0

6 years ago

1.10.0

6 years ago

1.9.0

6 years ago

1.8.0

6 years ago

1.7.0

6 years ago

1.6.0

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago