Skip to content
ui8kit

component / components

Backdrop

Backdrop component

Install

npx ui8kit add backdrop

Pulls in: box, compose, kit-box, media-frame, utils

Preview

No static preview for this item: it needs content or a parent that this page cannot supply. The code is below.

Code

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdn
npx ui8kit add backdrop
components/backdrop.svelte
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  A faint full-size picture behind the content of its section (image), or nothing (none). It sits inside the
  Block of the block, which `behind` makes `relative isolate overflow-hidden`, so the section stays the root of
  the block (rule 01).
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type BackdropProps = {
    kind?: "none" | "image";
    alt?: string;
    image?: string;
  };
</script>

<script lang="ts">
  import Box from "../compose/Box.svelte";
  import MediaFrame from "../components/media-frame.svelte";

  let { kind = "none", alt = "", image }: BackdropProps = $props();
</script>

{#if ((kind as string) === "image")}
  <Box class="pointer-events-none absolute inset-0 -z-10" data-slot="backdrop">
    <MediaFrame alt={alt} src={image} ratio="21/9" class="size-full rounded-none opacity-30" />
  </Box>
{/if}

Svelte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdn
npx ui8kit add backdrop
components/backdrop.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * A faint full-size picture behind the content of its section (image), or nothing (none). It sits inside the
 * Block of the block, which `behind` makes `relative isolate overflow-hidden`, so the section stays the root of
 * the block (rule 01).
 */
import { type ReactNode } from "react";
import { Box } from "../compose";
import { MediaFrame } from "../components/media-frame";

export type BackdropProps = {
  kind?: "none" | "image";
  alt?: string;
  image?: string;
};

export function Backdrop({ kind = "none", alt = "", image }: BackdropProps) {
  return (
    <>
      {((kind as string) === "image") ? (
        <Box className="pointer-events-none absolute inset-0 -z-10" data-slot="backdrop">
          <MediaFrame alt={alt} src={image} ratio="21/9" className="size-full rounded-none opacity-30" />
        </Box>
      ) : null}
    </>
  );
}

React registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdn
npx ui8kit add backdrop
components/backdrop.vue
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  A faint full-size picture behind the content of its section (image), or nothing (none). It sits inside the
  Block of the block, which `behind` makes `relative isolate overflow-hidden`, so the section stays the root of
  the block (rule 01).
-->
<script lang="ts">
export type BackdropProps = {
  kind?: "none" | "image";
  alt?: string;
  image?: string;
};
</script>

<script setup lang="ts">
import Box from "../compose/Box.vue";
import MediaFrame from "../components/media-frame.vue";

const { kind = "none", alt = "", image } = defineProps<BackdropProps>();
</script>

<template>
  <Box
    v-if="((kind as string) === 'image')"
    class="pointer-events-none absolute inset-0 -z-10"
    data-slot="backdrop"
  >
    <MediaFrame :alt="alt" :src="image" ratio="21/9" class="size-full rounded-none opacity-30" />
  </Box>
</template>

Vue registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdn
npx ui8kit add backdrop
components/backdrop.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * A faint full-size picture behind the content of its section (image), or nothing (none). It sits inside the
 * Block of the block, which `behind` makes `relative isolate overflow-hidden`, so the section stays the root of
 * the block (rule 01).
 */
import { type JSX } from "solid-js";
import { Box } from "../compose";
import { MediaFrame } from "../components/media-frame";

export type BackdropProps = {
  kind?: "none" | "image";
  alt?: string;
  image?: string;
};

export function Backdrop({ kind = "none", alt = "", image }: BackdropProps) {
  return (
    <>
      {((kind as string) === "image") ? (
        <Box class="pointer-events-none absolute inset-0 -z-10" data-slot="backdrop">
          <MediaFrame alt={alt} src={image} ratio="21/9" class="size-full rounded-none opacity-30" />
        </Box>
      ) : null}
    </>
  );
}

Solid registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdn
npx ui8kit add backdrop
blocks/backdrop.templ
// Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Source: packages/compose-gen/specs/patterns/backdrop.json

package blocks

import (
	"github.com/ui8kit/codegen/generated/templ/ui/box"
	"github.com/ui8kit/codegen/generated/templ/compose"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// BackdropProps are the props of Backdrop; the values are the JSON shapes of the TypeScript props.
type BackdropProps struct {
	Kind any `json:"kind"`
	Alt any `json:"alt"`
	Image any `json:"image"`
}

// A faint full-size picture behind the content of its section (image), or nothing (none). It sits inside the Block of the block, which `behind` makes `relative isolate overflow-hidden`, so the section stays the root of the block (rule 01).
templ Backdrop(p BackdropProps) {
	{{ vKind := uiutils.Def(p.Kind, "none") }}
	{{ vAlt := uiutils.Def(p.Alt, "") }}
	{{ vImage := p.Image }}
	if uiutils.Eq(vKind, "image") {
		@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "pointer-events-none absolute inset-0 -z-10", Attrs: uiutils.Attrs("data-slot", "backdrop")}}) {
			@MediaFrame(MediaFrameProps{Alt: vAlt, Src: vImage, Ratio: "21/9", Class: uiutils.Cnv("size-full rounded-none opacity-30")})
		}
	}
}

