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. 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

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

              
                #root
              
            
!

CSS

              
                body
	background-color: turquoise

#root
	display: flex
	position: relative
	justify-content: center
	align-items: center
	width: 100%
	height: 100vh

.textarea
	box-sizing: border-box
	border: none
	border-radius: 3px
	resize: none
	font-size: 20px
	line-height: 24px
	overflow: auto
	height: auto
	padding: 8px
	box-shadow: 0px 4px 10px -8px black
	
	&::placeholder
		color: gainsboro
	
	&:focus
		outline: none
              
            
!

JS

              
                class ResizableTextarea extends React.PureComponent {
	constructor(props) {
		super(props);
		this.state = {
			value: '',
			rows: 5,
			minRows: 5,
			maxRows: 10,
		};
	}
	
	handleChange = (event) => {
		const textareaLineHeight = 24;
		const { minRows, maxRows } = this.state;
		
		const previousRows = event.target.rows;
  	event.target.rows = minRows; // reset number of rows in textarea 
		
		const currentRows = ~~(event.target.scrollHeight / textareaLineHeight);
    
    if (currentRows === previousRows) {
    	event.target.rows = currentRows;
    }
		
		if (currentRows >= maxRows) {
			event.target.rows = maxRows;
			event.target.scrollTop = event.target.scrollHeight;
		}
    
  	this.setState({
    	value: event.target.value,
      rows: currentRows < maxRows ? currentRows : maxRows,
    });
	};
	
	render() {
		return (
			<textarea
				rows={this.state.rows}
				value={this.state.value}
				placeholder={'Enter your text here...'}
				className={'textarea'}
				onChange={this.handleChange}
			/>
		);
	}
}

ReactDOM.render(
	<ResizableTextarea/>,
	document.querySelector('#root')
);
              
            
!
999px

Console