Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="app"></div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Lato')

$default: #fff
$primary: #00b2d0
$secondary: #00c92b
$alert: #e53d00

=btn-color($color)
  &
    background: $color
    &:hover
      background: $color*.9
      box-shadow: 1px 1px 1px #333

.app
  width: 90%
  margin: 0 auto
  display: flex
  flex-direction: column
  justify-content: center
  font-family: 'Lato', sans-serif
  
.button
  margin: 0.5em
  padding: .5em 1.5em
  border: 1px solid #000
  color: #fff
  border-radius: 4px
  cursor: pointer
  transition: background .20s ease-in, box-shadow .20s ease-in
  text-transform: uppercase
  
  &--default
    +btn-color($default)
    color: #000
  &--primary
    +btn-color($primary)
  &--secondary
    +btn-color($secondary)
  &--alert
    +btn-color($alert)
  &--round
    border-radius: 50%
    padding: 1em
  &--disabled
    opacity: .3
    cursor: initial
    &:hover
      box-shadow: none
      
  &:active
    box-shadow: inset 1px 1px 1px #333    
  &:focus
    outline: none

.buttons-container
  display: flex
  flex-direction: column
  justify-items: center
  h2
    text-align: center
    
.buttons-wrapper
  display: grid
  justify-items: center
  width: 100%
  &.three-cols
    grid-template-columns: repeat(3,1fr)
  &.four-cols
    grid-template-columns: repeat(4,1fr)
  
              
            
!

JS

              
                class Button extends React.Component {
  static propTypes = {
    children: PropTypes.node.isRequired,
    color: PropTypes.string,
  }

  constructor(props){
    super(props)
  };
   
  render() {
    const {children,color,disable, round} = this.props
    
    const btnColorClass = (color ) ? `button--${color}` : 'button--default'
    const disabledClass = (disable) ? 'button--disabled' : ''
    const roundClass = (round) ? 'button--round' :  ''
    
    const btnClasses = `${btnColorClass} ${disabledClass} ${roundClass}`
    return (
      <button className={`button ${btnClasses}`} disabled={disable}>
        {children}
      </button>
    )
  }
}

const BtnContainer = ({title,colClass,children}) => {
  return(
    <div className='buttons-container'>
      <h2>{title}</h2>
      <div className={`buttons-wrapper  ${colClass}`}>
        {children}
      </div>
    </div>
  )
}

class App extends React.Component {

  render() {
    return (
      <div className="app">
        <BtnContainer title='Default Color Buttons' colClass='four-cols'>
          <Button>Ciao</Button>
          <Button color='primary' > Primary </Button>
          <Button color='secondary' > Secondary </Button>
          <Button color='alert' > Alert </Button>
          <Button disable>Ciao</Button>
          <Button color='primary' disable> Primary </Button>
          <Button color='secondary' disable> Secondary </Button>
          <Button color='alert' disable> Alert </Button>
        </BtnContainer>
        
        <BtnContainer title='Round Buttons' colClass='three-cols'>
          <Button color='primary' round > + </Button>
          <Button color='secondary' round > = </Button>
          <Button color='alert' round > - </Button>
          <Button color='primary' round disable> + </Button>
          <Button color='secondary' round disable> = </Button>
          <Button color='alert' round disable> - </Button>
        </BtnContainer>
        
        
      </div>
    )
  }
}

ReactDOM.render(<App/>,document.getElementById('app'))
              
            
!
999px

Console