templ registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework twig --dir src --registry-url https://registry.buildy.tw/twig --strict-cdn
npx ui8kit add backdrop
blocks/backdrop.html.twig
{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/patterns/backdrop.json
    A faint full-size picture behind the content of its section (image), or nothing (none). It sits inside the Block of the block, which `behind` makes `relative isolate overflow-hidden`, so the section stays the root of the block (rule 01).
    Props (p): kind, alt, image. -#}
{%- set v_kind = (p.kind ?? 'none') -%}
{%- set v_alt = (p.alt ?? '') -%}
{%- set v_image = (p.image ?? null) -%}
{%- if og_t(og_eq(v_kind, 'image')) %}
  {%- set c_1 -%}
    {{ include('blocks/media-frame.html.twig', {'p': {'alt': v_alt, 'src': v_image, 'ratio': '21/9', 'className': og_cnv(['size-full rounded-none opacity-30'])}}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Box.html.twig', {'class': 'pointer-events-none absolute inset-0 -z-10', 'attrs': og_attrs(['data-slot', 'backdrop']), 'children': c_1}, with_context = false) }}
{%- endif %}

Twig registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework latte --dir src --registry-url https://registry.buildy.tw/latte --strict-cdn
npx ui8kit add backdrop
blocks/backdrop.latte
{* Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/patterns/backdrop.json
    A faint full-size picture behind the content of its section (image), or nothing (none). It sits inside the Block of the block, which `behind` makes `relative isolate overflow-hidden`, so the section stays the root of the block (rule 01).
    Props (p): kind, alt, image. *}
{var $v_kind = ($p['kind'] ?? 'none')}
{var $v_alt = ($p['alt'] ?? '')}
{var $v_image = ($p['image'] ?? null)}
{if og_t(og_eq($v_kind, 'image'))}
  {capture $c_1}
    {=og_include('blocks/media-frame.latte', ['p' => ['alt' => $v_alt, 'src' => $v_image, 'ratio' => '21/9', 'className' => og_cnv(['size-full rounded-none opacity-30'])]])|noescape}
  {/capture}
  {=og_include('compose/Box.latte', ['class' => 'pointer-events-none absolute inset-0 -z-10', 'attrs' => og_attrs(['data-slot', 'backdrop']), 'children' => (string) $c_1])|noescape}
{/if}

Latte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework jinja2 --dir src --registry-url https://registry.buildy.tw/jinja2 --strict-cdn
npx ui8kit add backdrop
blocks/backdrop.html.j2
{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/patterns/backdrop.json
    A faint full-size picture behind the content of its section (image), or nothing (none). It sits inside the Block of the block, which `behind` makes `relative isolate overflow-hidden`, so the section stays the root of the block (rule 01).
    Props (p): kind, alt, image. -#}
{%- set v_kind = og_def(p['kind'], 'none') -%}
{%- set v_alt = og_def(p['alt'], '') -%}
{%- set v_image = og_def(p['image'], none) -%}
{%- if og_t(og_eq(v_kind, 'image')) %}
  {%- set c_1 -%}
    {{ og_include('blocks/media-frame.html.j2', {'p': {'alt': v_alt, 'src': v_image, 'ratio': '21/9', 'className': og_cnv(['size-full rounded-none opacity-30'])}}) }}
  {%- endset -%}
  {{ og_include('compose/box.html.j2', {'p': {'Class': 'pointer-events-none absolute inset-0 -z-10', 'Attrs': og_attrs(['data-slot', 'backdrop'])}, 'children': c_1}) }}
{%- endif %}

Jinja2 registry item (JSON)

Props

Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.

A faint full-size picture behind the content of its section (image), or nothing (none). It sits inside the Block of the block, which `behind` makes `relative isolate overflow-hidden`, so the section stays the root of the block (rule 01).

Props of Backdrop
PropTypeDefault Description
kind "none" | "image""none"what is drawn behind
alt string""accessible name of the picture (image)
image string-address of the picture (image); none: the placeholder

Used in