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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <circle-text r="3em" rotate="-90deg">
  CSS is super fun & cool & I like CSS!!!
<circle-text r="70">
  Our Tricks Are Treats Because CSS Is Sweet!
<circle-text style="color: hotPink; text-shadow: lightYellow 1px 1px 2px;">
  CSS in JS in CSS in JS in CSS in JS in CSS in JS in CSS in JS in CSS in JS

<script> // for the demo only
  window.addEventListener("load", testScriptedCreation);
  function testScriptedCreation() {    
    let ct = document.createElement("circle-text");
    ct.textContent = "123456789";
    window.setTimeout(()=>{ct.textContent="updated live from script"}, 1000);
    window.setTimeout(()=>{ct.setAttribute("r", "3em")}, 2000);
    window.setTimeout(()=>{ct.setAttribute("rotate", "0.5turn")}, 3000);
              /* to hide the content when custom elements aren't supported */
circle-text {
  display: none;
circle-text:defined {
  display: inline-block;

/* styles for this demo */
circle-text {
  /* customize the color and font as normal with CSS */
  color: skyBlue;
  text-transform: uppercase;
  font: large Tahoma, sans-serif;
  vertical-align: middle;
  /* position as you wish */

body {
  background: #222;

              if (window.customElements && document.body.attachShadow) { //mustard
class CircleText extends HTMLElement {
  static get observedAttributes() {
    return ['r', 'rotate'];
  static defaultRadius = 100;
  constructor() {
    let shadow = this.attachShadow({mode: 'open'});
    shadow.innerHTML = `
<svg id="s">
    svg { display: block; overflow: visible; padding: 1em; }
    textPath { fill: currentColor; }
  <defs><path id="p"/><circle id="r"/></defs>
  <text id="t"><textPath id="tp" xlink:href="#p"></textPath></text>
    // save links to the elements we'll need to modify
    this.svg = shadow.getElementById("s");
    this.path = shadow.getElementById("p");
    this.text = shadow.getElementById("t");
    this.textPath = shadow.getElementById("tp");
    // SVGLength object on a circle for unit conversion for path data
    // (since Safari and Firefox don't support text on a <circle> element)
    this.radius = shadow.getElementById("r").r.baseVal;
    // create a mutation observer for text content updates
    let watchText = new MutationObserver(this.updateText.bind(this));
    watchText.observe(this, {childList: true, characterData: true});
  connectedCallback() {
    // re-calculate dimensions, in case of font-relative units
  attributeChangedCallback(name, oldValue, newValue) {
    switch (name) {
      case "r":
        if (this.svg.isConnected) this.updateRadius(newValue);
      case "rotate":
  updateRadius(newValue) {
    var r;
    if (this.svg.isConnected) {
      //force an initial style calc to get em values
      let f = getComputedStyle(this.svg)["font-size"];
    try {
      this.radius.valueAsString = newValue;
      r = this.radius.value;
    } catch(e) {
      r = CircleText.defaultRadius;
    let d = 2*r;
    let offset = -1*r;
      {name: "height", value:d },
      {name: "width", value:d },
      {name: "viewBox", value: [offset, offset, d, d].join() }
      ({name, value})=>this.svg.setAttribute(name, value)
      `M${-r},0 A${r},${r},0 1 1 ${r},0 A${r},${r},0 1 1 ${-r},0Z`
  updateTransform(rotate) {
    if (rotate) {
      this.text.style["transform"] = `rotate(${rotate})`;
    } else {
      this.text.style["transform"] = "none";
  updateText() {
    this.textPath.textContent = this.textContent.trim();
}//end class
customElements.define("circle-text", CircleText, {});

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.