<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>development &amp;mdash; Build stuff; Break stuff; Have fun!</title>
    <link>https://barfooz.xyz/tag:development</link>
    <description>barfooz.xyz</description>
    <pubDate>Mon, 01 Jun 2026 16:19:00 +0000</pubDate>
    <image>
      <url>https://i.snap.as/btoNrLSF.png</url>
      <title>development &amp;mdash; Build stuff; Break stuff; Have fun!</title>
      <link>https://barfooz.xyz/tag:development</link>
    </image>
    <item>
      <title>HTML Dialog Element with React.js and Tailwind CSS</title>
      <link>https://barfooz.xyz/html-dialog-element-with-react-js-and-tailwind-css?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Recently, I&#39;ve tried to work with the new dialiog / Element in React.js. I like how minimal the API and the React.js code is. For simple pop-ups and modals, it works great. I have some doubt when it gets more complex, for example if you add a prev or next button, but it should be realizable.&#xA;&#xA;The styling is done quite well. In basic CSS, you can target the open dialog with dialog[open] {} and the background with dialog[open]::backdrop {}. Everything else are just usual HTML Elements.&#xA;&#xA;Browser Support&#xA;&#xA;Image of Table, which shows in which desktop browsers the element is supported.&#xA;&#xA;The dialog / Element is supported in all relevant browsers.&#xA;&#xA;Image of Table, which shows in which mobile browsers the element is supported.&#xA;&#xA;Same for all relevant mobile browsers.&#xA;&#xA;Source: https://caniuse.com/mdn-htmlelementsdialog&#xA;&#xA;Example&#xA;&#xA;Here is my minimal version of the implementation for Next.js with Tailwind CSS:&#xA;&#34;use client&#34;;&#xA;&#xA;import { useRef } from &#34;react&#34;;&#xA;&#xA;import { P } from &#34;@/components/ui&#34;;&#xA;import { Image } from &#34;@/components/image&#34;;&#xA;&#xA;type Props = {&#xA;  children: string;&#xA;  image: {&#xA;    src: string;&#xA;    alt: string;&#xA;    width: number;&#xA;    height: number;&#xA;  };&#xA;};&#xA;&#xA;export function GalleryItem({ children, image }: Props): JSX.Element {&#xA;  const ref = useRefHTMLDialogElement(null);&#xA;&#xA;  function openModal() {&#xA;    ref.current?.showModal();&#xA;  }&#xA;&#xA;  function closeModal() {&#xA;    ref.current?.close();&#xA;  }&#xA;&#xA;  return (&#xA;    div&#xA;      div className=&#34;h-64 shadow shadow-black cursor-pointer overflow-hidden rounded-xl&#34;&#xA;        &lt;Image&#xA;          className=&#34;w-full h-full align-middle object-cover ease-linear duration-300 sm:hover:scale-125&#34;&#xA;          src={image.src}&#xA;          width={500}&#xA;          height={500}&#xA;          alt={image.alt}&#xA;          onClick={openModal}&#xA;        /  /div&#xA;      &lt;dialog&#xA;        ref={ref}&#xA;        onClick={closeModal}&#xA;        className=&#34;focus:outline-none focus:ring focus:ring-neutral-500 rounded-xl backdrop:bg-neutral-800 backdrop:bg-opacity-85&#34;&#xA;        &lt;Image&#xA;          className=&#34;w-full h-full&#34;&#xA;          src={image.src}&#xA;          width={image.width}&#xA;          height={image.height}&#xA;          alt={image.alt}&#xA;        /  div className=&#34;absolute bottom-0 h-1/3 w-full bg-gradient-to-t from-neutral-800 p-4 flex items-end&#34;&#xA;          P className=&#34; text-white p-0&#34;{children}/P&#xA;        /div&#xA;      /dialog&#xA;    /div&#xA;  );&#xA;}&#xA;&#xA;---&#xA;&#xA;9/100 of #100DaysToOffload&#xA;&#xA;#development #react #javascript #typescript #tailwind&#xA;&#xA;a href=&#34;https://remark.as/p/barfooz.xyz/html-dialog-element-with-react-js-and-tailwind-css&#34;Discuss.../a]]&gt;</description>
      <content:encoded><![CDATA[<p>Recently, I&#39;ve tried to work with the new <code>&lt;dialiog /&gt;</code> <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog">Element</a> in React.js. I like how minimal the API and the React.js code is. For simple pop-ups and modals, it works great. I have some doubt when it gets more complex, for example if you add a <em>prev</em> or <em>next</em> button, but it should be realizable.</p>

<p>The styling is done quite well. In basic CSS, you can target the open dialog with <code>dialog[open] {}</code> and the background with <code>dialog[open]::backdrop {}</code>. Everything else are just usual HTML Elements.</p>

<h2 id="browser-support" id="browser-support">Browser Support</h2>

<p><img src="https://i.snap.as/ChLK9YCa.jpg" alt="Image of Table, which shows in which desktop browsers the element is supported."/></p>

<p>The <code>&lt;dialog /&gt;</code> Element is supported in all relevant browsers.</p>

<p><img src="https://i.snap.as/0h66l6Qq.jpg" alt="Image of Table, which shows in which mobile browsers the element is supported."/></p>

<p>Same for all relevant mobile browsers.</p>

<p>Source: <a href="https://caniuse.com/mdn-html_elements_dialog">https://caniuse.com/mdn-html_elements_dialog</a></p>

<h2 id="example" id="example">Example</h2>

<p>Here is my minimal version of the implementation for Next.js with Tailwind CSS:</p>

<pre><code class="language-typescript">&#34;use client&#34;;

import { useRef } from &#34;react&#34;;

import { P } from &#34;@/components/ui&#34;;
import { Image } from &#34;@/components/image&#34;;

type Props = {
  children: string;
  image: {
    src: string;
    alt: string;
    width: number;
    height: number;
  };
};

export function GalleryItem({ children, image }: Props): JSX.Element {
  const ref = useRef&lt;HTMLDialogElement&gt;(null);

  function openModal() {
    ref.current?.showModal();
  }

  function closeModal() {
    ref.current?.close();
  }

  return (
    &lt;div&gt;
      &lt;div className=&#34;h-64 shadow shadow-black cursor-pointer overflow-hidden rounded-xl&#34;&gt;
        &lt;Image
          className=&#34;w-full h-full align-middle object-cover ease-linear duration-300 sm:hover:scale-125&#34;
          src={image.src}
          width={500}
          height={500}
          alt={image.alt}
          onClick={openModal}
        /&gt;
      &lt;/div&gt;
      &lt;dialog
        ref={ref}
        onClick={closeModal}
        className=&#34;focus:outline-none focus:ring focus:ring-neutral-500 rounded-xl backdrop:bg-neutral-800 backdrop:bg-opacity-85&#34;
      &gt;
        &lt;Image
          className=&#34;w-full h-full&#34;
          src={image.src}
          width={image.width}
          height={image.height}
          alt={image.alt}
        /&gt;
        &lt;div className=&#34;absolute bottom-0 h-1/3 w-full bg-gradient-to-t from-neutral-800 p-4 flex items-end&#34;&gt;
          &lt;P className=&#34; text-white p-0&#34;&gt;{children}&lt;/P&gt;
        &lt;/div&gt;
      &lt;/dialog&gt;
    &lt;/div&gt;
  );
}
</code></pre>

<hr/>

<p>9/100 of <a href="https://barfooz.xyz/tag:100DaysToOffload" class="hashtag"><span>#</span><span class="p-category">100DaysToOffload</span></a></p>

<p><a href="https://barfooz.xyz/tag:development" class="hashtag"><span>#</span><span class="p-category">development</span></a> <a href="https://barfooz.xyz/tag:react" class="hashtag"><span>#</span><span class="p-category">react</span></a> <a href="https://barfooz.xyz/tag:javascript" class="hashtag"><span>#</span><span class="p-category">javascript</span></a> <a href="https://barfooz.xyz/tag:typescript" class="hashtag"><span>#</span><span class="p-category">typescript</span></a> <a href="https://barfooz.xyz/tag:tailwind" class="hashtag"><span>#</span><span class="p-category">tailwind</span></a></p>

<p><a href="https://remark.as/p/barfooz.xyz/html-dialog-element-with-react-js-and-tailwind-css">Discuss...</a></p>
]]></content:encoded>
      <guid>https://barfooz.xyz/html-dialog-element-with-react-js-and-tailwind-css</guid>
      <pubDate>Sun, 25 Feb 2024 12:32:57 +0000</pubDate>
    </item>
  </channel>
</rss>