Skip to content
ui8kit

component / components

Section Box

Section Box component

Install

npx ui8kit add section-box

Pulls in: card, compose, kit-box, utils

Preview

Available for projects

Hi, I design calm software

Nine years of product design for teams that ship every week. I like systems, plain words and short feedback loops.

Design systems

95%

User research

85%

Prototyping

90%

Frontend code

70%

Product writing

80%

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 section-box
components/section-box.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. -->
<!-- The body of a SectionFrame: inside a card when `boxed`, else the children as they are (no wrapper). -->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type SectionBoxProps = {
    boxed?: boolean;
    children?: Snippet;
  };
</script>

<script lang="ts">
  import Card from "../compose/Card.svelte";

  let { boxed = false, children }: SectionBoxProps = $props();
</script>

{#if boxed}
  <Card variant="muted">
    {@render children?.()}
  </Card>
{:else}
  {@render children?.()}
{/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 section-box
components/section-box.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.
/** The body of a SectionFrame: inside a card when `boxed`, else the children as they are (no wrapper). */
import { type ReactNode } from "react";
import { Card } from "../compose";

export type SectionBoxProps = {
  boxed?: boolean;
  children?: ReactNode;
};

export function SectionBox({ boxed = false, children }: SectionBoxProps) {
  return (
    <>
      {boxed ? (
        <Card variant="muted">
          {children}
        </Card>
      ) : (
        <>
          {children}
        </>
      )}
    </>
  );
}

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 section-box
components/section-box.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. -->
<!-- The body of a SectionFrame: inside a card when `boxed`, else the children as they are (no wrapper). -->
<script lang="ts">
export type SectionBoxProps = {
  boxed?: boolean;
};
</script>

<script setup lang="ts">
import Card from "../compose/Card.vue";

const { boxed = false } = defineProps<SectionBoxProps>();
defineSlots<{ default?(): unknown }>();
</script>

<template>
  <Card v-if="boxed" variant="muted">
    <slot />
  </Card>
  <slot v-else />
</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 section-box
components/section-box.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.
/** The body of a SectionFrame: inside a card when `boxed`, else the children as they are (no wrapper). */
import { type JSX } from "solid-js";
import { Card } from "../compose";

export type SectionBoxProps = {
  boxed?: boolean;
  children?: JSX.Element;
};

export function SectionBox({ boxed = false, children }: SectionBoxProps) {
  return (
    <>
      {boxed ? (
        <Card variant="muted">
          {children}
        </Card>
      ) : (
        <>
          {children}
        </>
      )}
    </>
  );
}

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 section-box
blocks/section-box.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/section-box.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"
)

// SectionBoxProps are the props of SectionBox; the values are the JSON shapes of the TypeScript props.
type SectionBoxProps struct {
	Boxed any `json:"boxed"`
}

// The body of a SectionFrame: inside a card when `boxed`, else the children as they are (no wrapper).
templ SectionBox(p SectionBoxProps) {
	{{ vBoxed := uiutils.Def(p.Boxed, false) }}
	if uiutils.T(vBoxed) {
		@compose.Card(compose.CardProps{Variant: "muted", BoxProps: box.BoxProps{}}) {
			{ children... }
		}
	} else {
		{ children... }
	}
}

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 section-box
blocks/section-box.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/section-box.json
    The body of a SectionFrame: inside a card when `boxed`, else the children as they are (no wrapper).
    Props (p): boxed; children: markup. -#}
{%- set v_boxed = (p.boxed ?? false) -%}
{%- if og_t(v_boxed) %}
  {%- set c_1 -%}
    {{ og_slot((children ?? null))|raw }}
  {%- endset -%}
  {{ include('compose/Card.html.twig', {'variant': 'muted', 'children': c_1}, with_context = false) }}
{%- else %}
  {{ og_slot((children ?? null))|raw }}
{%- 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 section-box
blocks/section-box.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/section-box.json
    The body of a SectionFrame: inside a card when `boxed`, else the children as they are (no wrapper).
    Props (p): boxed; children: markup. *}
{var $v_boxed = ($p['boxed'] ?? false)}
{if og_t($v_boxed)}
  {capture $c_1}
    {=og_slot(($children ?? null))|noescape}
  {/capture}
  {=og_include('compose/Card.latte', ['variant' => 'muted', 'children' => (string) $c_1])|noescape}
{else}
  {=og_slot(($children ?? null))|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 section-box
blocks/section-box.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/section-box.json
    The body of a SectionFrame: inside a card when `boxed`, else the children as they are (no wrapper).
    Props (p): boxed; children: markup. -#}
{%- set v_boxed = og_def(p['boxed'], false) -%}
{%- if og_t(v_boxed) %}
  {%- set c_1 -%}
    {{ og_slot(og_def(children, none))|safe }}
  {%- endset -%}
  {{ og_include('compose/card.html.j2', {'p': {'Variant': 'muted'}, 'children': c_1}) }}
{%- else %}
  {{ og_slot(og_def(children, none))|safe }}
{%- 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.

The body of a SectionFrame: inside a card when `boxed`, else the children as they are (no wrapper).

Props of SectionBox
PropTypeDefault Description
boxed booleanfalsethe children sit in a card

Used in