Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


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


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.


Save Automatically?

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.


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


                html, body, #app {
  height: 100%;

.container {
  background: #009999;
  min-height: 100%;
  text-align: center;
  padding: 30px;
  h1 {
    margin: 0;
    color: white;
    padding: 30px;

.article {
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  padding: 30px;
  background: white;
  margin-top: 30px;
  box-shadow: 0 2px 4px 0 rgba(black, .5);
  text-align: left;
  line-height: 1.2;
  box-sizing: border-box;

// dropdown css starts

.dropdown-container {
  width: 200px;
  margin: 0 auto;
  .dropdown-btn {
    width: 100%;
    border-radius: 3px;
    background: #eee;
    border: none;
    text-align: left;
    padding: 10px 15px;
    outline: none;
    &:focus {
      background: #e6e6e6;

  .arrow {
    position: relative;

    &::after {
      content: '';
      width: 0;
      height: 0;
      border-style: solid;
      border-width: 10px 5px 0 5px;
      border-color: black transparent transparent transparent;
      position: absolute;
      right: 10px;
      top: 7px;

  .dropdown-list {
    list-style-type: none;
    position: absolute;
    margin: 0;
    padding: 0;
    width: 200px;
    height: 200px;
    border: none;
    background: white;
    box-shadow: 0 2px 4px 0 rgba(black, .5);
    z-index: 9;
    overflow: auto;
    border-radius: 3px;
    .option {
      padding: 5px;
      cursor: pointer;
      &:hover {
        color: white;
        background: #47d1d1;



                const fonts = ['Arial', 'Helvetica', 'Times', 'Palatino', 'Times New Roman', 'Arial Black', 'Gadget', 'Comic Sans MS', 'cursive', 'Impact', 'Charcoal', 'Tahoma', 'Geneva', 'Verdana'];
let timer;

class Dropdown extends React.Component {
  render () {
    const {
    } = this.props;
    return (
      <div className="dropdown-container">
        <label className="arrow">
            style={{ fontFamily: value }}
        <ul className="dropdown-list" hidden={!show} ref={getListRef}>
          { => (
              style={{ fontFamily: font }}

class Application extends React.Component {  
  constructor (props) {
    this.state = {
      value: 'Arial',
      show: false,
  handleChange = (font) => () => {
    this.setState({ value: font, show: false });
  handleToggle = () => {
    this.setState({ show: ! });
  handleBlur = (e) => {
    if ( && !(this.input.getDOMNode() === || this.list.getDOMNode() === {
      timer = setTimeout(() => {
        this.setState({ show: false });
      }, 200);
  getInputRef = (ref) => {
    this.input = ref;

  getListRef = (ref) => {
    this.list = ref;
  componentDidMount () {
    document.addEventListener('mousedown', this.handleBlur);
  render() {
    return <div className="container">
      <h1>React Dropdown (MouseClick)</h1>
      <article className="article" style={{ fontFamily: this.state.value }}>
        React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes.<br /><br />
Declarative views make your code more predictable and easier to debug.
        Build encapsulated components that manage their own state, then compose them to make complex UIs.<br /><br />
Since component logic is written in JavaScript instead of templates, you can easily pass rich data through your app and keep state out of the DOM.
        We don’t make assumptions about the rest of your technology stack, so you can develop new features in React without rewriting existing code.<br /><br />
React can also render on the server using Node and power mobile apps using React Native.
        React components implement a render() method that takes input data and returns what to display. This example uses an XML-like syntax called JSX. Input data that is passed into the component can be accessed by render() via this.props.<br /><br />
JSX is optional and not required to use React. Try the Babel REPL to see the raw JavaScript code produced by the JSX compilation step.<br /><br />
        In addition to taking input data (accessed via this.props), a component can maintain internal state data (accessed via this.state). When a component’s state data changes, the rendered markup will be updated by re-invoking render().

  componentWillUnmount () {
    document.removeEventListener('mousedown', this.handleBlur);

React.render(<Application />, document.getElementById('app'));