HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs 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 its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<!--
Include Tailwind JIT CDN compiler
More info: https://beyondco.de/blog/tailwind-jit-compiler-via-cdn
-->
<script src="https://unpkg.com/tailwindcss-jit-cdn"></script>
<!-- Specify a custom Tailwind configuration -->
<script type="tailwind-config">
{
theme: {
extend: {
colors: {
blue: colors.sky,
}
}
}
}
</script>
<!-- Custom style for toggle -->
<style type="postcss">
#toggle:checked + label > span:first-child {
@apply left-[22px];
}
</style>
<!-- Snippet -->
<section class="flex flex-col justify-center antialiased bg-gray-100 text-gray-600 min-h-screen p-4">
<div class="h-full">
<!-- Pricing -->
<div class="max-w-5xl mx-auto" x-data="{ annual: true }">
<h2 class="text-3xl text-gray-800 font-bold text-center mb-4">Plans</h2>
<!-- Toggle switch -->
<div class="flex justify-center">
<div class="flex items-center space-x-3 mb-8">
<div class="text-sm text-gray-500 font-medium min-w-[120px] text-right">Monthly</div>
<div class="relative select-none w-[44px]">
<input type="checkbox" id="toggle" class="peer sr-only" x-model="annual" />
<label class="block overflow-hidden cursor-pointer h-6 rounded-full bg-gray-400 peer-checked:bg-indigo-500" for="toggle">
<span class="absolute block rounded-full w-5 h-5 top-0.5 left-0.5 right-1/2 bg-white shadow-sm transition-all duration-150 ease-out" aria-hidden="true"></span>
<span class="sr-only">Pay annually</span>
</label>
</div>
<div class="text-sm text-gray-500 font-medium min-w-[120px]">Annually <span class="text-green-500">(-20%)</span></div>
</div>
</div>
<!-- Pricing tabs -->
<div class="grid grid-cols-12 gap-6">
<!-- Tab 1 -->
<div class="relative col-span-full md:col-span-4 bg-white shadow-md rounded-sm border border-gray-200">
<div class="absolute top-0 left-0 right-0 h-0.5 bg-green-500" aria-hidden="true"></div>
<div class="px-5 pt-5 pb-6 border-b border-gray-200">
<header class="flex items-center mb-2">
<div class="w-6 h-6 rounded-full flex-shrink-0 bg-gradient-to-tr from-green-500 to-green-300 mr-3">
<svg class="w-6 h-6 fill-current text-white" viewBox="0 0 24 24">
<path d="M12 17a.833.833 0 01-.833-.833 3.333 3.333 0 00-3.334-3.334.833.833 0 110-1.666 3.333 3.333 0 003.334-3.334.833.833 0 111.666 0 3.333 3.333 0 003.334 3.334.833.833 0 110 1.666 3.333 3.333 0 00-3.334 3.334c0 .46-.373.833-.833.833z" />
</svg>
</div>
<h3 class="text-lg text-gray-800 font-semibold">Basic</h3>
</header>
<div class="text-sm mb-2">Ideal for individuals that need a custom solution with custom tools.</div>
<!-- Price -->
<div class="text-gray-800 font-bold mb-4">
<span class="text-2xl">$</span><span class="text-3xl" x-text="annual ? '14' : '19'">14</span><span class="text-gray-500 font-medium text-sm">/mo</span>
</div>
<!-- CTA -->
<button class="font-medium text-sm inline-flex items-center justify-center px-3 py-2 border border-gray-200 rounded leading-5 shadow-sm transition duration-150 ease-in-out focus:outline-none focus-visible:ring-2 hover:border-gray-300 text-gray-600 w-full">Downgrade</button>
</div>
<div class="px-5 pt-4 pb-5">
<div class="text-xs text-gray-800 font-semibold uppercase mb-4">What's included</div>
<!-- List -->
<ul>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Lorem ipsum dolor sit amet</div>
</li>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Quis nostrud exercitation</div>
</li>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Lorem ipsum dolor sit amet</div>
</li>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Quis nostrud exercitation</div>
</li>
</ul>
</div>
</div>
<!-- Tab 2 -->
<div class="relative col-span-full md:col-span-4 bg-white shadow-md rounded-sm border border-gray-200">
<div class="absolute top-0 left-0 right-0 h-0.5 bg-blue-500" aria-hidden="true"></div>
<div class="px-5 pt-5 pb-6 border-b border-gray-200">
<header class="flex items-center mb-2">
<div class="w-6 h-6 rounded-full flex-shrink-0 bg-gradient-to-tr from-blue-500 to-blue-300 mr-3">
<svg class="w-6 h-6 fill-current text-white" viewBox="0 0 24 24">
<path d="M12 17a.833.833 0 01-.833-.833 3.333 3.333 0 00-3.334-3.334.833.833 0 110-1.666 3.333 3.333 0 003.334-3.334.833.833 0 111.666 0 3.333 3.333 0 003.334 3.334.833.833 0 110 1.666 3.333 3.333 0 00-3.334 3.334c0 .46-.373.833-.833.833z" />
</svg>
</div>
<h3 class="text-lg text-gray-800 font-semibold">Standard</h3>
</header>
<div class="text-sm mb-2">Ideal for individuals that need a custom solution with custom tools.</div>
<!-- Price -->
<div class="text-gray-800 font-bold mb-4">
<span class="text-2xl">$</span><span class="text-3xl" x-text="annual ? '34' : '39'">34</span><span class="text-gray-500 font-medium text-sm">/mo</span>
</div>
<!-- CTA -->
<button class="font-medium text-sm inline-flex items-center justify-center px-3 py-2 border border-transparent rounded leading-5 shadow-sm transition duration-150 ease-in-out border-gray-200 focus:outline-none focus-visible:ring-2 bg-gray-100 text-gray-400 w-full cursor-not-allowed flex items-center" disabled>
<svg class="w-3 h-3 flex-shrink-0 fill-current mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<span>Current Plan</span>
</button>
</div>
<div class="px-5 pt-4 pb-5">
<div class="text-xs text-gray-800 font-semibold uppercase mb-4">What's included</div>
<!-- List -->
<ul>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Lorem ipsum dolor sit amet</div>
</li>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Quis nostrud exercitation</div>
</li>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Lorem ipsum dolor sit amet</div>
</li>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Quis nostrud exercitation</div>
</li>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Lorem ipsum dolor sit amet</div>
</li>
</ul>
</div>
</div>
<!-- Tab 3 -->
<div class="relative col-span-full md:col-span-4 bg-white shadow-md rounded-sm border border-gray-200">
<div class="absolute top-0 left-0 right-0 h-0.5 bg-indigo-500" aria-hidden="true"></div>
<div class="px-5 pt-5 pb-6 border-b border-gray-200">
<header class="flex items-center mb-2">
<div class="w-6 h-6 rounded-full flex-shrink-0 bg-gradient-to-tr from-indigo-500 to-indigo-300 mr-3">
<svg class="w-6 h-6 fill-current text-white" viewBox="0 0 24 24">
<path d="M12 17a.833.833 0 01-.833-.833 3.333 3.333 0 00-3.334-3.334.833.833 0 110-1.666 3.333 3.333 0 003.334-3.334.833.833 0 111.666 0 3.333 3.333 0 003.334 3.334.833.833 0 110 1.666 3.333 3.333 0 00-3.334 3.334c0 .46-.373.833-.833.833z" />
</svg>
</div>
<h3 class="text-lg text-gray-800 font-semibold">Plus</h3>
</header>
<div class="text-sm mb-2">Ideal for individuals that need a custom solution with custom tools.</div>
<!-- Price -->
<div class="text-gray-800 font-bold mb-4">
<span class="text-2xl">$</span><span class="text-3xl" x-text="annual ? '74' : '79'">74</span><span class="text-gray-500 font-medium text-sm">/mo</span>
</div>
<!-- CTA -->
<button class="font-medium text-sm inline-flex items-center justify-center px-3 py-2 border border-transparent rounded leading-5 shadow-sm transition duration-150 ease-in-out bg-indigo-500 focus:outline-none focus-visible:ring-2 hover:bg-indigo-600 text-white w-full">Upgrade</button>
</div>
<div class="px-5 pt-4 pb-5">
<div class="text-xs text-gray-800 font-semibold uppercase mb-4">What's included</div>
<!-- List -->
<ul>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Lorem ipsum dolor sit amet</div>
</li>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Quis nostrud exercitation</div>
</li>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Lorem ipsum dolor sit amet</div>
</li>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Quis nostrud exercitation</div>
</li>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Lorem ipsum dolor sit amet</div>
</li>
<li class="flex items-center py-1">
<svg class="w-3 h-3 flex-shrink-0 fill-current text-green-500 mr-2" viewBox="0 0 12 12">
<path d="M10.28 1.28L3.989 7.575 1.695 5.28A1 1 0 00.28 6.695l3 3a1 1 0 001.414 0l7-7A1 1 0 0010.28 1.28z" />
</svg>
<div class="text-sm">Quis nostrud exercitation</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- More components -->
<div x-show="open" class="fixed bottom-0 right-0 w-full md:bottom-8 md:right-12 md:w-auto z-60" x-data="{ open: true }">
<div class="bg-gray-800 text-gray-50 text-sm p-3 md:rounded shadow-lg flex justify-between">
<div>👉 <a class="hover:underline ml-1" href="https://cruip.com/mosaic/?ref=codepen-cruip-pricing-tab" target="_blank">More components on Cruip.com</a></div>
<button class="text-gray-500 hover:text-gray-400 ml-5" @click="open = false">
<span class="sr-only">Close</span>
<svg class="w-4 h-4 flex-shrink-0 fill-current" viewBox="0 0 16 16">
<path d="M12.72 3.293a1 1 0 00-1.415 0L8.012 6.586 4.72 3.293a1 1 0 00-1.414 1.414L6.598 8l-3.293 3.293a1 1 0 101.414 1.414l3.293-3.293 3.293 3.293a1 1 0 001.414-1.414L9.426 8l3.293-3.293a1 1 0 000-1.414z" />
</svg>
</button>
</div>
</div>
section {
font-family: 'Inter', sans-serif;
}
Also see: Tab Triggers