Skip to component content
Layout155 / 155

ContentRegion

Keep a heading stationary above labeled scrolling content.

Example

Updates

The heading stays in place.

Update 1A short project update for the team.
Update 2A short project update for the team.
Update 3A short project update for the team.
Update 4A short project update for the team.
Update 5A short project update for the team.
Update 6A short project update for the team.
Update 7A short project update for the team.
Update 8A short project update for the team.
Update 9A short project update for the team.
Update 10A short project update for the team.
Update 11A short project update for the team.
Update 12A short project update for the team.
Source
ContentRegion.tsxtsx
import { useState } from "react";
import { AppFrame, ContentRegion, HStack, NavigationTitle, Picker, Row, Toggle, ViewFrame, VStack } from "@/ohmygui";

export default function Example() {
  const [width, setWidth] = useState<"content" | "full">("content");
  const [contentHeight, setContentHeight] = useState<"natural" | "fill">("natural");
  const [scrollable, setScrollable] = useState(true);

  return (
    <VStack gap="md" align="stretch">
      <HStack gap="md" wrap>
        <Picker label="Content width" value={width} onChange={(event) => setWidth(event.currentTarget.value as typeof width)} items={[{ value: "content", label: "Reading width" }, { value: "full", label: "Full width" }]} />
        <Picker label="Content height" value={contentHeight} onChange={(event) => setContentHeight(event.currentTarget.value as typeof contentHeight)} items={[{ value: "natural", label: "Natural" }, { value: "fill", label: "Fill available space" }]} />
        <Toggle label="Scroll content" checked={scrollable} onChange={(event) => setScrollable(event.currentTarget.checked)} />
      </HStack>
      <ViewFrame height={360}>
        <AppFrame as="section" viewport={false}>
          <ContentRegion
            label="Project updates"
            width={width}
            contentHeight={contentHeight}
            scrollable={scrollable}
            heading={<NavigationTitle title="Updates" subtitle="The heading stays in place." size="section" level={3} />}
          >
            {Array.from({ length: 12 }, (_, index) => (
              <Row key={index} title={`Update ${index + 1}`} description="A short project update for the team." divider />
            ))}
          </ContentRegion>
        </AppFrame>
      </ViewFrame>
    </VStack>
  );
}