CxJS

Section

import { Section } from 'cx/widgets'; Copied

Sections are used to divide a larger body into distinct parts. A section optionally may have a header (title) and a footer.

Note

Section predates Tailwind CSS and is rarely used when Tailwind is available. Consider using Tailwind’s card utilities instead.

<div className="flex flex-col gap-4">
  <Section mod="card" title="Simple Section">
    This is a simple section with a title and some content.
  </Section>

  <Section mod="card" title="Section with Footer">
    This section has a footer with action buttons.
    <FlexRow putInto="footer" spacing>
      <Button mod="hollow" icon="calendar" />
      <Button mod="hollow" icon="calculator" />
      <Button mod="hollow" icon="search" />
    </FlexRow>
  </Section>

  <Section mod="card">
    <FlexRow align="center" putInto="header">
      <Heading level={4} className="text-blue-400">
        Custom Header
      </Heading>
      <Button mod="hollow" icon="x" style="margin-left: auto" />
    </FlexRow>
    This section has a custom header with a close button.
  </Section>
</div>

Simple Section

This is a simple section with a title and some content.

Section with Footer

This section has a footer with action buttons.

Custom Header

This section has a custom header with a close button.

Mods

<div className="grid grid-cols-2 gap-4">
  <Section mod="primary" title="mod=primary">
    Primary style with blue background.
  </Section>

  <Section mod="success" title="mod=success">
    Success style with green background.
  </Section>

  <Section mod="warning" title="mod=warning">
    Warning style with orange background.
  </Section>

  <Section mod="error" title="mod=error">
    Error style with red background.
  </Section>
</div>

mod=primary

Primary style with blue background.

mod=success

Success style with green background.

mod=warning

Warning style with orange background.

mod=error

Error style with red background.

Configuration

PropertyTypeDescription
titlestringSection’s title text.
headerconfigCustom content for the header. Use putInto="header" on child elements.
footerconfigCustom content for the footer. Use putInto="footer" on child elements.
padbooleanAdd default padding to the section body. Default is true.
modstringVisual modifier. Values: card, primary, success, warning, error.
hLevelnumberHeading level for the title. Default is 3.
headerStylestring | objectCustom style for the header.
headerClassstring | objectAdditional CSS class for the header.
bodyStylestring | objectCustom style for the body.
bodyClassstring | objectAdditional CSS class for the body.
footerStylestring | objectCustom style for the footer.
footerClassstring | objectAdditional CSS class for the footer.
baseClassstringBase CSS class. Default is section.