Pen Settings



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


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.


                <!DOCTYPE html>
<html lang="en" >
  <meta charset="UTF-8">
  <title>CodePen - alpine js-Photo Gallery</title>

<!-- partial:index.partial.html -->
<!DOCTYPE html>
<html dir="rtl" lang="en">

  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <script defer src="[email protected]/dist/cdn.min.js"></script>
  <script src=""></script>


<body x-data="images()" x-init="fetch('')
.then(response => response.json())
.then(response => { images = response.hits })">
  <header class="absolute top-0 left-0 right-0 h-16 w-full">
    <nav class="container mx-auto flex items-center justify-between px-12 py-4 lg:px-36">
      <a class="w-24 lg:w-full" href="">
        <img src="" alt="" />

      <!-- hamberger -->
      <button class="lg:hidden">
        <svg xmlns="" class="h-8 w-8 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
          <path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16" />
    <!-- hero start -->
    <section class="bg-[url('')] bg-cover bg-center pt-40 pb-28">
      <div class="container mx-auto px-16 lg:px-36">
        <div class="flex flex-col items-center justify-center space-y-3">
          <h1 class="text-2xl font-semibold text-white/80">جستجوی عکس</h1>
          <h2 class="text-xl font-normal text-white/70">می توانید عکس های با کیفیت را اینجا پیدا کنید</h2>
          <!-- search box -->
          <div x-model="q" dir="rtl" class="flex w-full items-stretch justify-center rounded lg:flex-wrap">
            <input class="flex-1 border-2 py-2 px-2 outline-none focus:border-sky-600" type="text" placeholder="جستجوی تصاویر" />
            <select x-model="image_type" class="ouline-none flex-1 border border-white py-2 text-gray-600 focus:border-sky-600" name="" id="" aria-placeholder="">
              <option selected>نوع تصویر را انتخاب کنید</option>
              <option value="all">همه</option>
              <option value="photo">عکس</option>
              <option value="illustration">تصاویر</option>
              <option value="vector">وکتور</option>
            <div class="flex items-center rounded-l bg-sky-600 px-4 text-center text-white">
              <button @click="getImages()" class="inline-block align-text-top">جستجو</button>
    <!-- hero end -->
    <!-- content start -->
    <section class=" grid grid-cols-5 gap-4 mt-4">
      <template x-for="image in images" :key="">
        <div class=" border rounded shadow">
          <img class="h-auto  " :src="image.webformatURL" alt="image.tags[0]" />
    <!-- content end -->
    function images() {
      return {
        images: [],
        q: "",
        image_type: "",
        getImages: async function() {
          console.log("params", this.q, this.image_type);
          const response = await fetch(
          const data = await response.json();
          this.images = data.hits;

<!-- partial -->