Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ 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

              
                <div class="flex flex-col px-6 py-8 bg-gray-100">
	
	<div class="mx-auto text-center mb-6">
		<h1 class="mb-6 font-bold text-lg">JReviews REST API Demo</h1>
		<a class="text-blue-700 font-medium" href="https://www.jreviews.com/blog/building-and-consuming-a-read-only-rest-api" target="_blank">Read the blog post</a>
	</div>
	
	<div x-data="list()" x-init="load()" class="w-full max-w-sm mx-auto">	
		<ul class="space-y-3">
			
		<!-- begin listing card template -->
		<template x-for="(entry,index) in entries" :key="index">
			<li class="border-0 bg-white shadow-md rounded-lg"> 
				<a :href="entry.href" target="_blank" rel="noopener" class="flex flex-row">
					<div class="relative h-0 p-10 rounded-l overflow-hidden">
						<img class="absolute inset-0 h-full object-cover" :src="entry.thumbnail" >
					</div>
					<div class="p-3 overflow-hidden">
						<p :href="entry.href" class="truncate font-medium text-gray-900" x-text="entry.title"></p>
					</div>
				</a>
			</li>
		</template>
		<!-- end listing card template -->
		</ul>
		
		<!-- begin pagination -->
		<div class="flex mt-6 items-center justify-center">
			
			<!-- loading state -->
			<div x-show="state == 'loading'">
				<svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-gray-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
					<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
					<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
				</svg>
			</div>
			
			<div x-show="state == 'ready'">
				
				<!-- previous button -->
				<span class="inline-flex rounded-md shadow-sm">
					<button type="button" class="inline-flex items-center px-3 py-2 border border-gray-300 text-xs leading-4 font-medium rounded bg-white hover:text-gray-500 focus:outline-none focus:border-blue-300 focus:shadow-outline-blue active:text-gray-800 active:bg-gray-50 transition ease-in-out duration-150"
					:class="{ 'text-gray-300': !links.previous, 'text-gray-700': links.previous }"
					:disabled="!links.previous" 
					@click="load(links.previous)"
					>
						Previous
					</button>			
				</span>

				<!-- next button -->
				<span class="inline-flex rounded-md shadow-sm">
					<button type="button" class="inline-flex items-center px-3 py-2 border border-gray-300 text-xs leading-4 font-medium rounded bg-white hover:text-gray-500 focus:outline-none focus:border-blue-300 focus:shadow-outline-blue active:text-gray-800 active:bg-gray-50 transition ease-in-out duration-150"
					:class="{ 'text-gray-300': !links.next, 'text-gray-700': links.next }"
					:disabled="!links.next" 
					@click="load(links.next)"
					>
						Next
					</button>			
				</span>
			</div>
		</div>
	</div>
</div>

<script>
function list() {
	return {
		api_url: 'https://demo.jreviews.com/classifieds/real-estate?format=json&limit=5',
		entries: [], 
		links: {}, 
		state: 'loading',
		load: async function(url) { 
			if (! url) {
				url = this.api_url
			}
			this.state = 'loading'
			const response = await fetch(url)
			const data = await response.json()
			this.state = 'ready'
			this.entries = data.items
			this.links = data.pagination.links																	 
		}
	}
}
</script>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console