Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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.

HTML

              
                <h2>Resize your browser window and see Shiitake in action</h2>
<div id="react-root"></div>
              
            
!

CSS

              
                #react-root {
  max-width: 700px;
  margin: 0 auto;
}

.side-by-side {
  width: 100%;
  font-size: 36px;
  line-height: 1em;
  display: flex;
  margin-bottom: 50px;
}

.side-by-side > div {
  width: 50%;
  border: 1px solid black;
  padding: 5px;
  box-sizing: border-box;
}

.shiitake-inline-wrapper {
  width: 50%;
  margin-bottom: 50px;
  font-size: 36px;
  display: flex;
}

.shiitake-paragraph {
  margin: 0 0 50px;
  width: 25%;
}

.line-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.show-hide-example {
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
}

.show-hide-content {
  position: absolute;
  /* using negative top like this preserves with width so the spacers can compute accurately */
  top: -20000px;
  box-sizing: inherit;
}

.show-hide-example:hover .show-hide-content {
  position: relative;
  top: 0;
}

.example-label {
  color: #26539b;
}

              
            
!

JS

              
                // due to this: https://github.com/webpack/webpack/issues/3929
Shiitake = Shiitake.default;

const ipsum = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent pretium tincidunt viverra. Pellentesque
auctor leo sit amet eros fringilla placerat. Proin et velit nec nulla laoreet sagittis. Nullam finibus lorem
cursus, convallis diam nec, laoreet libero. In venenatis, risus sit amet lobortis commodo, dui nulla feugiat
libero, sed pharetra enim mauris id turpis.`;

const ipsum2 = `Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
printer took a galley of type and scrambled it to make a type specimen book. It has survived not only
five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was
popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.`;

class App extends React.Component {
  constructor() {
    super();

    this.state = { ipsum, dynamicLines: 2, truncatedText: false };

    this.click = this.click.bind(this);
    this.toggleDynamicLines = this.toggleDynamicLines.bind(this);
    this.toggleTruncatedText = this.toggleTruncatedText.bind(this);
  }

  click() {
    this.setState({ ipsum: ipsum2 });
  }

  toggleDynamicLines() {
    this.setState({ dynamicLines: (this.state.dynamicLines === 2) ? 1 : 2 });
  }
  
  toggleTruncatedText(isTruncated) {
    this.setState({ truncatedText: isTruncated });
  }

  render() {
    const { truncatedText } = this.state;
    const text = 'Cook it up all night with Shitakes';

    // used to verify that passing undefined is safe
    let nullText;

    return (
      <div className="wrapper">

        <h2>Compare with webkit line-clamp</h2>
        <div className="side-by-side">
          <Shiitake lines={2} throttleRate={200} className="shiitake">
            {text}
          </Shiitake>
          <div className="line-clamp">
            {text}
          </div>
        </div>

        <h2>Create inline style with flexbox:</h2>
        <div className="shiitake-inline-wrapper">
          <Shiitake lines={1} throttleRate={200} className="shiitake-inline">
            {text}
          </Shiitake>
          &gt;
        </div>

        <h2>Specify your own tag name:</h2>
        <Shiitake tagName="p" lines={1} throttleRate={200} className="shiitake-paragraph" onClick={this.click}>
          {this.state.ipsum}
        </Shiitake>

        <h2>Can handle undefined children</h2>
        <Shiitake lines={1}>
          {nullText}
        </Shiitake>

        <h2>Example of showing/hiding</h2>
        <div className="show-hide-example">
          <h4>Hover here</h4>
          <div className="show-hide-content">
            <Shiitake lines={2}>
              {ipsum}
            </Shiitake>
          </div>
        </div>
        
        <h2>Custom overflow node</h2>
        <div>
          <Shiitake
            lines={2}
            overflowNode={<a href="https://github.com/bsidelinger912/shiitake#readme" target="_blank" rel="noopener noreferrer"> ...read more</a>}
          >
            {ipsum}
          </Shiitake>
        </div>
        
        <h2>Detect if text is truncated</h2>
        <div>
          <Shiitake
            lines={4}
            onTruncationChange={this.toggleTruncatedText}
          >
            {ipsum}
          </Shiitake>
          <p className="example-label">
            {truncatedText ? 'this text is truncated ^^' : 'this text is not truncated ^^'}
          </p>
        </div>
        
        <h2>Truncate the contents of an anchor tag</h2>
        <div>
          <Shiitake lines={2} tagName="a" attributes={{ href: 'https://github.com/bsidelinger912/shiitake#readme' }}>
            {ipsum}
          </Shiitake>
        </div>
        
        <p className="read-more">
          read more <a href="https://github.com/bsidelinger912/shiitake#readme">here</a>.
        </p>
      </div>
    );
  }
}

ReactDOM.render(<App />, document.getElementById('react-root'));
              
            
!
999px

Console