Skip to content

Instantly share code, notes, and snippets.

@PompaDonpa
Created September 3, 2022 00:47
Show Gist options
  • Save PompaDonpa/52a3d0cd8522bff1e8ed42e00efa8a90 to your computer and use it in GitHub Desktop.
Save PompaDonpa/52a3d0cd8522bff1e8ed42e00efa8a90 to your computer and use it in GitHub Desktop.
Div as a Button
import React from 'react'
import PropTypes from 'prop-types'
const allowedKeys = ['Enter', 'Space']
const DivButton = ({ hideText, setHideText }) => {
return (
<div
role="button"
tabIndex="0"
onClick={() => setHideText(!hideText)}
onKeyPress={e => {
allowedKeys.indexOf(e?.code) > -1 &&
setHideText(!hideText)
}}
css={(
display: 'inline-block',
textAlign: 'center',
color: 'bottontext',
borderRadius: 2,
backgroundColor: '#EFEFEF',
boxSizing: 'border-box',
padding: '1px 7px',
border: '1px outset #767676',
cursor: 'pointer',
':hover': {
color: '#aaaaaa'
}
)}
>
I am a div
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment