Grapes homepage1.57.0
  • Guide
  • Tokens
  • Components
    Grapes on GithubGrapes on Figma
    Interaction
    • Button
    • IconButton
    • FloatingActionBar
    • Link
    Icons
    • Icon
    • HighlightIcon
    Form
    • AmountInput
    • Autocomplete
    • AutocompleteMultiple
    • AutocompletePlace
    • CheckboxBox
    • CheckboxField
    • DatePicker
    • FormField
    • Input
    • OptionGroup
    • PasswordInput
    • PhoneInput
    • RadioBox
    • RadioField
    • RadioGroup
    • Select
    • SwitchField
    • TextArea
    • TextInput
    • Upload
    • UploadButton
    Feedback
    • Badge
    • Banner
    • Callout
    • EmptyState
    • Modal
    • ModalSlideshow
    • DeprecatedModalSlideshow
    • PageModal
    • Skeleton
    • Tag
    • Toast
    • Tooltip
    Data display
    • Accordion
    • Avatar
    • Box
    • Calendar
    • CalendarRange
    • CollapsibleList
    • FileCard
    • InfoTip
    • ListBox
    • ListView
    • Panel
    • SidePanel
    • DeprecatedPreview
    • Table
    • Timeline
    • useDateFormatter
    Navigation
    • DropdownItem
    • DropdownMenu
    • Navigation
    • NavigationItem
    • Popover
    • Tabs

    Panel

    A panel is a folding block displaying compact information and controls.

    View source code
    • Usage
    • Props

    Import

    • Panel: The panel component.
    • PanelSection: A helper component designed to represent a section inside the panel.

    Basic usage

    The Panel component is highly customizable, first with the title, header, footer, and footerSummary props, which are used to add content at the top and bottom of the panel, and the onClose prop which will add the cross icon at the top of the panel.

    The PanelSection component lets you define sections inside the panel, which will automatically be separated by dividers. The isEditable and isCollapsible props allow you to define your sections as editable or collapsible, and a number of props will help you customize editable sections.

    const Demo = () => {
      const [legalName, setLegalName] = useState("google");
      const [tmpLegalName, setTmpLegalName] = useState("");
    
      return (
        <Panel
          title="Supplier details"
          onClose={() => {}}
          header={
            <>
              <Avatar
                iconName="building-storefront"
                text="supplier"
                variant="square"
              />
              <div>
                <div>Google</div>
                <div>401000</div>
              </div>
            </>
          }
          footer={
            <Button
              variant="secondaryNeutral"
              fit="parent"
              text="Archive supplier"
            />
          }
          footerSummary={{
            title: "Summary",
            isCollapsible: true,
            content: (
              <>
                <div>Total amount</div>
                <div>500€</div>
              </>
            ),
          }}
        >
          <PanelSection
            title="Information"
            isEditable
            editSection={
              <FormField label="Legal name">
                <TextInput
                  onChange={(event) => setTmpLegalName(event.target.value)}
                  value={tmpLegalName}
                />
              </FormField>
            }
            cancelTranslation="Cancel"
            saveTranslation="Save changes"
            onSave={() => {
              setLegalName(tmpLegalName);
            }}
            onCancel={() => {
              console.log("onCancel");
            }}
          >
            <div>Legal name</div>
            <div>{legalName}</div>
          </PanelSection>
          <PanelSection title="Bank details" isEditable={false} isCollapsible>
            <div>Bank country</div>
            <div>France</div>
            <div>IBAN</div>
            <div>-</div>
            <div>BIC</div>
            <div>-</div>
          </PanelSection>
          <PanelSection title="Proof of bank details" isEditable={false}>
            <DeprecatedPreview
              fit="parent"
              iconName="receipt-checked"
              primaryText="Uploaded on November 4, 2020"
              rightAddon={
                <Icon
                  aria-hidden="true"
                  color="var(--grapes-color-content-decorative-icon)"
                  name="magnifying-glass"
                />
              }
            />
          </PanelSection>
        </Panel>
      );
    };
    

    Footer and footer summary

    Content Overflow in Footer Summary

    The Footer Summary, when configured as collapsible, benefits from an animation effect when it is revealed or concealed. This animation requires the use of an overflow property to ensure the content appears and disappears smoothly.

    As a result, components such as Popover, Select, and DropdownMenu are not compatible, as they cannot properly overflow the Footer Summary's boundaries.

    It is recommended to avoid using these components within an Collapsible Footer Summary to ensure proper functionality.

    However, if you must use these components, you can use the noAnimation prop. This prop will disable the animation, thereby eliminating the need for the overflow property.

    Two props are available to display information at the bottom of a panel: footer and footerSummary. You can use one or the other, or both at the same time.

    The footerSummary has a number of options, including title and content, and can be collapsed with the isCollapsible property. If the footer summary is collapsed, the options isDefaultCollapsed, onCollapsed, and onExtended become available.

    <>
      <Panel footer={<div>Footer</div>}></Panel>
      <Panel footerSummary={{ content: "Footer summary" }}></Panel>
      <Panel
        footerSummary={{
          title: "Collapsible footer summary",
          content: <div className="mt-16">Footer summary content</div>,
          isCollapsible: true,
        }}
      ></Panel>
      <Panel
        footer={<div>Footer</div>}
        footerSummary={{ content: "Footer summary" }}
      ></Panel>
    </>
    

    Supplier details

    Google
    401000
    Information
    Legal name
    google
    Bank details
    Bank country
    France
    IBAN
    -
    BIC
    -
    Proof of bank details
    Summary
    Total amount
    500€

    Panel title

    Footer

    Panel title

    Footer summary

    Panel title

    Collapsible footer summary
    Footer summary content

    Panel title

    Footer summary
    Footer