Skip to content
ui8kit

primitive / kit

Kit Separator

UI8Kit 3 Separator primitive (unstyled), from @ui8kit/registry

Install

npx ui8kit add kit-separator

Pulls in: 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 kit-separator
kit/ui/separator/Separator.svelte
<!-- Code generated by @ui8kit/codegen. DO NOT EDIT. -->
<!--
  Separator renders a void hr; no children.
-->
<script lang="ts" module>

  export type SeparatorProps = {
    orientation?: "horizontal" | "vertical";
    decorative?: boolean;
    class?: string;
    [key: string]: unknown;
  };
</script>

<script lang="ts">
  import { separatorClasses } from "./separator.shared";
  import { eqStr, oneOfOrLower, safeRest } from "../../utils/expr";

  let {
    orientation,
    decorative,
    class: className,
    ...rawRest
  }: SeparatorProps = $props();

  const rest = $derived(safeRest(rawRest));
  const cls = $derived(separatorClasses({ className }));
</script>

<hr {...(cls ? { class: cls } : {})} role={decorative ? "none" : undefined} aria-orientation={(!(decorative) && eqStr(oneOfOrLower(orientation, "horizontal", "vertical"), "vertical")) ? "vertical" : undefined} {...rest} />
kit/ui/separator/separator.shared.ts
// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.separator — shared TypeScript contract (types + classes helpers)

import { cn } from "../../utils";

/** Separator renders a void hr; no children. */
export type SeparatorBaseProps = {
  orientation?: "horizontal" | "vertical";
  decorative?: boolean;
};

export type SeparatorClassesInput = {
  className?: string;
};

/** Compose Separator classes without rendering — the cross-runtime `asChild` substitute. */
export function separatorClasses(input: SeparatorClassesInput = {}): string {
  return cn(input.className);
}

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 kit-separator
kit/ui/separator/separator.shared.ts
// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.separator — shared TypeScript contract (types + classes helpers)

import { cn } from "../../utils";

/** Separator renders a void hr; no children. */
export type SeparatorBaseProps = {
  orientation?: "horizontal" | "vertical";
  decorative?: boolean;
};

export type SeparatorClassesInput = {
  className?: string;
};

/** Compose Separator classes without rendering — the cross-runtime `asChild` substitute. */
export function separatorClasses(input: SeparatorClassesInput = {}): string {
  return cn(input.className);
}
kit/ui/separator/separator.tsx
// Code generated by @ui8kit/codegen. DO NOT EDIT.
/**
 * Separator is the native <hr> (implicit role=separator). Vertical adds
 * aria-orientation; Decorative removes the semantics with role=none.
 */

import { forwardRef, type HTMLAttributes } from "react";
import { separatorClasses } from "./separator.shared";
import { eqStr, oneOfOrLower, safeRest } from "../../utils/expr";

/**
 * Separator renders a void hr; no children.
 */
export type SeparatorProps = Omit<HTMLAttributes<HTMLHRElement>, "className" | "children" | "orientation" | "decorative"> & {
  orientation?: "horizontal" | "vertical";
  decorative?: boolean;
  className?: string;
};

export const Separator = forwardRef<HTMLHRElement, SeparatorProps>(function Separator(
  { orientation, decorative, className, ...rawRest },
  ref
) {
  const rest = safeRest(rawRest);
  const cls = separatorClasses({ className });
  return (
    <hr ref={ref} className={cls || undefined} role={decorative ? "none" : undefined} aria-orientation={(!(decorative) && eqStr(oneOfOrLower(orientation, "horizontal", "vertical"), "vertical")) ? "vertical" : undefined} {...rest} />
  );
});
Separator.displayName = "Separator";

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 kit-separator
kit/ui/separator/Separator.vue
<!-- Code generated by @ui8kit/codegen. DO NOT EDIT. -->
<!--
  Separator renders a void hr; no children.
-->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import { separatorClasses } from "./separator.shared";
import { eqStr, oneOfOrLower, safeRest } from "../../utils/expr";

defineOptions({ name: "Separator", inheritAttrs: false });

const props = defineProps<{
  orientation?: "horizontal" | "vertical";
  decorative?: boolean;
}>();

const attrs = useAttrs();
const callerClass = computed(() => attrs.class as string | undefined);
const restAttrs = computed(() => {
  const { class: _class, ...restEntries } = attrs;
  return safeRest(restEntries);
});
const cls = computed(() => separatorClasses({ className: callerClass.value }));
</script>

<template>
  <hr :class="cls || undefined" :role="props.decorative ? 'none' : undefined" :aria-orientation="(!(props.decorative) && eqStr(oneOfOrLower(props.orientation, 'horizontal', 'vertical'), 'vertical')) ? 'vertical' : undefined" v-bind="restAttrs" />
</template>
kit/ui/separator/separator.shared.ts
// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.separator — shared TypeScript contract (types + classes helpers)

import { cn } from "../../utils";

/** Separator renders a void hr; no children. */
export type SeparatorBaseProps = {
  orientation?: "horizontal" | "vertical";
  decorative?: boolean;
};

export type SeparatorClassesInput = {
  className?: string;
};

/** Compose Separator classes without rendering — the cross-runtime `asChild` substitute. */
export function separatorClasses(input: SeparatorClassesInput = {}): string {
  return cn(input.className);
}

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 kit-separator
kit/ui/separator/separator.shared.ts
// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.separator — shared TypeScript contract (types + classes helpers)

import { cn } from "../../utils";

/** Separator renders a void hr; no children. */
export type SeparatorBaseProps = {
  orientation?: "horizontal" | "vertical";
  decorative?: boolean;
};

export type SeparatorClassesInput = {
  className?: string;
};

