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.
<div class="w-full h-screen flex flex-col">
<div class="w-full h-12 bg-gray-300 flex flex-shrink-0 p-5">Nav</div>
<div class="flex flex-col w-32 flex-1 bg-gray-100">
<div class="w-full flex items-center justify-center h-12 bg-gray-100">
top
</div>
<div class="w-full flex-1 bg-gray-400"></div>
<div class="w-full flex items-center justify-center h-12 bg-gray-100">
bottom
</div>
</div>
</div>
<template>
<div class="min-h-screen bg-gray-100">
<nav class="bg-white border-b border-gray-100">
<!-- Primary Navigation Menu -->
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex">
<!-- Logo -->
<div class="flex-shrink-0 flex items-center">
<a href="/dashboard">
<jet-application-mark class="block h-9 w-auto" />
</a>
</div>
<!-- Navigation Links -->
<div class="hidden space-x-8 sm:-my-px sm:ml-10 sm:flex">
<jet-nav-link href="/dashboard" :active="$page.currentRouteName == 'dashboard'">
Dashboard
</jet-nav-link>
</div>
</div>
<!-- Settings Dropdown -->
<div class="hidden sm:flex sm:items-center sm:ml-6">
<div class="ml-3 relative">
<jet-dropdown align="right" width="48">
<template #trigger>
<button class="flex text-sm border-2 border-transparent rounded-full focus:outline-none focus:border-gray-300 transition duration-150 ease-in-out">
<img class="h-8 w-8 rounded-full object-cover" :src="$page.user.profile_photo_url" :alt="$page.user.name" />
</button>
</template>
<template #content>
<!-- Account Management -->
<div class="block px-4 py-2 text-xs text-gray-400">
Manage Account
</div>
<jet-dropdown-link href="/user/profile">
Profile
</jet-dropdown-link>
<jet-dropdown-link href="/user/api-tokens" v-if="$page.jetstream.hasApiFeatures">
API Tokens
</jet-dropdown-link>
<div class="border-t border-gray-100"></div>
<!-- Team Management -->
<template v-if="$page.jetstream.hasTeamFeatures">
<div class="block px-4 py-2 text-xs text-gray-400">
Manage Team
</div>
<!-- Team Settings -->
<jet-dropdown-link :href="'/teams/' + $page.user.current_team.id">
Team Settings
</jet-dropdown-link>
<jet-dropdown-link href="/teams/create" v-if="$page.jetstream.canCreateTeams">
Create New Team
</jet-dropdown-link>
<div class="border-t border-gray-100"></div>
<!-- Team Switcher -->
<div class="block px-4 py-2 text-xs text-gray-400">
Switch Teams
</div>
<template v-for="team in $page.user.all_teams">
<form @submit.prevent="switchToTeam(team)">
<jet-dropdown-link as="button">
<div class="flex items-center">
<svg v-if="team.id == $page.user.current_team_id" class="mr-2 h-5 w-5 text-green-400" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke="currentColor" viewBox="0 0 24 24"><path d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<div>{{ team.name }}</div>
</div>
</jet-dropdown-link>
</form>
</template>
<div class="border-t border-gray-100"></div>
</template>
<!-- Authentication -->
<form @submit.prevent="logout">
<jet-dropdown-link as="button">
Logout
</jet-dropdown-link>
</form>
</template>
</jet-dropdown>
</div>
</div>
<!-- Hamburger -->
<div class="-mr-2 flex items-center sm:hidden">
<button @click="showingNavigationDropdown = ! showingNavigationDropdown" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 focus:text-gray-500 transition duration-150 ease-in-out">
<svg class="h-6 w-6" stroke="currentColor" fill="none" viewBox="0 0 24 24">
<path :class="{'hidden': showingNavigationDropdown, 'inline-flex': ! showingNavigationDropdown }" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
<path :class="{'hidden': ! showingNavigationDropdown, 'inline-flex': showingNavigationDropdown }" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
</div>
</div>
<!-- Responsive Navigation Menu -->
<div :class="{'block': showingNavigationDropdown, 'hidden': ! showingNavigationDropdown}" class="sm:hidden">
<div class="pt-2 pb-3 space-y-1">
<jet-responsive-nav-link href="/dashboard" :active="$page.currentRouteName == 'dashboard'">
Dashboard
</jet-responsive-nav-link>
</div>
<!-- Responsive Settings Options -->
<div class="pt-4 pb-1 border-t border-gray-200">
<div class="flex items-center px-4">
<div class="flex-shrink-0">
<img class="h-10 w-10 rounded-full" :src="$page.user.profile_photo_url" :alt="$page.user.name" />
</div>
<div class="ml-3">
<div class="font-medium text-base text-gray-800">{{ $page.user.name }}</div>
<div class="font-medium text-sm text-gray-500">{{ $page.user.email }}</div>
</div>
</div>
<div class="mt-3 space-y-1">
<jet-responsive-nav-link href="/user/profile" :active="$page.currentRouteName == 'profile.show'">
Profile
</jet-responsive-nav-link>
<jet-responsive-nav-link href="/user/api-tokens" :active="$page.currentRouteName == 'api-tokens.index'" v-if="$page.jetstream.hasApiFeatures">
API Tokens
</jet-responsive-nav-link>
<!-- Authentication -->
<form method="POST" @submit.prevent="logout">
<jet-responsive-nav-link as="button">
Logout
</jet-responsive-nav-link>
</form>
<!-- Team Management -->
<template v-if="$page.jetstream.hasTeamFeatures">
<div class="border-t border-gray-200"></div>
<div class="block px-4 py-2 text-xs text-gray-400">
Manage Team
</div>
<!-- Team Settings -->
<jet-responsive-nav-link :href="'/teams/' + $page.user.current_team.id" :active="$page.currentRouteName == 'teams.show'">
Team Settings
</jet-responsive-nav-link>
<jet-responsive-nav-link href="/teams/create" :active="$page.currentRouteName == 'teams.create'">
Create New Team
</jet-responsive-nav-link>
<div class="border-t border-gray-200"></div>
<!-- Team Switcher -->
<div class="block px-4 py-2 text-xs text-gray-400">
Switch Teams
</div>
<template v-for="team in $page.user.all_teams">
<form @submit.prevent="switchToTeam(team)">
<jet-responsive-nav-link as="button">
<div class="flex items-center">
<svg v-if="team.id == $page.user.current_team_id" class="mr-2 h-5 w-5 text-green-400" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke="currentColor" viewBox="0 0 24 24"><path d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<div>{{ team.name }}</div>
</div>
</jet-responsive-nav-link>
</form>
</template>
</template>
</div>
</div>
</div>
</nav>
<!-- Page Heading -->
<header class="bg-white shadow">
<div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
<slot name="header"></slot>
</div>
</header>
<!-- Page Content -->
<main>
<slot></slot>
</main>
<!-- Modal Portal -->
<portal-target name="modal" multiple>
</portal-target>
</div>
</template>
<script>
import JetApplicationLogo from './../Jetstream/ApplicationLogo'
import JetApplicationMark from './../Jetstream/ApplicationMark'
import JetDropdown from './../Jetstream/Dropdown'
import JetDropdownLink from './../Jetstream/DropdownLink'
import JetNavLink from './../Jetstream/NavLink'
import JetResponsiveNavLink from './../Jetstream/ResponsiveNavLink'
export default {
components: {
JetApplicationLogo,
JetApplicationMark,
JetDropdown,
JetDropdownLink,
JetNavLink,
JetResponsiveNavLink,
},
data() {
return {
showingNavigationDropdown: false,
}
},
methods: {
switchToTeam(team) {
this.$inertia.put('/current-team', {
'team_id': team.id
}, {
preserveState: false
})
},
logout() {
axios.post('/logout').then(response => {
window.location = '/';
})
},
},
computed: {
path() {
return window.location.pathname
}
}
}
</script>
Also see: Tab Triggers