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

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


  <rad-input name="radInput" required>First name</rad-input>
  <label for="basic">Basic input</label>
  <input value="foo" name="basic" id="basic">
  <button type="submit">Submit</button>


                :root {
  --primary-color: hsl(250, 100%, 25%);
  --text-color: #141414;
  --text-color-inverted: #ffffff;

pre {
  background: var(--primary-color);
  color: var(--text-color-inverted);
  font-family: "Operator Mono", "Fira Code", monospace;
  padding: 16px;


                import { LitElement, html, css } from '';
import '';

class RadInput extends LitElement {
  static get formAssociated() {
    return true;
  static get properties() {
    return {
      name: { type: String, reflect: true },
      required: { type: Boolean, reflect: true },
      value: { type: String }
  static get styles() {
    return css`
    :host {
      display: block;
      font-family: system-ui;;
      margin: 0 0 16px;
    label {
      color: #141414;
      display: block;
      font-size: 14px;
      margin-bottom: 8px;
    input {
      border: 1px solid hsl(250, 100%, 25%);
      border-radius: 8px;
      color: #141414;
      font-size: 16px;
      padding: 8px;
  constructor() {
    this.internals = this.attachInternals(); = name;
    this.required = false;
    this.value = '';
    /** Placeholder for required */
    this._required = false;
  render() {
    return html`
      <label for="input"><slot></slot></label>
      <input type="${this.type}" name="${}" id="input" .value="${this.value}" ?required="${this.required}" @input="${this._onInput}" novalidate>
  _onInput(event) {
    this.value =;
  _manageRequired() {
    const { value } = this;
    const input = this.shadowRoot.querySelector('input');
    console.log({ value, required: this.required })
    if (value === '' && this.required) {
        valueMissing: true
      }, 'This field is required', input);
    } else {
  /** LitElement lifecycle method */
  firstUpdated(...args) {
    /** This ensures our element always participates in the form */
    /** Make sure validations are set up */
  get required() {
    return this._required;
  set required(isRequired) {
    this._required = isRequired;
    this.internals.ariaRequired = isRequired;

customElements.define('rad-input', RadInput);

/** Get a reference to the form */
const form = document.querySelector('form');

/** Get the output element to display form data in */
const output = document.querySelector('output');

/** Prevent default on form submissions */
form.addEventListener('submit', event => {
  const form =;
  console.log('Rad input:', form.radInput);

  /** Get all of the form data */
  const formData = new FormData(form);
  const data = {};
  formData.forEach((value, key) => data[key] = value);
  output.innerHTML = JSON.stringify(data, null, 2);
  console.log('rad value: ', document.querySelector('[name="radInput"]').value);