/** Compose Separator classes without rendering — the cross-runtime `asChild` substitute. */
export function separatorClasses(input: SeparatorClassesInput = {}): string {
  return cn(input.className);
}
kit/ui/separator/separator.solid.tsx
// Code generated by @ui8kit/codegen. DO NOT EDIT.
/**
 * Separator is the native <hr> (implicit role=separator). Vertical adds
 * aria-orientation; Decorative removes the semantics with role=none.
 */

import { splitProps, type JSX, type Component } from "solid-js";
import { separatorClasses } from "./separator.shared";
import { eqStr, oneOfOrLower, safeRest } from "../../utils/expr";

/**
 * Separator renders a void hr; no children.
 */
export type SeparatorProps = Omit<JSX.HTMLAttributes<HTMLHRElement>, "class" | "className" | "children" | "orientation" | "decorative"> & {
  orientation?: "horizontal" | "vertical";
  decorative?: boolean;
  class?: string;
  className?: string;
};

export const Separator: Component<SeparatorProps> = (props) => {
  const [local, rest] = splitProps(props, ["orientation", "decorative", "class", "className"]);
  const cls = () => separatorClasses({ className: local.class ?? local.className });
  return (
    <hr {...(cls() ? { class: cls() } : {})} role={local.decorative ? "none" : undefined} aria-orientation={(!(local.decorative) && eqStr(oneOfOrLower(local.orientation, "horizontal", "vertical"), "vertical")) ? "vertical" : undefined} {...safeRest(rest)} />
  );
};

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 kit-separator
ui/separator/separator.templ
// Code generated by @ui8kit/codegen. DO NOT EDIT.

/*
Separator is the native <hr> (implicit role=separator). Vertical adds
aria-orientation; Decorative removes the semantics with role=none.
*/

package separator

import (
	uiutils "github.com/ui8kit/codegen/generated/templ/utils"
)

// SeparatorProps configures Separator.
type SeparatorProps struct {
	// Class — token class names supplied by the consumer
	Class string
	// Orientation — horizontal (default) | vertical
	Orientation string
	// Decorative — purely visual: role=none, no separator semantics
	Decorative bool
	Attrs templ.Attributes
}

// SeparatorClasses composes Separator classes without rendering —
// the server-composition escape hatch for custom root elements (no asChild in templ).
func SeparatorClasses(p SeparatorProps) string {
	return uiutils.Cn(p.Class)
}

// Separator renders the Separator contract.
templ Separator(p SeparatorProps) {
	<hr
		if SeparatorClasses(p) != "" {
			class={ SeparatorClasses(p) }
		}
		if !uiutils.HasAttr(p.Attrs, "role") {
			if p.Decorative {
				role={ "none" }
			}
		}
		if !uiutils.HasAttr(p.Attrs, "aria-orientation") {
			if (!p.Decorative && (uiutils.OneOfOrLower(p.Orientation, "horizontal", "vertical") == "vertical")) {
				aria-orientation={ "vertical" }
			}
		}
		{ uiutils.RestAttrs(p.Attrs, false)... }
	/>
}

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 kit-separator
ui/separator/Separator.html.twig
{# Code generated by @ui8kit/codegen. DO NOT EDIT. #}
{# Separator — Separator renders a void hr; no children. #}
{# @param class (string) #}
{# @param orientation (string) #}
{# @param decorative (bool) #}
{# @param attrs (attrs) #}
{% set class = class|default('') %}
{% set orientation = orientation|default('') %}
{% set decorative = decorative|default(false) %}
{% set attrs = attrs|default([]) %}
<hr{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('separatorClasses', {'class': class, 'orientation': orientation, 'decorative': decorative})), 'role': (decorative ? 'none' : null), 'aria-orientation': (((not decorative) and (ui8kit_one_of_or_lower(orientation, 'horizontal', ['vertical']) is same as('vertical'))) ? 'vertical' : null)}, attrs) }}>

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 kit-separator
ui/separator/Separator.latte
{* Code generated by @ui8kit/codegen. DO NOT EDIT. *}
{* Separator — Separator renders a void hr; no children. *}
{parameters
  string $class = '',
  string $orientation = '',
  bool $decorative = false,
  array $attrs = [],
}
<hr n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::separatorClasses(['class' => $class, 'orientation' => $orientation, 'decorative' => $decorative])),
  'role' => ($decorative ? 'none' : null),
  'aria-orientation' => ((!$decorative && (\UI8Kit\Latte\Rt::oneOfOrLower($orientation, 'horizontal', ['vertical']) === 'vertical')) ? 'vertical' : null),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">

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 kit-separator
ui/separator/separator.html.j2
{#- Code generated by @ui8kit/codegen. DO NOT EDIT.
    Separator: Separator renders a void hr; no children.
    Props (p): Class (string), Orientation (string), Decorative (bool), Attrs (attrs).
    Classes without rendering: separator_classes(p) (no asChild in Jinja2). -#}
<hr
  {%- with cls = separator_classes(p) %}{%- if cls %} class="{{ cls }}"{%- endif %}{%- endwith %}
  {%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'role') %}{%- if ui_def(p['Decorative'], false) %} role="{{ 'none' }}"{%- endif %}{%- endif %}
  {%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'aria-orientation') %}{%- if ((not ui_def(p['Decorative'], false)) and ui_eq(ui_map_or(ui_def(p['Orientation'], ''), {'vertical': 'vertical'}, 'horizontal', true), 'vertical')) %} aria-orientation="{{ 'vertical' }}"{%- endif %}{%- endif %}
  {{ ui_attr_html(ui_def(p['Attrs'], {})) }}
>

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.

No props data for this item.