Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
react-button
Advanced tools
A carefully crafted button for React
$ npm install react-button --save
See Changelog
var Button = require('react-button')
function clicked(event){}
<Button onClick={clicked} >Export</Button>
<Button activeStyle={{position:'relative', top: 1}}>Save as</Button>
react-button
does not depend on any css files. All styles are inline in the react component.
react-button
can also be used as a toggle button
var pressed = true
function toggle(){
pressed = !pressed
//now re-render
}
//controlled behavior
<Button pressed={pressed} onClick={toggle}/>
//uncontrolled
<Button defaultPressed={true} pressedStyle={{color: 'blue'}} />
By default, the button comes with some structural styles as well as with styles for a default nice theme.
If you don't want the button to render with the default theme, just specify theme=''
(or any falsy value).
<Button theme='' onClick={function(){}} />
Or you can specify your own theme for the button.
The value for the theme
property is just an object with different styles
var theme = {
disabledStyle: { background: 'gray'},
overStyle: { background: 'red'},
activeStyle: { background: 'red'},
pressedStyle: {background: 'magenta', fontWeight: 'bold'},
overPressedStyle: {background: 'purple', fontWeight: 'bold'}
}
<Button theme={theme} defaultPressed={true}/>
Or, you can specify a theme as string: 'default' or 'primary'. Those are the only two themes that come built into the ReactButton
. You can get the styles for these:
var themes = require('react-button').themes
themes.gray = {
style: {...},
overStyle: {...}
}
<Button theme={themes.primary} />
//since 'gray' is added to the exported theme object,
//you can use it as a named theme
<Button theme='gray' />
You can style different button states - over (when mouse is over button), active (when mouse is down on the button)
<Button overStyle={{background: 'blue'}} activeStyle={{background: 'red'}} />
If you specify overStyle
, activeStyle
, pressedStyle
, overPressedStyle
etc, you are overwriting the values from the theme. The theme styles have the lowest precedence.
pressed
or defaultPressed
(as boolean values). This is called before onClick
Button.themes
Button.themes
, but it can be modified using this propertyIf you want to modify the default look for all buttons, just modify Button.themes.default
var Button = require('react-button')
var themes = Button.themes
themes.default.style = { ... }
themes.default.overStyle = { ... }
<Button>save</Button>
Style props are applied in this order:
style - default style
disabledStyle - style to be applied when the button is disabled. If disabled, no other over/active/pressed styles are applied.
focusedStyle - style to be applied to focused button
pressedStyle
focusedPressedStyle
overStyle
overFocusedStyle
overPressedStyle
overFocusedPressedStyle
activeStyle - style to be applied on active button (mousedown over button)
activeFocusedStyle
activePressedStyle
activeFocusedPressedStyle
You can set all these props both on the theme object, or on the button itself.
inline-flex
. Specify block: true
if you want to use display: flex
(or use style.display: 'flex').onStyleReady
)$ npm install
$ npm run dev # to start webpack-dev-server
$ npm run serve # to start http-server on port 9091
now navigate to localhost:9091
FAQs
React Button
We found that react-button demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.